methanol 0.0.3 → 0.0.5
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 +1 -1
- package/package.json +1 -1
- package/src/build-system.js +1 -1
- package/src/preview-server.js +1 -1
- package/themes/default/components/ThemeToCContainer.client.jsx +22 -15
- package/themes/default/components/ThemeToCContainer.static.jsx +1 -1
- package/themes/default/heading.jsx +1 -1
- package/themes/default/page.jsx +18 -15
- package/themes/default/sources/style.css +1 -1
package/README.md
CHANGED
package/package.json
CHANGED
package/src/build-system.js
CHANGED
|
@@ -174,7 +174,7 @@ export const runViteBuild = async (entry, htmlCache) => {
|
|
|
174
174
|
const baseConfig = {
|
|
175
175
|
configFile: false,
|
|
176
176
|
root: state.PAGES_DIR,
|
|
177
|
-
base: '
|
|
177
|
+
base: '/',
|
|
178
178
|
publicDir: state.STATIC_DIR === false ? false : state.STATIC_DIR,
|
|
179
179
|
build: {
|
|
180
180
|
outDir: state.DIST_DIR,
|
package/src/preview-server.js
CHANGED
|
@@ -29,19 +29,21 @@ export default function (props, ...children) {
|
|
|
29
29
|
const top = signal(0)
|
|
30
30
|
const height = signal(0)
|
|
31
31
|
const opacity = signal(0)
|
|
32
|
-
|
|
32
|
+
|
|
33
33
|
const updateActive = () => {
|
|
34
34
|
if (!el.value) return
|
|
35
|
-
|
|
35
|
+
|
|
36
36
|
const links = Array.from(el.value.querySelectorAll('a'))
|
|
37
37
|
if (!links.length) return
|
|
38
38
|
|
|
39
39
|
// Map links to their corresponding content anchors
|
|
40
|
-
const anchors = links
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
40
|
+
const anchors = links
|
|
41
|
+
.map((link) => {
|
|
42
|
+
const href = link.getAttribute('href')
|
|
43
|
+
if (!href || !href.startsWith('#')) return null
|
|
44
|
+
return document.getElementById(href.slice(1))
|
|
45
|
+
})
|
|
46
|
+
.filter(Boolean)
|
|
45
47
|
|
|
46
48
|
if (!anchors.length) return
|
|
47
49
|
|
|
@@ -56,13 +58,13 @@ export default function (props, ...children) {
|
|
|
56
58
|
for (let i = 0; i < anchors.length; i++) {
|
|
57
59
|
const anchor = anchors[i]
|
|
58
60
|
const nextAnchor = anchors[i + 1]
|
|
59
|
-
|
|
61
|
+
|
|
60
62
|
const sectionStart = anchor.offsetTop - threshold
|
|
61
63
|
const sectionEnd = nextAnchor ? nextAnchor.offsetTop - threshold : document.body.offsetHeight
|
|
62
64
|
|
|
63
65
|
// A section is visible if its range overlaps with the viewport [scrollY, scrollY + windowHeight]
|
|
64
|
-
const isVisible = sectionStart <
|
|
65
|
-
|
|
66
|
+
const isVisible = sectionStart < scrollY + windowHeight - threshold && sectionEnd > scrollY
|
|
67
|
+
|
|
66
68
|
if (isVisible) {
|
|
67
69
|
visibleAnchors.add(anchor)
|
|
68
70
|
}
|
|
@@ -77,10 +79,10 @@ export default function (props, ...children) {
|
|
|
77
79
|
let firstActiveLink = null
|
|
78
80
|
let lastActiveLink = null
|
|
79
81
|
|
|
80
|
-
links.forEach(l => {
|
|
82
|
+
links.forEach((l) => {
|
|
81
83
|
const href = l.getAttribute('href')
|
|
82
84
|
const anchorId = href ? href.slice(1) : null
|
|
83
|
-
const anchor = anchors.find(a => a.id === anchorId)
|
|
85
|
+
const anchor = anchors.find((a) => a.id === anchorId)
|
|
84
86
|
if (visibleAnchors.has(anchor)) {
|
|
85
87
|
l.classList.add('active')
|
|
86
88
|
if (!firstActiveLink) firstActiveLink = l
|
|
@@ -130,7 +132,7 @@ export default function (props, ...children) {
|
|
|
130
132
|
ticking = true
|
|
131
133
|
}
|
|
132
134
|
}
|
|
133
|
-
|
|
135
|
+
|
|
134
136
|
// Wait for mount/layout
|
|
135
137
|
useEffect(() => {
|
|
136
138
|
updateActive()
|
|
@@ -144,9 +146,14 @@ export default function (props, ...children) {
|
|
|
144
146
|
|
|
145
147
|
return (
|
|
146
148
|
<aside class="toc-panel" $ref={el}>
|
|
147
|
-
<div
|
|
149
|
+
<div
|
|
150
|
+
class="toc-indicator"
|
|
151
|
+
style:top={t`${top}px`}
|
|
152
|
+
style:height={t`${height}px`}
|
|
153
|
+
style:opacity={t`${opacity}`}
|
|
154
|
+
></div>
|
|
148
155
|
<div class="toc">
|
|
149
|
-
<
|
|
156
|
+
<div class="toc-heading">On this page</div>
|
|
150
157
|
<ul>{...children}</ul>
|
|
151
158
|
</div>
|
|
152
159
|
</aside>
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
export function heading(Tag) {
|
|
22
22
|
return (props, ...children) => (
|
|
23
23
|
<Tag {...props}>
|
|
24
|
-
{props.id && <a class="heading-anchor" href={`#${props.id}`} aria-
|
|
24
|
+
{props.id && <a class="heading-anchor" href={`#${props.id}`} aria-label={`Link to ${props.id}`}/>}
|
|
25
25
|
{...children}
|
|
26
26
|
</Tag>
|
|
27
27
|
)
|
package/themes/default/page.jsx
CHANGED
|
@@ -86,7 +86,7 @@ const PAGE_TEMPLATE = ({ Page, ExtraHead, components, ctx }) => {
|
|
|
86
86
|
const themeFavIcon = '/favicon.png'
|
|
87
87
|
const logo = pageFrontmatter.logo ?? rootFrontmatter.logo ?? ctx.site?.logo ?? themeLogo
|
|
88
88
|
const favicon = pageFrontmatter.favicon ?? rootFrontmatter.favicon ?? ctx.site?.favicon ?? themeFavIcon
|
|
89
|
-
const excerpt = pageFrontmatter.excerpt ??
|
|
89
|
+
const excerpt = pageFrontmatter.excerpt ?? `${title} | ${siteName} - Powered by Methanol`
|
|
90
90
|
const ogTitle = pageFrontmatter.ogTitle ?? null
|
|
91
91
|
const ogDescription = pageFrontmatter.ogDescription ?? null
|
|
92
92
|
const ogImage = pageFrontmatter.ogImage ?? null
|
|
@@ -100,8 +100,7 @@ const PAGE_TEMPLATE = ({ Page, ExtraHead, components, ctx }) => {
|
|
|
100
100
|
const nextPage = siblings?.next || null
|
|
101
101
|
const languages = Array.isArray(ctx.languages) ? ctx.languages : []
|
|
102
102
|
const currentLanguageHref = ctx.language?.href || ctx.language?.routePath || null
|
|
103
|
-
const languageCode =
|
|
104
|
-
pageFrontmatter.langCode ?? rootFrontmatter.langCode ?? ctx.language?.code ?? 'en'
|
|
103
|
+
const languageCode = pageFrontmatter.langCode ?? rootFrontmatter.langCode ?? ctx.language?.code ?? 'en'
|
|
105
104
|
const htmlLang = typeof languageCode === 'string' && languageCode.trim() ? languageCode : 'en'
|
|
106
105
|
const pagefindEnabled = ctx.site?.pagefind?.enabled !== false
|
|
107
106
|
const pagefindOptions = ctx.site?.pagefind?.options || null
|
|
@@ -153,7 +152,7 @@ const PAGE_TEMPLATE = ({ Page, ExtraHead, components, ctx }) => {
|
|
|
153
152
|
</title>
|
|
154
153
|
{baseHref ? <base href={baseHref} /> : null}
|
|
155
154
|
<link rel="icon" href={favicon} />
|
|
156
|
-
|
|
155
|
+
<meta name="description" content={excerpt} />
|
|
157
156
|
{ogTitle ? <meta property="og:title" content={ogTitle} /> : null}
|
|
158
157
|
{ogDescription ? <meta property="og:description" content={ogDescription} /> : null}
|
|
159
158
|
{ogImage ? <meta property="og:image" content={ogImage} /> : null}
|
|
@@ -201,11 +200,7 @@ const PAGE_TEMPLATE = ({ Page, ExtraHead, components, ctx }) => {
|
|
|
201
200
|
</svg>
|
|
202
201
|
</label>
|
|
203
202
|
{pagefindEnabled ? (
|
|
204
|
-
<button
|
|
205
|
-
class="search-toggle-label"
|
|
206
|
-
aria-label="Open search"
|
|
207
|
-
onclick="window.__methanolSearchOpen()"
|
|
208
|
-
>
|
|
203
|
+
<button class="search-toggle-label" aria-label="Open search" onclick="window.__methanolSearchOpen()">
|
|
209
204
|
<svg
|
|
210
205
|
width="24"
|
|
211
206
|
height="24"
|
|
@@ -249,7 +244,7 @@ const PAGE_TEMPLATE = ({ Page, ExtraHead, components, ctx }) => {
|
|
|
249
244
|
<aside class="sidebar">
|
|
250
245
|
<div class="sidebar-header">
|
|
251
246
|
<div class="logo">
|
|
252
|
-
<img src={logo} />
|
|
247
|
+
<img src={logo} alt="logo" fetchpriority="high"/>
|
|
253
248
|
<span>{siteName}</span>
|
|
254
249
|
</div>
|
|
255
250
|
{pagefindEnabled ? <ThemeSearchBox options={pagefindOptions} /> : null}
|
|
@@ -272,7 +267,9 @@ const PAGE_TEMPLATE = ({ Page, ExtraHead, components, ctx }) => {
|
|
|
272
267
|
<span class="page-nav-label">Previous</span>
|
|
273
268
|
<span class="page-nav-title">{prevPage.title || prevPage.routePath}</span>
|
|
274
269
|
</a>
|
|
275
|
-
) :
|
|
270
|
+
) : (
|
|
271
|
+
<div class="page-nav-spacer"></div>
|
|
272
|
+
)}
|
|
276
273
|
{nextPage ? (
|
|
277
274
|
<a class="page-nav-card next" href={nextPage.routeHref || nextPage.routePath}>
|
|
278
275
|
<span class="page-nav-label">Next</span>
|
|
@@ -283,11 +280,17 @@ const PAGE_TEMPLATE = ({ Page, ExtraHead, components, ctx }) => {
|
|
|
283
280
|
) : null}
|
|
284
281
|
{page ? (
|
|
285
282
|
<footer class="page-meta">
|
|
283
|
+
<div class="page-meta-item">Updated: {page.updatedAt || '-'}</div>
|
|
286
284
|
<div class="page-meta-item">
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
285
|
+
Powered by{' '}
|
|
286
|
+
<a
|
|
287
|
+
href="https://github.com/SudoMaker/Methanol"
|
|
288
|
+
target="_blank"
|
|
289
|
+
rel="noopener noreferrer"
|
|
290
|
+
class="methanol-link"
|
|
291
|
+
>
|
|
292
|
+
Methanol
|
|
293
|
+
</a>
|
|
291
294
|
</div>
|
|
292
295
|
</footer>
|
|
293
296
|
) : null}
|