@forsakringskassan/docs-generator 3.7.0 → 3.9.0
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/dist/index.d.mts +27 -0
- package/dist/index.mjs +127 -51
- package/dist/index.mjs.map +1 -1
- package/dist/runtime-internal.mjs +95 -126
- package/dist/style/core.css +127 -163
- package/dist/style/index.css +397 -172
- package/dist/style/site.css +360 -10
- package/dist/style/theme/fkui.css +6 -2
- package/package.json +1 -22
- package/templates/base.template.html +3 -1
- package/templates/macro/menu.html +6 -1
- package/templates/macro/mobile-menu.html +71 -0
- package/templates/partials/header.html +11 -9
- package/templates/partials/mobile-nav.html +24 -0
- package/templates/partials/spritesheet.html +12 -0
- package/templates/partials/topnav.html +0 -22
package/dist/index.d.mts
CHANGED
|
@@ -298,6 +298,24 @@ declare class Generator_2 {
|
|
|
298
298
|
format?: "iife" | "cjs" | "esm";
|
|
299
299
|
define?: Record<string, string>;
|
|
300
300
|
}): void;
|
|
301
|
+
/**
|
|
302
|
+
* Compile a worker script.
|
|
303
|
+
*
|
|
304
|
+
* This is mostly the same as {@link Generator.compileScript} with some differences:
|
|
305
|
+
*
|
|
306
|
+
* - The script is written directly to `outputFolder` instead of `assetFolder` (i.e. to the web root).
|
|
307
|
+
* - The output filename does not include a hash.
|
|
308
|
+
*
|
|
309
|
+
* @public
|
|
310
|
+
* @since %version%
|
|
311
|
+
* @param name - Asset name.
|
|
312
|
+
* @param src - Asset entrypoint.
|
|
313
|
+
* @param buildOptions - Options passed to `esbuild`.
|
|
314
|
+
*/
|
|
315
|
+
compileWorker(name: string, src: string | URL, buildOptions?: {
|
|
316
|
+
format?: "iife" | "cjs" | "esm";
|
|
317
|
+
define?: Record<string, string>;
|
|
318
|
+
}): void;
|
|
301
319
|
compileStyle(name: string, src: string | URL, options?: Partial<CompileOptions>): void;
|
|
302
320
|
/**
|
|
303
321
|
* @param dst - Destination directory relative to asset folder.
|
|
@@ -616,6 +634,15 @@ export declare interface PackageJson {
|
|
|
616
634
|
};
|
|
617
635
|
}
|
|
618
636
|
|
|
637
|
+
/* Excluded from this release type: PartialFile */
|
|
638
|
+
|
|
639
|
+
/**
|
|
640
|
+
* Read partial documents for insertion in other markdown documents.
|
|
641
|
+
*
|
|
642
|
+
* @public
|
|
643
|
+
*/
|
|
644
|
+
export declare function partialFileReader(filePath: string): Promise<DocumentPartial[]>;
|
|
645
|
+
|
|
619
646
|
/**
|
|
620
647
|
* Generates links to code playgrounds.
|
|
621
648
|
*
|
package/dist/index.mjs
CHANGED
|
@@ -1304,6 +1304,45 @@ function generateNavtree(docs) {
|
|
|
1304
1304
|
};
|
|
1305
1305
|
}
|
|
1306
1306
|
|
|
1307
|
+
function sortNavigationTree(tree) {
|
|
1308
|
+
tree.children.sort((a, b) => {
|
|
1309
|
+
if (a.sortorder < b.sortorder) {
|
|
1310
|
+
return -1;
|
|
1311
|
+
}
|
|
1312
|
+
if (a.sortorder > b.sortorder) {
|
|
1313
|
+
return 1;
|
|
1314
|
+
}
|
|
1315
|
+
const titleA = a.title.toUpperCase();
|
|
1316
|
+
const titleB = b.title.toUpperCase();
|
|
1317
|
+
if (titleA < titleB) {
|
|
1318
|
+
return -1;
|
|
1319
|
+
}
|
|
1320
|
+
if (titleA > titleB) {
|
|
1321
|
+
return 1;
|
|
1322
|
+
}
|
|
1323
|
+
return 0;
|
|
1324
|
+
});
|
|
1325
|
+
for (const child of tree.children) {
|
|
1326
|
+
if (isNavigationSection(child)) {
|
|
1327
|
+
sortNavigationTree(child);
|
|
1328
|
+
}
|
|
1329
|
+
}
|
|
1330
|
+
}
|
|
1331
|
+
|
|
1332
|
+
function navigationProcessor() {
|
|
1333
|
+
return {
|
|
1334
|
+
stage: "generate-nav",
|
|
1335
|
+
name: "navigation-processor",
|
|
1336
|
+
handler(context) {
|
|
1337
|
+
const pages = context.docs.filter(isDocumentPage);
|
|
1338
|
+
const navtree = generateNavtree(pages);
|
|
1339
|
+
sortNavigationTree(navtree);
|
|
1340
|
+
context.setTopNavigation(navtree);
|
|
1341
|
+
context.setSideNavigation(navtree);
|
|
1342
|
+
}
|
|
1343
|
+
};
|
|
1344
|
+
}
|
|
1345
|
+
|
|
1307
1346
|
function generateNavigation(entries, navtree) {
|
|
1308
1347
|
return {
|
|
1309
1348
|
key: ".",
|
|
@@ -1342,6 +1381,7 @@ function topnavProcessor(filename, title) {
|
|
|
1342
1381
|
const parsed = JSON.parse(content);
|
|
1343
1382
|
const pages = context.docs.filter(isDocumentPage);
|
|
1344
1383
|
const navtree = generateNavtree(pages);
|
|
1384
|
+
sortNavigationTree(navtree);
|
|
1345
1385
|
const rootNode = generateNavigation(parsed, navtree);
|
|
1346
1386
|
context.setTopNavigation({
|
|
1347
1387
|
title,
|
|
@@ -1736,7 +1776,7 @@ function getComponent(attrs) {
|
|
|
1736
1776
|
}
|
|
1737
1777
|
return toArray$1(attrs.component).map(normalizeComponent);
|
|
1738
1778
|
}
|
|
1739
|
-
function parseFile$
|
|
1779
|
+
function parseFile$2(filePath, basePath, content) {
|
|
1740
1780
|
const relative = basePath ? path__default.relative(basePath, normalizePath(filePath)) : normalizePath(filePath);
|
|
1741
1781
|
const parsed = path__default.parse(relative);
|
|
1742
1782
|
const blocks = fm(content);
|
|
@@ -1782,7 +1822,7 @@ function parseFile$1(filePath, basePath, content) {
|
|
|
1782
1822
|
}
|
|
1783
1823
|
async function frontMatterFileReader(filePath, basePath) {
|
|
1784
1824
|
const content = await fs.readFile(filePath, "utf8");
|
|
1785
|
-
const doc = parseFile$
|
|
1825
|
+
const doc = parseFile$2(filePath, basePath, content);
|
|
1786
1826
|
return [doc];
|
|
1787
1827
|
}
|
|
1788
1828
|
|
|
@@ -2549,7 +2589,7 @@ function fileReaderProcessor(sourceFiles) {
|
|
|
2549
2589
|
};
|
|
2550
2590
|
}
|
|
2551
2591
|
|
|
2552
|
-
function parseFile(filePath, basePath, content) {
|
|
2592
|
+
function parseFile$1(filePath, basePath, content) {
|
|
2553
2593
|
const attributes = JSON.parse(content);
|
|
2554
2594
|
const { title, href } = attributes;
|
|
2555
2595
|
if (!title) {
|
|
@@ -2588,10 +2628,31 @@ function parseFile(filePath, basePath, content) {
|
|
|
2588
2628
|
}
|
|
2589
2629
|
async function navigationFileReader(filePath, basePath) {
|
|
2590
2630
|
const content = await fs.readFile(filePath, "utf8");
|
|
2591
|
-
const doc = parseFile(filePath, basePath, content);
|
|
2631
|
+
const doc = parseFile$1(filePath, basePath, content);
|
|
2592
2632
|
return [doc];
|
|
2593
2633
|
}
|
|
2594
2634
|
|
|
2635
|
+
function parseFile(filePath, content) {
|
|
2636
|
+
const parsed = JSON.parse(content);
|
|
2637
|
+
return parsed.map((it) => {
|
|
2638
|
+
return {
|
|
2639
|
+
kind: "partial",
|
|
2640
|
+
id: it.id,
|
|
2641
|
+
name: it.id,
|
|
2642
|
+
alias: [],
|
|
2643
|
+
body: it.body,
|
|
2644
|
+
format: it.format,
|
|
2645
|
+
fileInfo: {
|
|
2646
|
+
fullPath: filePath
|
|
2647
|
+
}
|
|
2648
|
+
};
|
|
2649
|
+
});
|
|
2650
|
+
}
|
|
2651
|
+
async function partialFileReader(filePath) {
|
|
2652
|
+
const content = await fs.readFile(filePath, "utf8");
|
|
2653
|
+
return parseFile(filePath, content);
|
|
2654
|
+
}
|
|
2655
|
+
|
|
2595
2656
|
async function compileSassString(dst, style) {
|
|
2596
2657
|
const result = await compileStringAsync(style, {
|
|
2597
2658
|
style: "expanded",
|
|
@@ -2676,9 +2737,11 @@ function toExternalVendor(vendor) {
|
|
|
2676
2737
|
}
|
|
2677
2738
|
async function compileScript(options) {
|
|
2678
2739
|
const {
|
|
2679
|
-
assetFolder,
|
|
2680
2740
|
name,
|
|
2681
2741
|
src,
|
|
2742
|
+
rootDir,
|
|
2743
|
+
outputFolder,
|
|
2744
|
+
outputName,
|
|
2682
2745
|
assets,
|
|
2683
2746
|
vendor,
|
|
2684
2747
|
buildOptions,
|
|
@@ -2707,15 +2770,19 @@ async function compileScript(options) {
|
|
|
2707
2770
|
const content = await fs$1.readFile(outfile, "utf8");
|
|
2708
2771
|
const fingerprint = getFingerprint(content);
|
|
2709
2772
|
const integrity = getIntegrity(content);
|
|
2710
|
-
const filename = `${
|
|
2711
|
-
const dst = path__default.join(
|
|
2773
|
+
const filename = `${outputName}.js`.replaceAll("[name]", () => name).replaceAll("[hash]", () => fingerprint);
|
|
2774
|
+
const dst = path__default.join(outputFolder, filename);
|
|
2775
|
+
const publicPath = path__default.posix.join(
|
|
2776
|
+
path__default.posix.relative(rootDir, outputFolder),
|
|
2777
|
+
filename
|
|
2778
|
+
);
|
|
2712
2779
|
await fs$1.mkdir(path__default.dirname(dst), { recursive: true });
|
|
2713
2780
|
await fs$1.rename(outfile, dst);
|
|
2714
2781
|
const stat = await fs$1.stat(dst);
|
|
2715
2782
|
return {
|
|
2716
2783
|
name,
|
|
2717
2784
|
filename,
|
|
2718
|
-
publicPath:
|
|
2785
|
+
publicPath: `./${publicPath}`,
|
|
2719
2786
|
integrity,
|
|
2720
2787
|
format,
|
|
2721
2788
|
size: stat.size,
|
|
@@ -2735,7 +2802,7 @@ function byPriority({ options: a }, { options: b }) {
|
|
|
2735
2802
|
function isExternal(asset) {
|
|
2736
2803
|
return asset.options.appendTo === "none";
|
|
2737
2804
|
}
|
|
2738
|
-
function jsAssetProcessor(
|
|
2805
|
+
function jsAssetProcessor(rootDir, assets, vendor) {
|
|
2739
2806
|
const externalAssets = assets.filter(isExternal).map((it) => it.name);
|
|
2740
2807
|
return {
|
|
2741
2808
|
name: "js-asset-processor",
|
|
@@ -2746,9 +2813,11 @@ function jsAssetProcessor(assetFolder, assets, vendor) {
|
|
|
2746
2813
|
const body = context.getTemplateData("injectBody", []);
|
|
2747
2814
|
for (const asset of assets.toSorted(byPriority)) {
|
|
2748
2815
|
const info = await compileScript({
|
|
2749
|
-
assetFolder,
|
|
2750
2816
|
name: asset.name,
|
|
2751
2817
|
src: asset.src,
|
|
2818
|
+
rootDir,
|
|
2819
|
+
outputFolder: asset.outputFolder,
|
|
2820
|
+
outputName: asset.outputName,
|
|
2752
2821
|
assets: externalAssets,
|
|
2753
2822
|
vendor,
|
|
2754
2823
|
buildOptions: asset.buildOptions
|
|
@@ -2856,6 +2925,12 @@ var translation$1 = {
|
|
|
2856
2925
|
instructions: "<kbd>Esc</kbd> to close <kbd>Arrow up/down</kbd> to navigate <kbd>Enter</kbd> to select",
|
|
2857
2926
|
title: "Search",
|
|
2858
2927
|
placeholder: "Type to begin searching"
|
|
2928
|
+
},
|
|
2929
|
+
"mobile-nav": {
|
|
2930
|
+
close: "Close",
|
|
2931
|
+
menu: "Menu",
|
|
2932
|
+
"aria-label": "Open/close menu",
|
|
2933
|
+
nav: "Mobile primary"
|
|
2859
2934
|
}
|
|
2860
2935
|
};
|
|
2861
2936
|
var langEn = {
|
|
@@ -2890,51 +2965,18 @@ var translation = {
|
|
|
2890
2965
|
instructions: "<kbd>Esc</kbd> för att stänga <kbd>Pil upp/ner</kbd> för att navigera <kbd>Enter</kbd> för att välja",
|
|
2891
2966
|
title: "Sök",
|
|
2892
2967
|
placeholder: "Skriv för att börja söka"
|
|
2968
|
+
},
|
|
2969
|
+
"mobile-nav": {
|
|
2970
|
+
close: "Stäng",
|
|
2971
|
+
menu: "Meny",
|
|
2972
|
+
"aria-label": "Öppen/stängd meny",
|
|
2973
|
+
nav: "Mobile primär"
|
|
2893
2974
|
}
|
|
2894
2975
|
};
|
|
2895
2976
|
var langSv = {
|
|
2896
2977
|
translation: translation
|
|
2897
2978
|
};
|
|
2898
2979
|
|
|
2899
|
-
function sortNavigationTree(tree) {
|
|
2900
|
-
tree.children.sort((a, b) => {
|
|
2901
|
-
if (a.sortorder < b.sortorder) {
|
|
2902
|
-
return -1;
|
|
2903
|
-
}
|
|
2904
|
-
if (a.sortorder > b.sortorder) {
|
|
2905
|
-
return 1;
|
|
2906
|
-
}
|
|
2907
|
-
const titleA = a.title.toUpperCase();
|
|
2908
|
-
const titleB = b.title.toUpperCase();
|
|
2909
|
-
if (titleA < titleB) {
|
|
2910
|
-
return -1;
|
|
2911
|
-
}
|
|
2912
|
-
if (titleA > titleB) {
|
|
2913
|
-
return 1;
|
|
2914
|
-
}
|
|
2915
|
-
return 0;
|
|
2916
|
-
});
|
|
2917
|
-
for (const child of tree.children) {
|
|
2918
|
-
if (isNavigationSection(child)) {
|
|
2919
|
-
sortNavigationTree(child);
|
|
2920
|
-
}
|
|
2921
|
-
}
|
|
2922
|
-
}
|
|
2923
|
-
|
|
2924
|
-
function navigationProcessor() {
|
|
2925
|
-
return {
|
|
2926
|
-
stage: "generate-nav",
|
|
2927
|
-
name: "navigation-processor",
|
|
2928
|
-
handler(context) {
|
|
2929
|
-
const pages = context.docs.filter(isDocumentPage);
|
|
2930
|
-
const navtree = generateNavtree(pages);
|
|
2931
|
-
sortNavigationTree(navtree);
|
|
2932
|
-
context.setTopNavigation(navtree);
|
|
2933
|
-
context.setSideNavigation(navtree);
|
|
2934
|
-
}
|
|
2935
|
-
};
|
|
2936
|
-
}
|
|
2937
|
-
|
|
2938
2980
|
const templateUrl = new URL("../templates", import.meta.url);
|
|
2939
2981
|
const templateDirectory = fileURLToPath(templateUrl);
|
|
2940
2982
|
|
|
@@ -3887,9 +3929,12 @@ class Generator {
|
|
|
3887
3929
|
});
|
|
3888
3930
|
}
|
|
3889
3931
|
compileScript(name, src, options, buildOptions) {
|
|
3932
|
+
const { assetFolder } = this;
|
|
3890
3933
|
this.scripts.push({
|
|
3891
3934
|
name,
|
|
3892
3935
|
src,
|
|
3936
|
+
outputFolder: assetFolder,
|
|
3937
|
+
outputName: "[name]-[hash]",
|
|
3893
3938
|
options: {
|
|
3894
3939
|
appendTo: "none",
|
|
3895
3940
|
attributes: {},
|
|
@@ -3901,6 +3946,37 @@ class Generator {
|
|
|
3901
3946
|
}
|
|
3902
3947
|
});
|
|
3903
3948
|
}
|
|
3949
|
+
/**
|
|
3950
|
+
* Compile a worker script.
|
|
3951
|
+
*
|
|
3952
|
+
* This is mostly the same as {@link Generator.compileScript} with some differences:
|
|
3953
|
+
*
|
|
3954
|
+
* - The script is written directly to `outputFolder` instead of `assetFolder` (i.e. to the web root).
|
|
3955
|
+
* - The output filename does not include a hash.
|
|
3956
|
+
*
|
|
3957
|
+
* @public
|
|
3958
|
+
* @since %version%
|
|
3959
|
+
* @param name - Asset name.
|
|
3960
|
+
* @param src - Asset entrypoint.
|
|
3961
|
+
* @param buildOptions - Options passed to `esbuild`.
|
|
3962
|
+
*/
|
|
3963
|
+
compileWorker(name, src, buildOptions) {
|
|
3964
|
+
const { outputFolder } = this;
|
|
3965
|
+
this.scripts.push({
|
|
3966
|
+
name,
|
|
3967
|
+
src,
|
|
3968
|
+
outputFolder,
|
|
3969
|
+
outputName: "[name]",
|
|
3970
|
+
options: {
|
|
3971
|
+
appendTo: "none",
|
|
3972
|
+
attributes: {},
|
|
3973
|
+
priority: 0
|
|
3974
|
+
},
|
|
3975
|
+
buildOptions: {
|
|
3976
|
+
...buildOptions
|
|
3977
|
+
}
|
|
3978
|
+
});
|
|
3979
|
+
}
|
|
3904
3980
|
compileStyle(name, src, options) {
|
|
3905
3981
|
this.styles.push({
|
|
3906
3982
|
name,
|
|
@@ -3983,7 +4059,7 @@ class Generator {
|
|
|
3983
4059
|
redirectProcessor(),
|
|
3984
4060
|
vendorProcessor(assetFolder, this.vendor),
|
|
3985
4061
|
cssAssetProcessor(assetFolder, this.styles),
|
|
3986
|
-
jsAssetProcessor(
|
|
4062
|
+
jsAssetProcessor(outputFolder, this.scripts, this.vendor),
|
|
3987
4063
|
staticResourcesProcessor(assetFolder, this.resources),
|
|
3988
4064
|
navigationProcessor(),
|
|
3989
4065
|
nunjucksProcessor({
|
|
@@ -4059,5 +4135,5 @@ class Generator {
|
|
|
4059
4135
|
}
|
|
4060
4136
|
}
|
|
4061
4137
|
|
|
4062
|
-
export { Generator, apiExtractorProcessor, availableProcessors, cookieProcessor, defineSources, extractExamplesProcessor, frontMatterFileReader, htmlRedirectProcessor, isRelease, livereloadProcessor, manifestProcessor, matomoProcessor, motdProcessor, navigationFileReader, playgroundProcessor, processorRuntimeName, redirectFileProcessor, searchProcessor, selectableVersionProcessor, sourceUrlProcessor, topnavProcessor, versionBannerProcessor, versionProcessor, vueFileReader };
|
|
4138
|
+
export { Generator, apiExtractorProcessor, availableProcessors, cookieProcessor, defineSources, extractExamplesProcessor, frontMatterFileReader, htmlRedirectProcessor, isRelease, livereloadProcessor, manifestProcessor, matomoProcessor, motdProcessor, navigationFileReader, partialFileReader, playgroundProcessor, processorRuntimeName, redirectFileProcessor, searchProcessor, selectableVersionProcessor, sourceUrlProcessor, topnavProcessor, versionBannerProcessor, versionProcessor, vueFileReader };
|
|
4063
4139
|
//# sourceMappingURL=index.mjs.map
|