-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmeta.js
More file actions
67 lines (54 loc) · 2.6 KB
/
meta.js
File metadata and controls
67 lines (54 loc) · 2.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// Define the GitHub username
const githubUsername = "TheBaconSpace";
// Get the GitHub avatar using the GitHub API
fetch(`https://api.github.com/users/${githubUsername}`)
.then((response) => response.json())
.then((data) => {
// Extract the avatar URL from the response data
const avatarUrl = data.avatar_url;
// Create meta tags for Open Graph properties
const ogTitleTag = document.createElement("meta");
ogTitleTag.setAttribute("property", "og:title");
ogTitleTag.setAttribute("content", "Bacon_Space Social Links");
const ogTypeTag = document.createElement("meta");
ogTypeTag.setAttribute("property", "og:type");
ogTypeTag.setAttribute("content", "profile");
const ogUrlTag = document.createElement("meta");
ogUrlTag.setAttribute("property", "og:url");
ogUrlTag.setAttribute("content", "https://thebaconspace.github.io");
const ogImageTag = document.createElement("meta");
ogImageTag.setAttribute("property", "og:image");
ogImageTag.setAttribute("content", avatarUrl);
// Append the meta tags to the document's head
document.head.appendChild(ogTitleTag);
document.head.appendChild(ogTypeTag);
document.head.appendChild(ogUrlTag);
document.head.appendChild(ogImageTag);
// Create a link element for the favicon
const faviconLink = document.createElement("link");
faviconLink.rel = "icon";
faviconLink.href = avatarUrl;
// Append the link element to the document's head for the favicon
document.head.appendChild(faviconLink);
// Add Twitter card meta tags
const twitterCardTag = document.createElement("meta");
twitterCardTag.setAttribute("name", "twitter:card");
twitterCardTag.setAttribute("content", "summary_large_image");
const twitterSiteTag = document.createElement("meta");
twitterSiteTag.setAttribute("name", "twitter:site");
twitterSiteTag.setAttribute("content", "@Bacon_Space");
const twitterCreatorTag = document.createElement("meta");
twitterCreatorTag.setAttribute("name", "twitter:creator");
twitterCreatorTag.setAttribute("content", "@Bacon_Space");
const twitterTitleTag = document.createElement("meta");
twitterTitleTag.setAttribute("name", "twitter:title");
twitterTitleTag.setAttribute("content", "Bacon_Space Social Links");
// Append Twitter card meta tags to the document's head
document.head.appendChild(twitterCardTag);
document.head.appendChild(twitterSiteTag);
document.head.appendChild(twitterCreatorTag);
document.head.appendChild(twitterTitleTag);
})
.catch((error) => {
console.error("Error fetching GitHub data:", error);
});