jekyll-theme-primerpages 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/LICENSE +21 -0
- data/README.md +65 -0
- data/_config.yml +149 -0
- data/_includes/awesome-nav-breadcrumb-trail.html +33 -0
- data/_includes/awesome-nav-breadcrumbs.html +51 -0
- data/_includes/awesome-nav-menu-tree.html +21 -0
- data/_includes/awesome-nav-menu.html +68 -0
- data/_includes/awesome-nav-sidebar.html +7 -0
- data/_includes/awesome-nav-tree.html +52 -0
- data/_includes/breadcrumbs.html +62 -0
- data/_includes/category_index.html +18 -0
- data/_includes/collection-menu.html +79 -0
- data/_includes/collection-sidebar.html +23 -0
- data/_includes/custom-colors.html +99 -0
- data/_includes/footer.html +13 -0
- data/_includes/head.html +43 -0
- data/_includes/header-appbar.html +53 -0
- data/_includes/header-sidebar.html +60 -0
- data/_includes/header-stacked.html +33 -0
- data/_includes/header-topbar.html +59 -0
- data/_includes/link-card.html +52 -0
- data/_includes/links.html +12 -0
- data/_includes/masthead.html +18 -0
- data/_includes/mini-repo-info-card.html +30 -0
- data/_includes/nav-overlay.html +53 -0
- data/_includes/nav.html +51 -0
- data/_includes/navbar-underline.html +51 -0
- data/_includes/paginator_nav.html +28 -0
- data/_includes/post-card.html +27 -0
- data/_includes/post-feature-card.html +24 -0
- data/_includes/post-gallery.html +52 -0
- data/_includes/post-index.html +35 -0
- data/_includes/post-tease-image-card.html +22 -0
- data/_includes/post-tease-text-card.html +12 -0
- data/_includes/post-timeline-card.html +84 -0
- data/_includes/post-timeline.html +31 -0
- data/_includes/posts.html +12 -0
- data/_includes/related.html +116 -0
- data/_includes/repo-card.html +43 -0
- data/_includes/repositories.html +27 -0
- data/_includes/resolve-versioning.html +16 -0
- data/_includes/social.html +390 -0
- data/_includes/toggle.html +4 -0
- data/_includes/user-metadata.html +36 -0
- data/_includes/version-selector.html +22 -0
- data/_includes/version-warning.html +15 -0
- data/_layouts/category_index.html +16 -0
- data/_layouts/category_layout.html +33 -0
- data/_layouts/default.html +33 -0
- data/_layouts/docs.html +189 -0
- data/_layouts/docs_index.html +32 -0
- data/_layouts/home.html +3 -0
- data/_layouts/landing.html +38 -0
- data/_layouts/linktree.html +36 -0
- data/_layouts/page.html +22 -0
- data/_layouts/paginate.html +16 -0
- data/_layouts/paginate_timeline.html +17 -0
- data/_layouts/post.html +136 -0
- data/_layouts/profile.html +48 -0
- data/_layouts/repositories.html +11 -0
- data/_layouts/tag_index.html +16 -0
- data/_layouts/tags.html +12 -0
- data/_sass/_admonitions.scss +69 -0
- data/_sass/_highlight-syntax.scss +96 -0
- data/_sass/_language-colors.scss +1443 -0
- data/_sass/_main.scss +274 -0
- data/_sass/jekyll-theme-primerpages-compat.scss +5 -0
- data/_sass/jekyll-theme-primerpages.scss +7 -0
- data/assets/css/style.scss +2 -0
- data/assets/css/theme.scss +16 -0
- data/assets/img/default.png +0 -0
- data/assets/img/favicon.ico +0 -0
- data/assets/img/social-preview.png +0 -0
- data/assets/img/user-image.jpg +0 -0
- data/assets/js/anchor-links.js +47 -0
- data/assets/js/mermaid.js +61 -0
- data/assets/js/theme-toggle.js +84 -0
- data/assets/js/topbar.js +19 -0
- data/assets/js/versioning.js +300 -0
- metadata +184 -0
data/_sass/_main.scss
ADDED
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
:root {
|
|
2
|
+
--topbar-height: 150px;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
// Needed for setting the background overlay
|
|
6
|
+
body::before {
|
|
7
|
+
content: "";
|
|
8
|
+
position: absolute;
|
|
9
|
+
top: 0;
|
|
10
|
+
right: 0;
|
|
11
|
+
bottom: 0;
|
|
12
|
+
left: 0;
|
|
13
|
+
z-index: -1;
|
|
14
|
+
background-color: var(--overlay-color);
|
|
15
|
+
/* Use the --overlay-color variable here */
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.topbar-aware-height {
|
|
19
|
+
height: calc(100vh - var(--topbar-height, 150px));
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.topbar-aware-top {
|
|
23
|
+
top: var(--topbar-height, 150px);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.avatar-user {
|
|
27
|
+
border-radius: 50% !important;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// Needed to support custom background with a sidebar
|
|
31
|
+
.background-fixed {
|
|
32
|
+
background-attachment: fixed !important;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// If a user adds a custom font, this component will stop it from bleeding into GitHub components:
|
|
36
|
+
.github-component {
|
|
37
|
+
font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial,
|
|
38
|
+
sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol !important;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.min-height-full {
|
|
42
|
+
min-height: 100vh;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.img-contain {
|
|
46
|
+
object-fit: contain;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.img-cover {
|
|
50
|
+
object-fit: cover;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.Masthead .CircleBadge {
|
|
54
|
+
aspect-ratio: 1 / 1;
|
|
55
|
+
max-width: 296px;
|
|
56
|
+
position: relative;
|
|
57
|
+
overflow: hidden;
|
|
58
|
+
/* Hide any overflow to maintain circle shape */
|
|
59
|
+
margin: auto;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.CircleBadge img {
|
|
63
|
+
position: absolute !important;
|
|
64
|
+
height: 100% !important;
|
|
65
|
+
width: 100% !important;
|
|
66
|
+
object-fit: cover;
|
|
67
|
+
left: 0 !important;
|
|
68
|
+
top: 0 !important;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.image-container {
|
|
72
|
+
width: 100%;
|
|
73
|
+
/* Allow the container to adjust to the website's width */
|
|
74
|
+
// max-width: 800px; /* Set a maximum width to prevent image from exceeding 800px */
|
|
75
|
+
height: 0;
|
|
76
|
+
/* Create an aspect ratio container (initial height is 0) */
|
|
77
|
+
padding-bottom: 53.125%;
|
|
78
|
+
/* Aspect ratio (425 / 800) */
|
|
79
|
+
position: relative;
|
|
80
|
+
overflow: hidden;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
.image-container img {
|
|
84
|
+
position: absolute;
|
|
85
|
+
width: 100%;
|
|
86
|
+
/* Fill the entire container width */
|
|
87
|
+
height: 100%;
|
|
88
|
+
/* Fill the entire container height */
|
|
89
|
+
object-fit: cover;
|
|
90
|
+
/* Scale and crop the image to cover the container */
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
.image-container iframe {
|
|
94
|
+
position: absolute;
|
|
95
|
+
inset: 0;
|
|
96
|
+
width: 100%;
|
|
97
|
+
height: 100%;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
.post-tags::before {
|
|
101
|
+
content: "";
|
|
102
|
+
display: block;
|
|
103
|
+
height: 5px;
|
|
104
|
+
width: 20px;
|
|
105
|
+
background-color: var(--fgColor-default, var(--color-fg-default));
|
|
106
|
+
margin-bottom: 4px;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
.overflow-wrap-word {
|
|
110
|
+
overflow-wrap: break-word;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
.rounded-circle {
|
|
114
|
+
width: 100%;
|
|
115
|
+
/* Make the image fill the container */
|
|
116
|
+
height: 100%;
|
|
117
|
+
/* Make the image fill the container */
|
|
118
|
+
border-radius: 50%;
|
|
119
|
+
/* Make the div circular */
|
|
120
|
+
object-fit: cover;
|
|
121
|
+
/* Scale the image to fill the container */
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
.section-heading {
|
|
125
|
+
border-top: 5px solid var(--borderColor-default, var(--color-border-default));
|
|
126
|
+
border-bottom: 1px solid var(--borderColor-muted, var(--color-border-muted));
|
|
127
|
+
padding-top: 7px !important;
|
|
128
|
+
padding-bottom: 11px !important;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
.social-aside {
|
|
132
|
+
width: 44px;
|
|
133
|
+
height: 44px;
|
|
134
|
+
padding: 10px;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
.SelectMenu::before {
|
|
138
|
+
background-color: unset;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
.SelectMenu {
|
|
142
|
+
position: absolute;
|
|
143
|
+
top: unset;
|
|
144
|
+
bottom: unset;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
.AppHeader {
|
|
148
|
+
--AppHeader-bg: var(--bgColor-inset, var(--color-canvas-inset));
|
|
149
|
+
background: var(--AppHeader-bg);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
.AppHeader-button {
|
|
153
|
+
position: relative;
|
|
154
|
+
display: grid;
|
|
155
|
+
grid-auto-columns: max-content;
|
|
156
|
+
width: var(--base-size-32, 32px);
|
|
157
|
+
height: var(--base-size-32, 32px);
|
|
158
|
+
color: var(--color-fg-muted, var(--fgColor-muted));
|
|
159
|
+
background: transparent;
|
|
160
|
+
border: var(--borderWidth-thin, 1px) solid var(--borderColor-default);
|
|
161
|
+
border-radius: var(--borderRadius-medium, 6px);
|
|
162
|
+
align-items: center;
|
|
163
|
+
justify-content: center;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
.AppHeader-link {
|
|
167
|
+
color: var(--fgColor-default, var(--color-fg-default));
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
.version-selector__trigger {
|
|
171
|
+
color: var(--fgColor-default, var(--color-fg-default));
|
|
172
|
+
cursor: pointer;
|
|
173
|
+
text-decoration: none;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
.version-selector__trigger:hover {
|
|
177
|
+
text-decoration: none;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
.AppHeader .version-selector__trigger {
|
|
181
|
+
color: var(--fgColor-default, var(--color-fg-default));
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
.Header .version-selector__trigger {
|
|
185
|
+
color: var(--header-fgColor-default, var(--color-header-text));
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
.ActionListItem {
|
|
189
|
+
background-color: var(--control-transparent-bgColor-rest, #0000);
|
|
190
|
+
border-radius: var(--borderRadius-medium, 0.375rem);
|
|
191
|
+
list-style: none;
|
|
192
|
+
position: relative;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
.ActionListItem-label {
|
|
197
|
+
color: var(--fgColor-default, var(--color-fg-default));
|
|
198
|
+
font-size: var(--text-body-size-medium, 0.875rem);
|
|
199
|
+
font-weight: var(--base-text-weight-normal, 400);
|
|
200
|
+
grid-area: label;
|
|
201
|
+
line-height: var(--text-body-lineHeight-medium, 1.4285);
|
|
202
|
+
position: relative;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
.BlogHeader {
|
|
206
|
+
color: var(--header-fgColor-default, var(--color-header-text)) !important;
|
|
207
|
+
background-color: var(--header-bgColor, var(--color-header-bg)) !important;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
.Blog {
|
|
211
|
+
background-color: var(--bgColor-default, var(--color-canvas-default)) !important;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
.Header-link[aria-current]:not([aria-current=false]) {
|
|
215
|
+
color: var(--underlineNav-borderColor-active, var(--color-primer-border-active));
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
.awesome-nav-chevron {
|
|
219
|
+
transition: transform 0.2s ease;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
details[open]>summary .awesome-nav-chevron {
|
|
223
|
+
transform: rotate(180deg);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
.awesome-nav-menu-backdrop {
|
|
227
|
+
opacity: 0.6;
|
|
228
|
+
z-index: 100;
|
|
229
|
+
cursor: pointer;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
.awesome-nav-menu-drawer {
|
|
233
|
+
z-index: 100;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
.awesome-nav-menu-panel {
|
|
237
|
+
width: min(100vw, 22rem);
|
|
238
|
+
z-index: 110;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
summary::-webkit-details-marker {
|
|
242
|
+
display: none;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
@media print {
|
|
246
|
+
.BlogHeader {
|
|
247
|
+
background-color: inherit;
|
|
248
|
+
color: black !important;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
.AppHeader {
|
|
252
|
+
display: none !important;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
.Header {
|
|
256
|
+
display: none !important;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
.Toggle {
|
|
260
|
+
display: none !important;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
.Related {
|
|
264
|
+
display: none !important;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
.paginate-container {
|
|
268
|
+
display: none !important;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
.markdown-body {
|
|
272
|
+
font-size: 12px;
|
|
273
|
+
}
|
|
274
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
@use "sass:meta";
|
|
2
|
+
@import url("https://unpkg.com/@primer/css@21.5.1/dist/primer.css");
|
|
3
|
+
@import url("https://cdn.jsdelivr.net/npm/octicons-css/octicons.min.css");
|
|
4
|
+
@include meta.load-css("highlight-syntax");
|
|
5
|
+
@include meta.load-css("language-colors");
|
|
6
|
+
@include meta.load-css("admonitions");
|
|
7
|
+
@include meta.load-css("main");
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
---
|
|
2
|
+
---
|
|
3
|
+
{% assign jekyll_version=jekyll.version | split: "." | first %}
|
|
4
|
+
{% if jekyll_version == '3' %}
|
|
5
|
+
/* Jekyll version 3 detected */
|
|
6
|
+
@import 'jekyll-theme-primerpages-compat';
|
|
7
|
+
{% else %}
|
|
8
|
+
/* Jekyll version 4+ detected */
|
|
9
|
+
@use 'jekyll-theme-primerpages';
|
|
10
|
+
{% endif %}
|
|
11
|
+
|
|
12
|
+
:root{
|
|
13
|
+
--color-profile-text: var(--color-fg-default);
|
|
14
|
+
--color-profile-accent: var(--color-accent-fg);
|
|
15
|
+
--color-profile-bg: var(--color-canvas-default);
|
|
16
|
+
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
// Fix anchor links
|
|
2
|
+
document.addEventListener('DOMContentLoaded', function () {
|
|
3
|
+
// Function to handle anchor link click
|
|
4
|
+
function handleAnchorLinkClick(e) {
|
|
5
|
+
// Prevent the default behavior of the link (e.g., jumping to the anchor)
|
|
6
|
+
e.preventDefault();
|
|
7
|
+
|
|
8
|
+
// Get the target section's ID from the href attribute
|
|
9
|
+
var targetId = this.getAttribute('href').substring(1);
|
|
10
|
+
|
|
11
|
+
// Get the target section by ID
|
|
12
|
+
var targetSection = document.getElementById(targetId);
|
|
13
|
+
|
|
14
|
+
// If the target section exists, calculate the offset based on the top bar's height
|
|
15
|
+
if (targetSection) {
|
|
16
|
+
var topBarHeight = document.querySelector('.topbar').offsetHeight;
|
|
17
|
+
var offsetTop = targetSection.offsetTop - topBarHeight;
|
|
18
|
+
|
|
19
|
+
// Scroll to the target section with the calculated offset
|
|
20
|
+
window.scrollTo({
|
|
21
|
+
top: offsetTop,
|
|
22
|
+
behavior: 'smooth' // Optional: Add smooth scrolling effect
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// Function to recalculate topBarHeight on window resize
|
|
28
|
+
function handleWindowResize() {
|
|
29
|
+
topBarHeight = document.querySelector('.topbar').offsetHeight;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// Get all anchor links on the page
|
|
33
|
+
var anchorLinks = document.querySelectorAll('a[href^="#"]');
|
|
34
|
+
|
|
35
|
+
// Loop through each anchor link
|
|
36
|
+
anchorLinks.forEach(function (link) {
|
|
37
|
+
// Attach a click event listener to each anchor link
|
|
38
|
+
link.addEventListener('click', handleAnchorLinkClick);
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
// Add event listener for window resize, debounced for efficiency
|
|
42
|
+
var resizeTimer;
|
|
43
|
+
window.addEventListener('resize', function () {
|
|
44
|
+
clearTimeout(resizeTimer);
|
|
45
|
+
resizeTimer = setTimeout(handleWindowResize, 250);
|
|
46
|
+
});
|
|
47
|
+
});
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
document.addEventListener('DOMContentLoaded', async function () {
|
|
2
|
+
const htmlElement = document.documentElement;
|
|
3
|
+
|
|
4
|
+
function getResolvedMermaidTheme() {
|
|
5
|
+
const mode = htmlElement.getAttribute('data-color-mode');
|
|
6
|
+
|
|
7
|
+
if (mode === 'dark') return 'dark';
|
|
8
|
+
if (mode === 'light') return 'neutral';
|
|
9
|
+
|
|
10
|
+
return window.matchMedia('(prefers-color-scheme: dark)').matches
|
|
11
|
+
? 'dark'
|
|
12
|
+
: 'neutral';
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function prepareMermaidBlocks() {
|
|
16
|
+
document.querySelectorAll('pre > code.language-mermaid').forEach((code) => {
|
|
17
|
+
const source = code.textContent;
|
|
18
|
+
const container = document.createElement('div');
|
|
19
|
+
|
|
20
|
+
container.className = 'mermaid';
|
|
21
|
+
container.dataset.source = source;
|
|
22
|
+
container.textContent = source;
|
|
23
|
+
|
|
24
|
+
code.parentElement.replaceWith(container);
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
async function renderMermaid() {
|
|
29
|
+
mermaid.initialize({
|
|
30
|
+
startOnLoad: false,
|
|
31
|
+
theme: getResolvedMermaidTheme()
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
document.querySelectorAll('.mermaid').forEach((el) => {
|
|
35
|
+
el.removeAttribute('data-processed');
|
|
36
|
+
el.textContent = el.dataset.source;
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
await mermaid.run({
|
|
40
|
+
querySelector: '.mermaid'
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
prepareMermaidBlocks();
|
|
45
|
+
await renderMermaid();
|
|
46
|
+
|
|
47
|
+
const observer = new MutationObserver(renderMermaid);
|
|
48
|
+
|
|
49
|
+
observer.observe(htmlElement, {
|
|
50
|
+
attributes: true,
|
|
51
|
+
attributeFilter: ['data-color-mode']
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
window
|
|
55
|
+
.matchMedia('(prefers-color-scheme: dark)')
|
|
56
|
+
.addEventListener('change', function () {
|
|
57
|
+
if (htmlElement.getAttribute('data-color-mode') === 'auto') {
|
|
58
|
+
renderMermaid();
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
});
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
document.addEventListener('DOMContentLoaded', function () {
|
|
2
|
+
var themeToggle = document.getElementById('theme-toggle');
|
|
3
|
+
var themeIcon = document.getElementById('theme-icon');
|
|
4
|
+
var htmlElement = document.getElementsByTagName('html')[0];
|
|
5
|
+
|
|
6
|
+
function getCurrentMode() {
|
|
7
|
+
return htmlElement.getAttribute('data-color-mode');
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
function getModeFromCookie() {
|
|
11
|
+
var cookieValue = getCookie('colorMode');
|
|
12
|
+
if (cookieValue !== null && (cookieValue === 'auto' || cookieValue === 'dark' || cookieValue === 'light')) {
|
|
13
|
+
return cookieValue;
|
|
14
|
+
} else {
|
|
15
|
+
// Default to 'auto' mode if the cookie is not set or has an invalid value
|
|
16
|
+
return 'auto';
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function setCookie(name, value, days) {
|
|
21
|
+
var expires = "";
|
|
22
|
+
if (days) {
|
|
23
|
+
var date = new Date();
|
|
24
|
+
date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
|
|
25
|
+
expires = "; expires=" + date.toUTCString();
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// Updated cookie settings
|
|
29
|
+
document.cookie = name + "=" + (value || "") + expires + "; path=/; samesite=Strict; secure";
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function getCookie(name) {
|
|
33
|
+
var nameEQ = name + "=";
|
|
34
|
+
var ca = document.cookie.split(';');
|
|
35
|
+
for (var i = 0; i < ca.length; i++) {
|
|
36
|
+
var c = ca[i];
|
|
37
|
+
while (c.charAt(0) === ' ') c = c.substring(1, c.length);
|
|
38
|
+
if (c.indexOf(nameEQ) === 0) return c.substring(nameEQ.length, c.length);
|
|
39
|
+
}
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function getNextMode() {
|
|
44
|
+
var currentMode = getCurrentMode();
|
|
45
|
+
var nextMode;
|
|
46
|
+
if (currentMode === 'auto') {
|
|
47
|
+
nextMode = 'dark';
|
|
48
|
+
} else if (currentMode === 'dark') {
|
|
49
|
+
nextMode = 'light'
|
|
50
|
+
} else {
|
|
51
|
+
nextMode = 'auto'
|
|
52
|
+
}
|
|
53
|
+
return nextMode;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function updateTheme(nextMode) {
|
|
57
|
+
htmlElement.setAttribute('data-color-mode', nextMode);
|
|
58
|
+
updateThemeIcon(nextMode);
|
|
59
|
+
setCookie('colorMode', nextMode, 365); // Save the preference for 365 days
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function updateThemeIcon(nextMode) {
|
|
63
|
+
var nextIcon;
|
|
64
|
+
if (nextMode === 'dark') {
|
|
65
|
+
nextIcon = 'moon';
|
|
66
|
+
} else if (nextMode === 'light') {
|
|
67
|
+
nextIcon = 'sun'
|
|
68
|
+
} else {
|
|
69
|
+
nextIcon = 'zap';
|
|
70
|
+
}
|
|
71
|
+
// Set the span to the themeIcon class
|
|
72
|
+
themeIcon.classList = "octicon octicon-" + nextIcon + "-24";
|
|
73
|
+
themeToggle.setAttribute("aria-label", "Color mode: " + nextMode);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
themeToggle.addEventListener('click', function () {
|
|
77
|
+
updateTheme(getNextMode());
|
|
78
|
+
// updateThemeIcon(getNextMode());
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
// Initialize the theme icon based on the initial state
|
|
82
|
+
// updateThemeIcon(getModeFromCookie());
|
|
83
|
+
updateTheme(getModeFromCookie());
|
|
84
|
+
});
|
data/assets/js/topbar.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
document.addEventListener("DOMContentLoaded", function () {
|
|
2
|
+
function updateTopBarHeight() {
|
|
3
|
+
const topBar = document.querySelector('.topbar');
|
|
4
|
+
const topBarHeight = topBar ? topBar.offsetHeight : 0;
|
|
5
|
+
|
|
6
|
+
// 1. Set CSS variable for layout
|
|
7
|
+
document.documentElement.style.setProperty('--topbar-height', `${topBarHeight}px`);
|
|
8
|
+
|
|
9
|
+
// 2. Dispatch event for any JS-based listeners (timeline cards, etc)
|
|
10
|
+
document.dispatchEvent(new CustomEvent('topbarHeightUpdated', {
|
|
11
|
+
detail: { topBarHeight }
|
|
12
|
+
}));
|
|
13
|
+
|
|
14
|
+
console.log("[topbar.js] --topbar-height set to", topBarHeight);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
updateTopBarHeight();
|
|
18
|
+
window.addEventListener('resize', updateTopBarHeight);
|
|
19
|
+
});
|