specra 0.2.63 → 0.2.64
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
CHANGED
|
@@ -166,6 +166,12 @@ export function specraConfig(options = {}) {
|
|
|
166
166
|
kit: {
|
|
167
167
|
...options.kit,
|
|
168
168
|
paths: {
|
|
169
|
+
// Absolute (base-prefixed) links rather than relative ones. Under a
|
|
170
|
+
// subpath deployment, relative links (the SvelteKit default) interact
|
|
171
|
+
// badly with the prerender crawler and produce wrong targets; absolute
|
|
172
|
+
// `${base}/...` links resolve and crawl correctly. Override via
|
|
173
|
+
// options.kit.paths.relative if a site truly needs relative output.
|
|
174
|
+
relative: false,
|
|
169
175
|
...options.kit?.paths,
|
|
170
176
|
base: basePath,
|
|
171
177
|
},
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { ArrowRight, ExternalLink } from 'lucide-svelte';
|
|
3
3
|
import type { Snippet } from 'svelte';
|
|
4
4
|
import Icon from './Icon.svelte';
|
|
5
|
+
import { link } from '../../links.js';
|
|
5
6
|
|
|
6
7
|
interface Props {
|
|
7
8
|
title: string;
|
|
@@ -13,6 +14,10 @@
|
|
|
13
14
|
}
|
|
14
15
|
|
|
15
16
|
let { title, description, href, icon, external = false, children }: Props = $props();
|
|
17
|
+
|
|
18
|
+
// Apply the deployment base path to internal absolute hrefs (e.g. /docs/...),
|
|
19
|
+
// since rehype only rewrites plain markdown links, not component props.
|
|
20
|
+
const resolvedHref = $derived(href && href.startsWith('/') ? link(href) : href);
|
|
16
21
|
</script>
|
|
17
22
|
|
|
18
23
|
{#snippet cardContent(isLink: boolean)}
|
|
@@ -49,7 +54,7 @@
|
|
|
49
54
|
|
|
50
55
|
{#if href}
|
|
51
56
|
<a
|
|
52
|
-
{
|
|
57
|
+
href={resolvedHref}
|
|
53
58
|
class="card-link group block h-full p-4 rounded-xl border border-border hover:border-primary/50 hover:bg-muted/50 transition-all"
|
|
54
59
|
target={external ? '_blank' : undefined}
|
|
55
60
|
rel={external ? 'noopener noreferrer' : undefined}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import MdxContent from './MdxContent.svelte';
|
|
3
3
|
import type { Component } from 'svelte';
|
|
4
4
|
import type { MdxNode } from '../../mdx.js';
|
|
5
|
+
import { base } from '$app/paths';
|
|
5
6
|
|
|
6
7
|
interface Props {
|
|
7
8
|
nodes: MdxNode[];
|
|
@@ -9,11 +10,26 @@
|
|
|
9
10
|
}
|
|
10
11
|
|
|
11
12
|
let { nodes, components }: Props = $props();
|
|
13
|
+
|
|
14
|
+
// Prefix absolute href/src in raw content HTML with the deployment base path.
|
|
15
|
+
// The content nodes are pre-rendered HTML emitted via {@html}, which bypasses
|
|
16
|
+
// rehypeBasePath, so links like /docs/... would otherwise be base-less under a
|
|
17
|
+
// subpath deployment. Skips protocol-relative (//) and already-based URLs.
|
|
18
|
+
function withBase(html: string): string {
|
|
19
|
+
if (!base || !html) return html;
|
|
20
|
+
return html.replace(
|
|
21
|
+
/(href|src)="(\/[^"]*)"/g,
|
|
22
|
+
(m, attr, p) =>
|
|
23
|
+
p.startsWith('//') || p === base || p.startsWith(base + '/')
|
|
24
|
+
? m
|
|
25
|
+
: `${attr}="${base}${p}"`
|
|
26
|
+
);
|
|
27
|
+
}
|
|
12
28
|
</script>
|
|
13
29
|
|
|
14
30
|
{#each nodes as node}
|
|
15
31
|
{#if node.type === 'html'}
|
|
16
|
-
{@html node.content}
|
|
32
|
+
{@html withBase(node.content)}
|
|
17
33
|
{:else if node.type === 'component' && node.name}
|
|
18
34
|
{@const Comp = components[node.name]}
|
|
19
35
|
{#if Comp}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "specra",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.64",
|
|
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",
|