@f5-sales-demo/docs-theme 4.10.0 → 4.11.1
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.ts
CHANGED
|
@@ -38,6 +38,7 @@ import { stagedProviderSections } from './src/utils/provider-sections.ts';
|
|
|
38
38
|
import { publicationSidebar, repositoryPublicationProfile } from './src/utils/publication-profiles.ts';
|
|
39
39
|
import { resolveMegaMenuIcon } from './src/utils/resolve-icon.ts';
|
|
40
40
|
import providerSharedAssets from './src/utils/share-provider-assets.mjs';
|
|
41
|
+
import { statisticsScriptMarkdown } from './src/utils/statistics-script-markdown.mjs';
|
|
41
42
|
import { buildSubcategorySidebar } from './src/utils/subcategory-sidebar.ts';
|
|
42
43
|
|
|
43
44
|
export type { LocaleConfig } from './src/i18n/locales.ts';
|
|
@@ -942,6 +943,7 @@ export function createF5xcDocsConfig(options: F5xcDocsConfigOptions = {}) {
|
|
|
942
943
|
...(canonicalProvider
|
|
943
944
|
? [providerSharedAssets(), canonicalLlms({ contentRoot: canonicalProvider.contentRoot, base, title })]
|
|
944
945
|
: []),
|
|
946
|
+
...(githubRepository === 'f5-sales-demo/statistics' ? [statisticsScriptMarkdown()] : []),
|
|
945
947
|
...additionalIntegrations,
|
|
946
948
|
],
|
|
947
949
|
});
|
package/package.json
CHANGED
|
@@ -66,7 +66,7 @@ describe('Statistics publication', () => {
|
|
|
66
66
|
});
|
|
67
67
|
expect(repositoryPublicationProfile('statistics')?.favicon).toBeUndefined();
|
|
68
68
|
});
|
|
69
|
-
it('
|
|
69
|
+
it('preserves 13 existing routes and places Shell Scripts before Infrastructure', () => {
|
|
70
70
|
const sidebar = publicationSidebar('f5-sales-demo/statistics', []);
|
|
71
71
|
expect(sidebar?.slice(0, 11)).toEqual([
|
|
72
72
|
{ slug: 'index' },
|
|
@@ -81,12 +81,13 @@ describe('Statistics publication', () => {
|
|
|
81
81
|
{ slug: 'api-catalog' },
|
|
82
82
|
{ slug: 'setup' },
|
|
83
83
|
]);
|
|
84
|
-
expect(sidebar?.[11]).toEqual({
|
|
84
|
+
expect(sidebar?.[11]).toEqual({ slug: 'shell-scripts' });
|
|
85
|
+
expect(sidebar?.[12]).toEqual({
|
|
85
86
|
label: 'Infrastructure',
|
|
86
87
|
collapsed: true,
|
|
87
88
|
items: [{ slug: 'deployment' }, { slug: 'verification' }],
|
|
88
89
|
});
|
|
89
|
-
expect(sidebar).toHaveLength(
|
|
90
|
+
expect(sidebar).toHaveLength(13);
|
|
90
91
|
const routes = sidebar?.flatMap((item) =>
|
|
91
92
|
'slug' in item
|
|
92
93
|
? [item.slug]
|
|
@@ -94,8 +95,8 @@ describe('Statistics publication', () => {
|
|
|
94
95
|
? item.items.map((child) => ('slug' in child ? child.slug : ''))
|
|
95
96
|
: [],
|
|
96
97
|
);
|
|
97
|
-
expect(routes).toHaveLength(
|
|
98
|
-
expect(new Set(routes).size).toBe(
|
|
98
|
+
expect(routes).toHaveLength(14);
|
|
99
|
+
expect(new Set(routes).size).toBe(14);
|
|
99
100
|
});
|
|
100
101
|
it('preserves supplied fallback navigation for other repositories', () => {
|
|
101
102
|
const fallback = [{ slug: 'index' }, { label: 'Existing', items: [{ slug: 'existing' }] }];
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { readFile, writeFile } from 'node:fs/promises';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import { fileURLToPath } from 'node:url';
|
|
4
|
+
|
|
5
|
+
/** Keep the Statistics page-action Markdown export equal to its imported script source. */
|
|
6
|
+
export function statisticsScriptMarkdown() {
|
|
7
|
+
let root;
|
|
8
|
+
return {
|
|
9
|
+
name: 'statistics-script-markdown',
|
|
10
|
+
hooks: {
|
|
11
|
+
'astro:config:done': ({ config }) => {
|
|
12
|
+
root = fileURLToPath(config.root);
|
|
13
|
+
},
|
|
14
|
+
'astro:build:done': async ({ dir }) => {
|
|
15
|
+
await expandStatisticsScriptMarkdown(root, fileURLToPath(dir));
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export async function expandStatisticsScriptMarkdown(root, output) {
|
|
22
|
+
const path = join(output, 'en/shell-scripts.md');
|
|
23
|
+
let markdown = await readFile(path, 'utf8');
|
|
24
|
+
for (const name of ['simple-stats.sh', 'get-stats.sh']) {
|
|
25
|
+
const source = await readFile(join(root, 'src/content/docs/assets/scripts', name), 'utf8');
|
|
26
|
+
const fence = `\x60\x60\x60bash file=../assets/scripts/${name}\n\x60\x60\x60`;
|
|
27
|
+
if (!markdown.includes(fence)) throw new Error(`Missing script import in Statistics Markdown: ${name}`);
|
|
28
|
+
markdown = markdown.replace(fence, () => `\x60\x60\x60bash\n${source}\x60\x60\x60`);
|
|
29
|
+
}
|
|
30
|
+
await writeFile(path, markdown);
|
|
31
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { mkdir, mkdtemp, readFile, rm, writeFile } from 'node:fs/promises';
|
|
2
|
+
import { tmpdir } from 'node:os';
|
|
3
|
+
import { join } from 'node:path';
|
|
4
|
+
import { describe, expect, it } from 'vitest';
|
|
5
|
+
import { expandStatisticsScriptMarkdown } from './statistics-script-markdown.mjs';
|
|
6
|
+
|
|
7
|
+
describe('Statistics script Markdown export', () => {
|
|
8
|
+
it('expands both complete sources without interpreting replacement characters', async () => {
|
|
9
|
+
const root = await mkdtemp(join(tmpdir(), 'statistics-export-'));
|
|
10
|
+
try {
|
|
11
|
+
await mkdir(join(root, 'src/content/docs/assets/scripts'), { recursive: true });
|
|
12
|
+
await mkdir(join(root, 'output/en'), { recursive: true });
|
|
13
|
+
const source = '#!/usr/bin/env bash\nprintf "%s" "$&"\n';
|
|
14
|
+
for (const name of ['simple-stats.sh', 'get-stats.sh']) {
|
|
15
|
+
await writeFile(join(root, 'src/content/docs/assets/scripts', name), source);
|
|
16
|
+
}
|
|
17
|
+
await writeFile(
|
|
18
|
+
join(root, 'output/en/shell-scripts.md'),
|
|
19
|
+
['simple-stats.sh', 'get-stats.sh']
|
|
20
|
+
.map((name) => `\x60\x60\x60bash file=../assets/scripts/${name}\n\x60\x60\x60`)
|
|
21
|
+
.join('\n'),
|
|
22
|
+
);
|
|
23
|
+
await expandStatisticsScriptMarkdown(root, join(root, 'output'));
|
|
24
|
+
expect(await readFile(join(root, 'output/en/shell-scripts.md'), 'utf8')).toBe(
|
|
25
|
+
`\x60\x60\x60bash\n${source}\x60\x60\x60\n\x60\x60\x60bash\n${source}\x60\x60\x60`,
|
|
26
|
+
);
|
|
27
|
+
} finally {
|
|
28
|
+
await rm(root, { recursive: true, force: true });
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
});
|