@glossarist/concept-browser 0.4.2 → 0.4.3
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 +23 -0
- package/cli/index.mjs +53 -6
- package/index.html +0 -1
- package/package.json +2 -1
- package/vite.config.ts +22 -1
package/README.md
CHANGED
|
@@ -101,6 +101,29 @@ Replace `IEV` with the uppercase dataset ID.
|
|
|
101
101
|
|
|
102
102
|
All dataset configuration lives in a single file. Adding a new dataset requires **zero code changes** — just add an entry to `datasets.yml` and run the pipeline.
|
|
103
103
|
|
|
104
|
+
### Branding and favicon
|
|
105
|
+
|
|
106
|
+
The `site-config.yml` `branding` section controls the site's visual identity:
|
|
107
|
+
|
|
108
|
+
```yaml
|
|
109
|
+
branding:
|
|
110
|
+
primaryColor: "#d97706"
|
|
111
|
+
darkColor: "#1a1a2e"
|
|
112
|
+
logo:
|
|
113
|
+
path: /logos/my-logo.svg # URL path served to browsers
|
|
114
|
+
alt: "My Org"
|
|
115
|
+
localPath: logos/my-logo.svg # Local file used as favicon source
|
|
116
|
+
favicon: logos/my-favicon.svg # Optional — overrides logo.localPath for favicon generation
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
During build, favicons are auto-generated from a single SVG source using the [`favicons`](https://npmjs.com/package/favicons) package. The resolution order is:
|
|
120
|
+
|
|
121
|
+
1. `branding.favicon` — explicit path to favicon source SVG
|
|
122
|
+
2. `branding.logo.localPath` — falls back to the site logo
|
|
123
|
+
3. Package default `public/favicon.svg`
|
|
124
|
+
|
|
125
|
+
The build produces: `favicon.ico`, `favicon.svg`, `favicon-{16,32,48}x{16,32,48}.png`, `apple-touch-icon-*.png` (all standard iOS sizes), and injects the corresponding `<link>` and `<meta>` tags into `index.html` via a Vite plugin.
|
|
126
|
+
|
|
104
127
|
### Full reference
|
|
105
128
|
|
|
106
129
|
```yaml
|
package/cli/index.mjs
CHANGED
|
@@ -78,7 +78,7 @@ Environment:
|
|
|
78
78
|
if (!process.env.SITE_CONFIG && !process.env.SITE_ID && named.site) {
|
|
79
79
|
process.env.SITE_ID = named.site;
|
|
80
80
|
}
|
|
81
|
-
loadSiteConfig(named.site ? [named.site] : []);
|
|
81
|
+
const { config } = loadSiteConfig(named.site ? [named.site] : []);
|
|
82
82
|
|
|
83
83
|
if (cmd === 'build' || cmd === 'site') {
|
|
84
84
|
for (const step of ['fetch', 'generate', 'edges']) {
|
|
@@ -86,15 +86,62 @@ Environment:
|
|
|
86
86
|
await commands[step]();
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
-
//
|
|
89
|
+
// Generate favicons from site logo
|
|
90
90
|
const fs = await import('fs');
|
|
91
91
|
const publicDir = resolve(process.cwd(), 'public');
|
|
92
92
|
fs.mkdirSync(publicDir, { recursive: true });
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
93
|
+
|
|
94
|
+
const branding = config?.branding || {};
|
|
95
|
+
const faviconSrc =
|
|
96
|
+
(branding.favicon && resolve(process.cwd(), branding.favicon)) ||
|
|
97
|
+
(branding.logo?.localPath && resolve(process.cwd(), branding.logo.localPath)) ||
|
|
98
|
+
resolve(pkgRoot, 'public', 'favicon.svg');
|
|
99
|
+
|
|
100
|
+
let faviconHtml = '';
|
|
101
|
+
if (fs.existsSync(faviconSrc)) {
|
|
102
|
+
console.log(`\n=== FAVICONS ===\n`);
|
|
103
|
+
const favicons = (await import('favicons')).default;
|
|
104
|
+
const source = fs.readFileSync(faviconSrc);
|
|
105
|
+
const response = await favicons(source, {
|
|
106
|
+
appName: config?.title || 'Glossarist',
|
|
107
|
+
background: branding.primaryColor || '#2563eb',
|
|
108
|
+
theme_color: branding.primaryColor || '#2563eb',
|
|
109
|
+
icons: {
|
|
110
|
+
android: false,
|
|
111
|
+
appleIcon: true,
|
|
112
|
+
appleStartup: false,
|
|
113
|
+
favicons: true,
|
|
114
|
+
windows: false,
|
|
115
|
+
yandex: false,
|
|
116
|
+
},
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
// Write all generated images and files to public/
|
|
120
|
+
for (const img of response.images) {
|
|
121
|
+
fs.writeFileSync(resolve(publicDir, img.name), img.contents);
|
|
122
|
+
}
|
|
123
|
+
for (const file of response.files) {
|
|
124
|
+
fs.writeFileSync(resolve(publicDir, file.name), file.contents);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// Keep the original SVG for dark mode support
|
|
128
|
+
if (faviconSrc.endsWith('.svg')) {
|
|
129
|
+
fs.copyFileSync(faviconSrc, resolve(publicDir, 'favicon.svg'));
|
|
97
130
|
}
|
|
131
|
+
|
|
132
|
+
faviconHtml = response.html.join('\n ');
|
|
133
|
+
// Add SVG favicon
|
|
134
|
+
if (faviconSrc.endsWith('.svg')) {
|
|
135
|
+
faviconHtml += '\n <link rel="icon" type="image/svg+xml" href="/favicon.svg">';
|
|
136
|
+
}
|
|
137
|
+
// Write tags for Vite plugin to pick up
|
|
138
|
+
fs.writeFileSync(resolve(publicDir, 'favicon-links.html'), faviconHtml);
|
|
139
|
+
console.log(` Generated ${response.images.length} favicon files`);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// Pass favicon tags to Vite via env
|
|
143
|
+
if (faviconHtml) {
|
|
144
|
+
process.env.FAVICON_HTML = faviconHtml;
|
|
98
145
|
}
|
|
99
146
|
|
|
100
147
|
// Run vite build using the package's vite.config.ts
|
package/index.html
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
<html lang="en">
|
|
3
3
|
<head>
|
|
4
4
|
<meta charset="UTF-8" />
|
|
5
|
-
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
|
|
6
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
6
|
<link rel="preconnect" href="https://fonts.googleapis.com">
|
|
8
7
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@glossarist/concept-browser",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.3",
|
|
4
4
|
"description": "Vue SPA for browsing Glossarist terminology datasets with cross-reference resolution, graph visualization, and multi-language support",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -36,6 +36,7 @@
|
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@types/d3": "^7.4.3",
|
|
38
38
|
"@vue/test-utils": "^2.4.8",
|
|
39
|
+
"favicons": "^7.2.0",
|
|
39
40
|
"happy-dom": "^20.9.0",
|
|
40
41
|
"typescript": "~5.7.3",
|
|
41
42
|
"vitest": "^4.1.5",
|
package/vite.config.ts
CHANGED
|
@@ -8,6 +8,27 @@ const cwd = process.cwd()
|
|
|
8
8
|
|
|
9
9
|
const isTest = process.env.VITEST !== undefined
|
|
10
10
|
|
|
11
|
+
function faviconPlugin() {
|
|
12
|
+
return {
|
|
13
|
+
name: 'favicon-inject',
|
|
14
|
+
transformIndexHtml(html: string) {
|
|
15
|
+
const tags = process.env.FAVICON_HTML
|
|
16
|
+
if (!tags) return html
|
|
17
|
+
const faviconTags = tags.split('\n').map((line: string) => {
|
|
18
|
+
const m = line.trim().match(/<(\w+)\s+(.*)\/?>/s)
|
|
19
|
+
if (!m) return null
|
|
20
|
+
const tag = m[1]
|
|
21
|
+
const attrs: Record<string, string> = {}
|
|
22
|
+
for (const [, k, v] of m[2].matchAll(/(\w[\w-]*)="([^"]*)"/g)) {
|
|
23
|
+
attrs[k] = v
|
|
24
|
+
}
|
|
25
|
+
return { tag, attrs, injectTo: 'head' as const }
|
|
26
|
+
}).filter(Boolean)
|
|
27
|
+
return { html, tags: faviconTags }
|
|
28
|
+
},
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
11
32
|
export default defineConfig({
|
|
12
33
|
base: process.env.BASE_PATH || '/',
|
|
13
34
|
root: __dirname,
|
|
@@ -16,7 +37,7 @@ export default defineConfig({
|
|
|
16
37
|
outDir: resolve(cwd, 'dist'),
|
|
17
38
|
emptyOutDir: true,
|
|
18
39
|
},
|
|
19
|
-
plugins: [vue()],
|
|
40
|
+
plugins: [faviconPlugin(), vue()],
|
|
20
41
|
resolve: {
|
|
21
42
|
alias: {
|
|
22
43
|
'@': resolve(__dirname, 'src'),
|