-
Notifications
You must be signed in to change notification settings - Fork 76
/
main.js
97 lines (95 loc) · 2.54 KB
/
main.js
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
// Global Variables
let userData;
// Docsify Configurations
window.$docsify = {
name: "Journey Book",
repo: "collab-community/journey-book",
themeColor: "#FF6863",
loadSidebar: "_layouts/sidebar.md",
loadNavbar: "_layouts/navbar.md",
homepage: "index.md",
relativePath: true,
executeScript: true,
search: "auto",
search: {
maxAge: 86400000,
paths: "auto",
placeholder: "Search",
noData: "No Results found!",
depth: 6,
hideOtherSidebarContent: false,
},
vueGlobalOptions: {
data() {
return {
users: null,
};
},
created() {
fetch("Data.json")
.then((response) => response.json())
.then((data) => {
this.users = sortUsers(data);
userData = sortUsers(data);
})
.catch((err) => console.log(err));
},
},
darklightTheme: {
siteFont: "PT Sans",
defaultTheme: "dark",
codeFontFamily: "Roboto Mono, Monaco, courier, monospace",
bodyFontSize: "17px",
dark: {
accent: "#42b983",
toogleBackground: "#ffffff",
background: "#171717",
textColor: "#b4b4b4",
codeTextColor: "#ffffff",
codeBackgroundColor: "#171717",
borderColor: "#0d2538",
blockQuoteColor: "#858585",
highlightColor: "#d22778",
sidebarSublink: "#b4b4b4",
codeTypeColor: "#ffffff",
coverBackground:
"linear-gradient(to left bottom, hsl(118, 100%, 85%) 0%,hsl(181, 100%, 85%) 100%)",
toogleImage:
"url(https://cdn.jsdelivr.net/npm/docsify-darklight-theme@latest/icons/sun.svg)",
},
light: {
accent: "#42b983",
toogleBackground: "#ffffff",
background: "##ffffff",
textColor: "#000000",
},
},
};
// Function to sort the users alphabetically
const sortUsers = (users) => {
const sortedUsers = users.sort((a, b) => {
const nameA = a.name.toUpperCase();
const nameB = b.name.toUpperCase();
if (nameA < nameB) {
return -1;
}
if (nameA > nameB) {
return 1;
}
return 0;
});
return sortedUsers;
};
// Update Favicon
window.addEventListener("hashchange", function () {
if (!location.hash.startsWith("#/journeys")) {
document
.getElementById("favicon")
.setAttribute("href", "./assets/favicon.ico");
} else {
const username = location.hash.split("/")[2];
const user = userData.find((user) => user.username === username);
const favicon = `https://images.weserv.nl/?url=${user.avatar}&mask=circle&mtrim`;
document.getElementById("favicon").setAttribute("href", favicon);
}
});