@f5-sales-demo/docs-theme 4.4.5 → 4.4.7
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/package.json
CHANGED
|
@@ -30,14 +30,17 @@ export async function shareProviderAssets(root, base = '/') {
|
|
|
30
30
|
tokenStyles.set(name, style);
|
|
31
31
|
return `<span class="${name}"`;
|
|
32
32
|
});
|
|
33
|
-
html = html.replace(
|
|
33
|
+
html = html.replace(
|
|
34
|
+
/<a\b([^>]*?)href="https:\/\/f5-sales-demo.github.io(\/terraform-provider-xcsh\/[^"#]*)/g,
|
|
35
|
+
'<a$1href="$2',
|
|
36
|
+
);
|
|
34
37
|
if (tokenStyles.size) html = html.replace('</head>', `<link rel="stylesheet" href="${prefix}tokens.css"></head>`);
|
|
35
38
|
const islands = [];
|
|
36
39
|
html = html.replace(/<astro-island\b[\s\S]*?<\/astro-island>/g, (island) => {
|
|
37
40
|
islands.push(island);
|
|
38
41
|
return `<!--provider-island-${islands.length - 1}-->`;
|
|
39
42
|
});
|
|
40
|
-
const pagePath = `${base.replace(/\/$/, '')}/${file.
|
|
43
|
+
const pagePath = `${base.replace(/\/$/, '')}/${posix.dirname(file) === '.' ? '' : posix.dirname(file) + '/'}`;
|
|
41
44
|
html = html.replace(/<a\b([^>]*?)href="([^"#]+)(#[^"]*)?"/g, (original, attrs, href, fragment = '') => {
|
|
42
45
|
if (!href.startsWith(`${base.replace(/\/$/, '')}/`)) return original;
|
|
43
46
|
const target = href.split('?')[0];
|
|
@@ -55,3 +55,33 @@ it('shortens internal HTML links without changing resolved fragment destinations
|
|
|
55
55
|
await rm(root, { recursive: true, force: true });
|
|
56
56
|
}
|
|
57
57
|
});
|
|
58
|
+
|
|
59
|
+
it('resolves file-route links from their containing directory', async () => {
|
|
60
|
+
const root = await mkdtemp(join(tmpdir(), 'provider-file-route-'));
|
|
61
|
+
try {
|
|
62
|
+
await writeFile(join(root, '404.html'), '<a href="/provider/preview/main/actions/">Actions</a>');
|
|
63
|
+
await shareProviderAssets(root, '/provider/preview/main/');
|
|
64
|
+
const html = await readFile(join(root, '404.html'), 'utf8');
|
|
65
|
+
const match = /href="([^"]+)"/.exec(html);
|
|
66
|
+
if (!match) throw new Error('missing link');
|
|
67
|
+
expect(new URL(match[1], 'https://example.test/provider/preview/main/404.html').href).toBe(
|
|
68
|
+
'https://example.test/provider/preview/main/actions/',
|
|
69
|
+
);
|
|
70
|
+
} finally {
|
|
71
|
+
await rm(root, { recursive: true, force: true });
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
it('preserves absolute canonical metadata while shortening anchor links', async () => {
|
|
76
|
+
const root = await mkdtemp(join(tmpdir(), 'provider-canonical-'));
|
|
77
|
+
try {
|
|
78
|
+
const url = 'https://f5-sales-demo.github.io/terraform-provider-xcsh/resources/';
|
|
79
|
+
await writeFile(join(root, 'index.html'), `<link rel="canonical" href="${url}"><a href="${url}">Resources</a>`);
|
|
80
|
+
await shareProviderAssets(root, '/terraform-provider-xcsh/');
|
|
81
|
+
const html = await readFile(join(root, 'index.html'), 'utf8');
|
|
82
|
+
expect(html).toContain(`<link rel="canonical" href="${url}">`);
|
|
83
|
+
expect(html).toContain('<a href="resources/">');
|
|
84
|
+
} finally {
|
|
85
|
+
await rm(root, { recursive: true, force: true });
|
|
86
|
+
}
|
|
87
|
+
});
|