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 CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Opinionated MDX-first static site generator powered by rEFui + Vite.
4
4
 
5
- For full documentation and examples, see the `methanol-docs` project.
5
+ For full documentation and examples, visit [Methanol Docs](https://methanol.netlify.app/).
6
6
 
7
7
  ## Quick start
8
8
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "methanol",
3
- "version": "0.0.3",
3
+ "version": "0.0.5",
4
4
  "description": "Static site generator powered by rEFui and MDX",
5
5
  "main": "./index.js",
6
6
  "type": "module",
@@ -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,
@@ -29,7 +29,7 @@ export const runVitePreview = async () => {
29
29
  const baseConfig = {
30
30
  configFile: false,
31
31
  root: state.PAGES_DIR,
32
- base: './',
32
+ base: '/',
33
33
  build: {
34
34
  outDir: state.DIST_DIR
35
35
  }
@@ -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.map(link => {
41
- const href = link.getAttribute('href')
42
- if (!href || !href.startsWith('#')) return null
43
- return document.getElementById(href.slice(1))
44
- }).filter(Boolean)
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 < (scrollY + windowHeight - threshold) && sectionEnd > scrollY
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 class="toc-indicator" style:top={t`${top}px`} style:height={t`${height}px`} style:opacity={t`${opacity}`}></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
- <h4>On this page</h4>
156
+ <div class="toc-heading">On this page</div>
150
157
  <ul>{...children}</ul>
151
158
  </div>
152
159
  </aside>
@@ -53,7 +53,7 @@ export default function (props, ...children) {
53
53
  return (
54
54
  <aside class="toc-panel">
55
55
  <div class="toc">
56
- <h4>On this page</h4>
56
+ <div class="toc-heading">On this page</div>
57
57
  <ul>{...children}</ul>
58
58
  </div>
59
59
  </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-hidden />}
24
+ {props.id && <a class="heading-anchor" href={`#${props.id}`} aria-label={`Link to ${props.id}`}/>}
25
25
  {...children}
26
26
  </Tag>
27
27
  )
@@ -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 ?? null
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
- {excerpt ? <meta name="description" content={excerpt} /> : null}
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
- ) : <div class="page-nav-spacer"></div>}
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
- Updated: {page.updatedAt || '-'}
288
- </div>
289
- <div class="page-meta-item">
290
- Powered by <a href="https://github.com/SudoMaker/Methanol" target="_blank" rel="noopener noreferrer" class="methanol-link">Methanol</a>
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}
@@ -1105,7 +1105,7 @@ a {
1105
1105
  }
1106
1106
 
1107
1107
  .toc {
1108
- h4 {
1108
+ .toc-heading {
1109
1109
  margin: 0 0 1rem 0.5rem;
1110
1110
  font-size: 0.8rem;
1111
1111
  font-weight: 600;