@zeropress/build-pages 0.6.3 → 0.6.4
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.
- package/README.md +41 -9
- package/action.yml +1 -1
- package/dist/action.js +62 -16
- package/dist/prebuild.js +215 -21
- package/package.json +2 -2
- package/schemas/zeropress-build-pages.config.v0.1.schema.json +67 -0
- package/src/index.js +71 -13
- package/src/prebuild.js +244 -22
- package/themes/docs/assets/style.css +6 -7
- package/themes/docs/assets/theme.js +37 -17
- package/themes/docs/layout.html +2 -2
- package/themes/docs/page.html +4 -0
- package/themes/docs/post.html +37 -10
- package/themes/docs/theme.json +1 -0
|
@@ -1,20 +1,3 @@
|
|
|
1
|
-
/* ---------- Sticky header scrolled state ---------- */
|
|
2
|
-
|
|
3
|
-
const siteHeader = document.querySelector('.site-header');
|
|
4
|
-
|
|
5
|
-
if (siteHeader) {
|
|
6
|
-
let lastScrolled = false;
|
|
7
|
-
const updateHeader = () => {
|
|
8
|
-
const scrolled = window.scrollY > 4;
|
|
9
|
-
if (scrolled !== lastScrolled) {
|
|
10
|
-
siteHeader.classList.toggle('is-scrolled', scrolled);
|
|
11
|
-
lastScrolled = scrolled;
|
|
12
|
-
}
|
|
13
|
-
};
|
|
14
|
-
updateHeader();
|
|
15
|
-
window.addEventListener('scroll', updateHeader, { passive: true });
|
|
16
|
-
}
|
|
17
|
-
|
|
18
1
|
/* ---------- Mobile nav toggle ---------- */
|
|
19
2
|
|
|
20
3
|
const navToggle = document.querySelector('[data-nav-toggle]');
|
|
@@ -51,6 +34,7 @@ const themeToggle = document.querySelector('[data-theme-toggle]');
|
|
|
51
34
|
|
|
52
35
|
if (themeToggle) {
|
|
53
36
|
const root = document.documentElement;
|
|
37
|
+
themeToggle.disabled = false;
|
|
54
38
|
|
|
55
39
|
const getResolvedTheme = () => {
|
|
56
40
|
const stored = root.dataset.theme;
|
|
@@ -100,6 +84,42 @@ if (primaryLinks.length) {
|
|
|
100
84
|
|
|
101
85
|
/* ---------- Table of contents scroll spy ---------- */
|
|
102
86
|
|
|
87
|
+
document.querySelectorAll('[data-enhance-toc]').forEach((toc) => {
|
|
88
|
+
const layout = toc.closest('.doc-layout');
|
|
89
|
+
const prose = layout?.querySelector('.prose');
|
|
90
|
+
if (!layout || !prose) return;
|
|
91
|
+
|
|
92
|
+
const headings = Array.from(prose.querySelectorAll('h2[id], h3[id], h4[id]'))
|
|
93
|
+
.filter((heading) => heading.id && heading.textContent.trim());
|
|
94
|
+
if (!headings.length) return;
|
|
95
|
+
|
|
96
|
+
const title = document.createElement('p');
|
|
97
|
+
title.className = 'doc-toc__title';
|
|
98
|
+
title.textContent = 'On this page';
|
|
99
|
+
|
|
100
|
+
const nav = document.createElement('nav');
|
|
101
|
+
const list = document.createElement('ol');
|
|
102
|
+
|
|
103
|
+
for (const heading of headings) {
|
|
104
|
+
const level = Number(heading.tagName.slice(1)) || 2;
|
|
105
|
+
const item = document.createElement('li');
|
|
106
|
+
const link = document.createElement('a');
|
|
107
|
+
|
|
108
|
+
item.className = `doc-toc__item doc-toc__item--level-${level}`;
|
|
109
|
+
link.href = `#${encodeURIComponent(heading.id)}`;
|
|
110
|
+
link.dataset.docTocLink = '';
|
|
111
|
+
link.textContent = heading.textContent.trim();
|
|
112
|
+
|
|
113
|
+
item.append(link);
|
|
114
|
+
list.append(item);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
nav.append(list);
|
|
118
|
+
toc.replaceChildren(title, nav);
|
|
119
|
+
toc.hidden = false;
|
|
120
|
+
layout.classList.add('doc-layout--with-toc');
|
|
121
|
+
});
|
|
122
|
+
|
|
103
123
|
const tocLinks = Array.from(document.querySelectorAll('[data-doc-toc-link]'));
|
|
104
124
|
|
|
105
125
|
if (tocLinks.length) {
|
package/themes/docs/layout.html
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
<!doctype html>
|
|
1
2
|
<html lang="{{site.locale}}">
|
|
2
3
|
<head>
|
|
3
4
|
<meta charset="utf-8">
|
|
@@ -22,7 +23,6 @@
|
|
|
22
23
|
class="brand__mark"
|
|
23
24
|
src="{{site.logo.src}}"
|
|
24
25
|
alt="{{#if site.logo.alt}}{{site.logo.alt}}{{#else}}{{site.title}}{{/if}}"
|
|
25
|
-
aria-hidden="true"
|
|
26
26
|
>
|
|
27
27
|
{{/if}}
|
|
28
28
|
<span class="brand__name">{{site.title}}</span>
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
</div>
|
|
60
60
|
</div>
|
|
61
61
|
{{/if}}
|
|
62
|
-
<button class="theme-toggle" type="button" aria-label="Toggle color theme" data-theme-toggle title="Toggle theme">
|
|
62
|
+
<button class="theme-toggle" type="button" aria-label="Toggle color theme" data-theme-toggle title="Toggle theme" disabled>
|
|
63
63
|
<svg class="theme-toggle__icon theme-toggle__icon--sun" viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
|
|
64
64
|
<circle cx="12" cy="12" r="4"></circle>
|
|
65
65
|
<path d="M12 2v2M12 20v2M4.93 4.93l1.41 1.41M17.66 17.66l1.41 1.41M2 12h2M20 12h2M4.93 19.07l1.41-1.41M17.66 6.34l1.41-1.41"></path>
|
package/themes/docs/page.html
CHANGED
package/themes/docs/post.html
CHANGED
|
@@ -1,12 +1,39 @@
|
|
|
1
|
-
<article class="shell doc-
|
|
2
|
-
<
|
|
3
|
-
<
|
|
4
|
-
<
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
{{post.
|
|
1
|
+
<article class="shell doc-layout{{#if post.toc}} doc-layout--with-toc{{/if}}">
|
|
2
|
+
<div class="doc-content">
|
|
3
|
+
<header class="doc-header">
|
|
4
|
+
<p class="eyebrow">
|
|
5
|
+
<span class="eyebrow__dot" aria-hidden="true"></span>
|
|
6
|
+
Post
|
|
7
|
+
</p>
|
|
8
|
+
<h1>{{post.title}}</h1>
|
|
9
|
+
</header>
|
|
10
|
+
<div class="prose" {{#if site.search}}{{#if_neq post.discoverability "delist"}}data-pagefind-body{{/if_neq}}{{/if}}>
|
|
11
|
+
{{post.html}}
|
|
12
|
+
</div>
|
|
13
|
+
{{#if post.meta.source_markdown_url}}
|
|
14
|
+
<footer class="doc-source">
|
|
15
|
+
<a href="{{post.meta.source_markdown_url}}">
|
|
16
|
+
<svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
|
|
17
|
+
<path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"></path>
|
|
18
|
+
<polyline points="14 2 14 8 20 8"></polyline>
|
|
19
|
+
</svg>
|
|
20
|
+
View this post as Markdown
|
|
21
|
+
</a>
|
|
22
|
+
</footer>
|
|
23
|
+
{{/if}}
|
|
11
24
|
</div>
|
|
25
|
+
{{#if post.toc}}
|
|
26
|
+
<aside class="doc-toc" aria-label="Table of contents">
|
|
27
|
+
<p class="doc-toc__title">On this page</p>
|
|
28
|
+
<nav>
|
|
29
|
+
<ol>
|
|
30
|
+
{{#for item in post.toc}}<li class="doc-toc__item doc-toc__item--level-{{item.level}}"><a href="{{item.href}}" data-doc-toc-link>{{item.title}}</a></li>{{/for}}
|
|
31
|
+
</ol>
|
|
32
|
+
</nav>
|
|
33
|
+
</aside>
|
|
34
|
+
{{#else}}
|
|
35
|
+
{{#if_eq post.document_type "html"}}
|
|
36
|
+
<aside class="doc-toc" aria-label="Table of contents" data-enhance-toc hidden></aside>
|
|
37
|
+
{{/if_eq}}
|
|
38
|
+
{{/if}}
|
|
12
39
|
</article>
|