methanol 0.0.18 → 0.0.20

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.
@@ -45,63 +45,78 @@ const toSignal = (i) => {
45
45
  return sig
46
46
  }
47
47
 
48
- const NavTree = ({ nodes, depth }) => (
49
- <For entries={nodes}>
50
- {({ item }) => {
51
- const node = read(item)
52
- const { routeHref: href, routePath, type, name, isRoot } = node
53
- const { title } = extract(item, 'title')
54
-
55
- const isActive = matchCurrentPath(routePath)
56
-
57
- if (type === 'directory') {
58
- const label = title.or(name)
59
- const { children } = extract(item, 'children')
60
-
61
- const isOpen = $(() => {
62
- if (depth < 1) {
63
- return true
64
- }
65
- const _active = isActive.value
66
- const _currentPath = currentPath.value
67
- return _active || _currentPath.startsWith(routePath)
68
- })
69
-
70
- const header = href ? (
71
- <a class={isActive.choose('nav-dir-link active', 'nav-dir-link')} href={href}>
72
- {label}
73
- </a>
74
- ) : (
75
- <span class="nav-dir-label">{label}</span>
76
- )
77
-
78
- return (
79
- <li class={isActive.choose('is-active', null)}>
80
- <details class="sidebar-collapsible" open={isOpen.choose(true, null)}>
81
- <summary class="sb-dir-header">{header}</summary>
82
- <If condition={() => children.value.length}>
83
- {() => (
84
- <ul data-depth={depth + 1}>
85
- <NavTree nodes={children} depth={depth + 1} />
86
- </ul>
87
- )}
88
- </If>
89
- </details>
90
- </li>
91
- )
92
- } else {
93
- const label = title.or(node.isIndex ? 'Home' : name)
94
- return (
95
- <li>
96
- <a class={isActive.choose('active', null)} href={href}>
48
+ const filterVisible = (items) => {
49
+ if (!Array.isArray(items)) return []
50
+ return items.filter(({ value: item }) => {
51
+ if (!item.hidden) {
52
+ return true
53
+ }
54
+
55
+ const _currentPath = currentPath.value
56
+ return _currentPath.startsWith(item.routePath)
57
+ })
58
+ }
59
+
60
+ const NavTree = ({ nodes, depth }) => {
61
+ const filtered = signal(nodes, filterVisible)
62
+ return (
63
+ <For entries={filtered}>
64
+ {({ item }) => {
65
+ const node = read(item)
66
+ const { routeHref: href, routePath, type, name, isRoot } = node
67
+ const { title } = extract(item, 'title')
68
+
69
+ const isActive = matchCurrentPath(routePath)
70
+
71
+ if (type === 'directory') {
72
+ const label = title.or(name)
73
+ const { children } = extract(item, 'children')
74
+
75
+ const isOpen = $(() => {
76
+ if (depth < 1) {
77
+ return true
78
+ }
79
+ const _active = isActive.value
80
+ const _currentPath = currentPath.value
81
+ return _active || _currentPath.startsWith(routePath)
82
+ })
83
+
84
+ const header = href ? (
85
+ <a class={isActive.choose('nav-dir-link active', 'nav-dir-link')} href={href}>
97
86
  {label}
98
87
  </a>
99
- </li>
100
- )
101
- }
102
- }}
103
- </For>
104
- )
88
+ ) : (
89
+ <span class="nav-dir-label">{label}</span>
90
+ )
91
+
92
+ return (
93
+ <li class={isActive.choose('is-active', null)}>
94
+ <details class="sidebar-collapsible" open={isOpen.choose(true, null)}>
95
+ <summary class="sb-dir-header">{header}</summary>
96
+ <If condition={() => children.value.length}>
97
+ {() => (
98
+ <ul data-depth={depth + 1}>
99
+ <NavTree nodes={children} depth={depth + 1} />
100
+ </ul>
101
+ )}
102
+ </If>
103
+ </details>
104
+ </li>
105
+ )
106
+ } else {
107
+ const label = title.or(node.isIndex ? 'Home' : name)
108
+ return (
109
+ <li>
110
+ <a class={isActive.choose('active', null)} href={href}>
111
+ {label}
112
+ </a>
113
+ </li>
114
+ )
115
+ }
116
+ }}
117
+ </For>
118
+ )
119
+ }
105
120
 
