@edoxen/browser 0.1.2 → 0.1.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/package.json
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
---
|
|
2
2
|
import type { EdoxenConfig } from '../../config/index.js'
|
|
3
3
|
import { generateCssTokens } from '../../config/index.js'
|
|
4
|
-
import
|
|
4
|
+
// Side-effect import: bundles styles/base.css through Astro/Vite's CSS
|
|
5
|
+
// pipeline and inlines the result on every page that uses BaseLayout.
|
|
6
|
+
import '../../../styles/base.css'
|
|
5
7
|
|
|
6
8
|
interface Props {
|
|
7
9
|
config: EdoxenConfig
|
|
@@ -14,7 +16,6 @@ const { config, title, description, lang = config.site.locale } = Astro.props
|
|
|
14
16
|
const pageTitle = title ?? config.site.title
|
|
15
17
|
const pageDescription = description ?? config.site.description
|
|
16
18
|
const tokens = generateCssTokens(config.theme)
|
|
17
|
-
const globalCss = `${baseCss}\n${tokens}`
|
|
18
19
|
const canonical = new URL(Astro.url.pathname, config.site.url).toString()
|
|
19
20
|
---
|
|
20
21
|
|
|
@@ -35,7 +36,8 @@ const canonical = new URL(Astro.url.pathname, config.site.url).toString()
|
|
|
35
36
|
<meta name="twitter:card" content="summary" />
|
|
36
37
|
<meta name="twitter:title" content={pageTitle} />
|
|
37
38
|
<meta name="twitter:description" content={pageDescription} />
|
|
38
|
-
|
|
39
|
+
|
|
40
|
+
<style is:global set:html={tokens} />
|
|
39
41
|
<slot name="head" />
|
|
40
42
|
</head>
|
|
41
43
|
<body>
|
|
@@ -15,7 +15,7 @@ interface FetchResponse {
|
|
|
15
15
|
facetYears?: number[]
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
function
|
|
18
|
+
function buildListItem(item: SearchableItem, basePath: string): HTMLLIElement {
|
|
19
19
|
const li = document.createElement('li')
|
|
20
20
|
li.className = 'edoxen-search-filter__result'
|
|
21
21
|
const link = document.createElement('a')
|
|
@@ -28,7 +28,7 @@ function appendListItem(list: ParentNode, item: SearchableItem, basePath: string
|
|
|
28
28
|
badge.textContent = item.bodyType
|
|
29
29
|
li.appendChild(badge)
|
|
30
30
|
}
|
|
31
|
-
|
|
31
|
+
return li
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
function makeFacetChip(label: string, count: number, active: boolean, onToggle: () => void): HTMLElement {
|
|
@@ -73,7 +73,6 @@ class SearchFilter extends HTMLElement {
|
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
private renderShell(): void {
|
|
76
|
-
this.innerHTML = ''
|
|
77
76
|
const form = document.createElement('form')
|
|
78
77
|
form.className = 'edoxen-search-filter__form'
|
|
79
78
|
form.setAttribute('role', 'search')
|
|
@@ -100,7 +99,7 @@ class SearchFilter extends HTMLElement {
|
|
|
100
99
|
results.setAttribute('data-role', 'results')
|
|
101
100
|
form.appendChild(results)
|
|
102
101
|
|
|
103
|
-
this.
|
|
102
|
+
this.replaceChildren(form)
|
|
104
103
|
}
|
|
105
104
|
|
|
106
105
|
private render(): void {
|
|
@@ -108,7 +107,7 @@ class SearchFilter extends HTMLElement {
|
|
|
108
107
|
const resultsEl = this.querySelector('[data-role="results"]')
|
|
109
108
|
if (!facetsEl || !resultsEl) return
|
|
110
109
|
|
|
111
|
-
facetsEl.
|
|
110
|
+
facetsEl.replaceChildren()
|
|
112
111
|
const bodies = new Set<string>()
|
|
113
112
|
const kinds = new Set<string>()
|
|
114
113
|
const years = new Set<number>()
|
|
@@ -135,16 +134,16 @@ class SearchFilter extends HTMLElement {
|
|
|
135
134
|
facetsEl.appendChild(chip)
|
|
136
135
|
}
|
|
137
136
|
|
|
138
|
-
resultsEl.
|
|
137
|
+
resultsEl.replaceChildren()
|
|
139
138
|
const matches = filterItems(this.items, this.state)
|
|
140
139
|
if (matches.length === 0) {
|
|
141
140
|
const empty = document.createElement('li')
|
|
142
141
|
empty.className = 'edoxen-empty'
|
|
143
142
|
empty.textContent = 'No matches.'
|
|
144
|
-
resultsEl.
|
|
143
|
+
resultsEl.replaceChildren(empty)
|
|
145
144
|
return
|
|
146
145
|
}
|
|
147
|
-
|
|
146
|
+
resultsEl.replaceChildren(...matches.map((item) => buildListItem(item, this.basePath)))
|
|
148
147
|
}
|
|
149
148
|
|
|
150
149
|
private syncHash(): void {
|
|
@@ -155,11 +154,10 @@ class SearchFilter extends HTMLElement {
|
|
|
155
154
|
}
|
|
156
155
|
|
|
157
156
|
private renderError(message: string): void {
|
|
158
|
-
this.innerHTML = ''
|
|
159
157
|
const p = document.createElement('p')
|
|
160
158
|
p.className = 'edoxen-search-filter__error'
|
|
161
159
|
p.textContent = message
|
|
162
|
-
this.
|
|
160
|
+
this.replaceChildren(p)
|
|
163
161
|
}
|
|
164
162
|
}
|
|
165
163
|
|