specra 0.2.16 → 0.2.55
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/config/svelte-config.js +44 -4
- package/package.json +1 -1
package/config/svelte-config.js
CHANGED
|
@@ -78,8 +78,27 @@ function resolveBasePath(configPath = path.join(process.cwd(), 'specra.config.js
|
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
/**
|
|
81
|
-
* Scan the docs/ directory and return prerender entries for
|
|
82
|
-
*
|
|
81
|
+
* Scan the docs/ directory and return prerender entries for every
|
|
82
|
+
* version-root page across all products and the default (no-product)
|
|
83
|
+
* layout. SvelteKit's prerender crawler picks up child pages by
|
|
84
|
+
* following links, but the version-root pages themselves are leaves
|
|
85
|
+
* with no inbound link from a prerendered ancestor (the product
|
|
86
|
+
* dropdown switches between them client-side), so adapter-static
|
|
87
|
+
* needs them seeded explicitly. Without these entries, navigating
|
|
88
|
+
* from one product to another in a static build fetches a
|
|
89
|
+
* non-existent `__data.json` and falls back through to the SPA
|
|
90
|
+
* `index.html` — the client then JSON.parse's HTML and throws
|
|
91
|
+
* `Unexpected token '<', "<!doctype html>"`.
|
|
92
|
+
*
|
|
93
|
+
* Layouts we handle:
|
|
94
|
+
* docs/v1/... → emit `/docs/v1`
|
|
95
|
+
* docs/v2/... → emit `/docs/v2`
|
|
96
|
+
* docs/sdk/_product_.json → recurse: docs/sdk/v1 → emit `/docs/sdk/v1`
|
|
97
|
+
* docs/api/_product_.json → recurse: docs/api/v1 → emit `/docs/api/v1`
|
|
98
|
+
*
|
|
99
|
+
* `_product_.json` is the marker file Specra uses to identify a
|
|
100
|
+
* multi-product layout (the same marker the SDK's product loader
|
|
101
|
+
* reads).
|
|
83
102
|
*/
|
|
84
103
|
function discoverVersionEntries(docsDir = path.join(process.cwd(), 'docs')) {
|
|
85
104
|
const entries = ['/']
|
|
@@ -88,12 +107,33 @@ function discoverVersionEntries(docsDir = path.join(process.cwd(), 'docs')) {
|
|
|
88
107
|
|
|
89
108
|
const items = fs.readdirSync(docsDir, { withFileTypes: true })
|
|
90
109
|
for (const item of items) {
|
|
91
|
-
if (item.isDirectory()
|
|
110
|
+
if (!item.isDirectory()) continue
|
|
111
|
+
|
|
112
|
+
// Default-product version: docs/v1 → /docs/v1
|
|
113
|
+
if (/^v\d/.test(item.name)) {
|
|
92
114
|
entries.push(`/docs/${item.name}`)
|
|
115
|
+
continue
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// Multi-product: directory has a _product_.json marker. Recurse
|
|
119
|
+
// into it and emit one entry per version subdirectory.
|
|
120
|
+
const productDir = path.join(docsDir, item.name)
|
|
121
|
+
const productMarker = path.join(productDir, '_product_.json')
|
|
122
|
+
if (!fs.existsSync(productMarker)) continue
|
|
123
|
+
|
|
124
|
+
try {
|
|
125
|
+
const versionItems = fs.readdirSync(productDir, { withFileTypes: true })
|
|
126
|
+
for (const v of versionItems) {
|
|
127
|
+
if (v.isDirectory() && /^v\d/.test(v.name)) {
|
|
128
|
+
entries.push(`/docs/${item.name}/${v.name}`)
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
} catch {
|
|
132
|
+
// Ignore product-dir read errors — leave that product unseeded.
|
|
93
133
|
}
|
|
94
134
|
}
|
|
95
135
|
} catch {
|
|
96
|
-
// Ignore errors — fall back to just '/'
|
|
136
|
+
// Ignore top-level errors — fall back to just '/'.
|
|
97
137
|
}
|
|
98
138
|
return entries
|
|
99
139
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "specra",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.55",
|
|
4
4
|
"description": "A modern documentation library for SvelteKit with built-in versioning, API reference generation, full-text search, and MDX support",
|
|
5
5
|
"svelte": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|