106
121
  const rootNodes = signal()
107
122
  const rootTree = HTMLRenderer.createElement(NavTree, { nodes: rootNodes, depth: 0 })
@@ -61,6 +61,10 @@ const PAGE_TEMPLATE = ({ PageContent, ExtraHead, components, ctx }) => {
61
61
  const htmlLang = typeof languageCode === 'string' && languageCode.trim() ? languageCode : 'en'
62
62
  const pagefindEnabled = ctx.site.pagefind?.enabled !== false
63
63
  const pagefindOptions = ctx.site.pagefind?.options || null
64
+ const feedInfo = ctx.site.feed
65
+ const rssHref = feedInfo?.enabled ? feedInfo.href : null
66
+ const feedType = feedInfo?.atom ? 'application/atom+xml' : 'application/rss+xml'
67
+ const feedLabel = feedInfo?.atom ? 'Atom' : 'RSS'
64
68
  const repoBase = ctx.site.repoBase
65
69
  const sourceUrl = pageFrontmatter.sourceURL
66
70
  const editUrl = sourceUrl || (repoBase && page.relativePath ? new URL(page.relativePath, repoBase).href : null)
@@ -108,6 +112,8 @@ const PAGE_TEMPLATE = ({ PageContent, ExtraHead, components, ctx }) => {
108
112
  <head>
109
113
  <meta charset="UTF-8" />
110
114
  <meta name="viewport" content="width=device-width" />
115
+ <meta name="theme-color" content="#ffffff" media="(prefers-color-scheme: light)" />
116
+ <meta name="theme-color" content="#09090b" media="(prefers-color-scheme: dark)" />
111
117
  <title>
112
118
  {title} | {siteName}
113
119
  </title>
@@ -122,6 +128,7 @@ const PAGE_TEMPLATE = ({ PageContent, ExtraHead, components, ctx }) => {
122
128
  {twitterTitle ? <meta name="twitter:title" content={twitterTitle} /> : null}
123
129
  {twitterDescription ? <meta name="twitter:description" content={twitterDescription} /> : null}
124
130
  {twitterImage ? <meta name="twitter:image" content={twitterImage} /> : null}
131
+ {rssHref ? <link rel="alternate" type={feedType} title={`${siteName} ${feedLabel}`} href={rssHref} /> : null}
125
132
  <link
126
133
  rel="preload stylesheet"
127
134
  as="style"
@@ -205,6 +212,24 @@ const PAGE_TEMPLATE = ({ PageContent, ExtraHead, components, ctx }) => {
205
212
  {languageSelector}
206
213
  <ThemeColorSwitch />
207
214
  <ThemeAccentSwitch />
215
+ {rssHref ? (
216
+ <a class="rss-link" href={rssHref} aria-label={feedLabel} title={feedLabel}>
217
+ <svg
218
+ width="18"
219
+ height="18"
220
+ viewBox="3 3 18 18"
221
+ fill="none"
222
+ stroke="currentColor"
223
+ stroke-width="2"
224
+ stroke-linecap="round"
225
+ stroke-linejoin="round"
226
+ >
227
+ <path d="M4 11a9 9 0 0 1 9 9"></path>
228
+ <path d="M4 4a16 16 0 0 1 16 16"></path>
229
+ <circle cx="5" cy="19" r="1"></circle>
230
+ </svg>
231
+ </a>
232
+ ) : null}
208
233
  </div>
209
234
  </aside>
210
235
  <main class="main-content" data-pagefind-body={pagefindEnabled ? '' : null}>