@glossarist/concept-browser 0.7.71 → 0.7.73

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.
@@ -0,0 +1,55 @@
1
+ import { defineConfig } from 'astro/config';
2
+ import vue from '@astrojs/vue';
3
+ import sitemap from '@astrojs/sitemap';
4
+ import tailwindcss from '@tailwindcss/vite';
5
+ import yaml from 'js-yaml';
6
+ import { readFileSync } from 'fs';
7
+ import { fileURLToPath } from 'url';
8
+ import { resolve, dirname } from 'path';
9
+
10
+ const __dirname = dirname(fileURLToPath(import.meta.url));
11
+ const pkg = JSON.parse(readFileSync(resolve(__dirname, 'package.json'), 'utf-8'));
12
+ const pkgVersion = pkg.version;
13
+
14
+ const site = process.env.SITE_URL || 'https://www.geolexica.org';
15
+ const base = process.env.BASE_PATH || '/';
16
+
17
+ export default defineConfig({
18
+ root: __dirname,
19
+ site,
20
+ base,
21
+ output: 'static',
22
+ publicDir: resolve(process.cwd(), 'public'),
23
+ integrations: [
24
+ vue({ appEntrypoint: '/src/islands/app-entry' }),
25
+ sitemap(),
26
+ ],
27
+ i18n: {
28
+ defaultLocale: 'eng',
29
+ locales: ['eng', 'fra', 'deu', 'jpn', 'ara', 'zho', 'rus', 'spa', 'kor', 'swe', 'pol', 'fin', 'dan', 'nld', 'msa'],
30
+ routing: {
31
+ prefixDefaultLocale: false,
32
+ },
33
+ },
34
+ prefetch: {
35
+ prefetchAll: true,
36
+ defaultStrategy: 'viewport',
37
+ },
38
+ vite: {
39
+ plugins: [
40
+ tailwindcss(),
41
+ {
42
+ name: 'yaml-transform',
43
+ enforce: 'pre',
44
+ transform(code, id) {
45
+ if (!id.endsWith('.yml') && !id.endsWith('.yaml')) return;
46
+ const data = yaml.load(code);
47
+ return { code: `export default ${JSON.stringify(data)}`, map: null };
48
+ },
49
+ },
50
+ ],
51
+ define: {
52
+ __CONCEPT_BROWSER_VERSION__: JSON.stringify(pkgVersion),
53
+ },
54
+ },
55
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@glossarist/concept-browser",
3
- "version": "0.7.71",
3
+ "version": "0.7.73",
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": {
@@ -93,11 +93,11 @@
93
93
  "src",
94
94
  "data",
95
95
  "public/favicon.svg",
96
+ "astro.config.mjs",
96
97
  "index.html",
97
98
  "vite.config.ts",
98
99
  "tsconfig.json",
99
100
  "tailwind.config.js",
100
- "postcss.config.js",
101
101
  "env.d.ts"
102
102
  ]
103
103
  }
@@ -1,25 +1,18 @@
1
1
  /**
2
- * Data bridge: converts existing public/data/*.json into Astro
3
- * content collections at src/content/. Run before `astro build`.
2
+ * Data bridge: converts public/data/*.json into Astro content collections.
4
3
  *
5
- * Reads: public/data/datasets.json, public/data/{id}/manifest.json,
6
- * public/data/{id}/index.json
7
- * Writes: src/content/datasets/*.json, src/content/groups/*.json,
8
- * src/content/concepts/{registerId}/{conceptId}.json
4
+ * Reads from the CONSUMER's CWD: public/data/datasets.json, public/data/{id}/manifest.json
5
+ * Writes to the CONSUMER's CWD: .cb-content/{datasets,groups,concepts,pages}/
6
+ *
7
+ * The package directory (node_modules/@glossarist/concept-browser/) is NEVER written to.
9
8
  */
10
9
  import { readFileSync, writeFileSync, mkdirSync, existsSync, readdirSync } from 'fs';
11
- import { join, dirname } from 'path';
12
- import { fileURLToPath } from 'url';
10
+ import { join } from 'path';
13
11
 
14
- const __dirname = dirname(fileURLToPath(import.meta.url));
15
12
  const CWD = process.cwd();
16
- const PKG_ROOT = join(__dirname, '..');
17
- // Read generated data from the CONSUMER's working directory (where
18
- // generate-data.mjs writes public/data/). Write content collections
19
- // to the PACKAGE's src/content/ (where Astro expects them).
20
13
  const PUBLIC_DATA = join(CWD, 'public', 'data');
21
14
  const PUBLIC_ROOT = join(CWD, 'public');
22
- const CONTENT_DIR = join(PKG_ROOT, 'src', 'content');
15
+ const CONTENT_DIR = join(CWD, '.cb-content');
23
16
 
24
17
  function readJson(p) {
25
18
  if (!existsSync(p)) return null;
@@ -140,6 +133,7 @@ for (const g of groups) {
140
133
  // --- Pages (from public/pages/*.json) ---
141
134
  const pagesDir = join(CWD, 'public', 'pages');
142
135
  if (existsSync(pagesDir)) {
136
+ mkdirSync(join(CONTENT_DIR, 'pages'), { recursive: true });
143
137
  for (const file of readdirSync(pagesDir)) {
144
138
  if (!file.endsWith('.json')) continue;
145
139
  const page = readJson(join(pagesDir, file));
@@ -1,8 +1,11 @@
1
1
  import { defineCollection, z } from 'astro:content';
2
2
  import { glob } from 'astro/loaders';
3
+ import { resolve } from 'path';
4
+
5
+ const cbContent = resolve(process.cwd(), '.cb-content');
3
6
 
4
7
  const datasets = defineCollection({
5
- loader: glob({ pattern: '**/*.json', base: './src/content/datasets' }),
8
+ loader: glob({ pattern: '**/*.json', base: resolve(cbContent, 'datasets') }),
6
9
  schema: z.object({
7
10
  id: z.string(),
8
11
  title: z.string(),
@@ -25,7 +28,7 @@ const datasets = defineCollection({
25
28
  });
26
29
 
27
30
  const groups = defineCollection({
28
- loader: glob({ pattern: '**/*.json', base: './src/content/groups' }),
31
+ loader: glob({ pattern: '**/*.json', base: resolve(cbContent, 'groups') }),
29
32
  schema: z.object({
30
33
  id: z.string(),
31
34
  label: z.string(),
@@ -38,7 +41,7 @@ const groups = defineCollection({
38
41
  });
39
42
 
40
43
  const concepts = defineCollection({
41
- loader: glob({ pattern: '**/*.json', base: './src/content/concepts' }),
44
+ loader: glob({ pattern: '**/*.json', base: resolve(cbContent, 'concepts') }),
42
45
  schema: z.object({
43
46
  registerId: z.string(),
44
47
  conceptId: z.string(),
@@ -73,7 +76,7 @@ const concepts = defineCollection({
73
76
  });
74
77
 
75
78
  const pages = defineCollection({
76
- loader: glob({ pattern: '**/*.{md,json}', base: './src/content/pages' }),
79
+ loader: glob({ pattern: '**/*.{md,json}', base: resolve(cbContent, 'pages') }),
77
80
  schema: z.object({
78
81
  title: z.string(),
79
82
  type: z.string().optional(),