specra 0.2.15 → 0.2.16
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.
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rehype plugin that prefixes internal absolute links with a base path.
|
|
3
|
+
* Internal links start with "/" and don't start with "http" or "//".
|
|
4
|
+
*
|
|
5
|
+
* Used for GitHub Pages deployments where the site lives under a subpath.
|
|
6
|
+
*
|
|
7
|
+
* Manually walks the tree to avoid ESM/CJS issues with unist-util-visit
|
|
8
|
+
* when loaded from svelte-config.js at Node.js config time.
|
|
9
|
+
*/
|
|
1
10
|
import type { Root } from 'hast';
|
|
2
11
|
interface Options {
|
|
3
12
|
basePath?: string;
|
package/dist/rehype-base-path.js
CHANGED
|
@@ -1,17 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
function walkElements(nodes, fn) {
|
|
2
|
+
for (const node of nodes) {
|
|
3
|
+
if (node.type === 'element') {
|
|
4
|
+
fn(node);
|
|
5
|
+
if (node.children) {
|
|
6
|
+
walkElements(node.children, fn);
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
}
|
|
8
11
|
export function rehypeBasePath(options = {}) {
|
|
9
12
|
const { basePath = '' } = options;
|
|
10
13
|
if (!basePath)
|
|
11
14
|
return () => { };
|
|
12
15
|
const cleanBase = basePath.replace(/\/$/, '');
|
|
13
16
|
return (tree) => {
|
|
14
|
-
|
|
17
|
+
walkElements(tree.children, (node) => {
|
|
15
18
|
if (node.tagName === 'a' && node.properties?.href) {
|
|
16
19
|
const href = node.properties.href;
|
|
17
20
|
if (typeof href === 'string' && href.startsWith('/') && !href.startsWith('//') && !href.startsWith(cleanBase + '/')) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "specra",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.16",
|
|
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",
|