@forsakringskassan/docs-generator 3.7.0 → 3.8.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.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,
@@ -2856,6 +2896,12 @@ var translation$1 = {
2856
2896
  instructions: "<kbd>Esc</kbd> to close <kbd>Arrow up/down</kbd> to navigate <kbd>Enter</kbd> to select",
2857
2897
  title: "Search",
2858
2898
  placeholder: "Type to begin searching"
2899
+ },
2900
+ "mobile-nav": {
2901
+ close: "Close",
2902
+ menu: "Menu",
2903
+ "aria-label": "Open/close menu",
2904
+ nav: "Mobile primary"
2859
2905
  }
2860
2906
  };
2861
2907
  var langEn = {
@@ -2890,51 +2936,18 @@ var translation = {
2890
2936
  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
2937
  title: "Sök",
2892
2938
  placeholder: "Skriv för att börja söka"
2939
+ },
2940
+ "mobile-nav": {
2941
+ close: "Stäng",
2942
+ menu: "Meny",
2943
+ "aria-label": "Öppen/stängd meny",
2944
+ nav: "Mobile primär"
2893
2945
  }
2894
2946
  };
2895
2947
  var langSv = {
2896
2948
  translation: translation
2897
2949
  };
2898
2950
 
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
2951
  const templateUrl = new URL("../templates", import.meta.url);
2939
2952
  const templateDirectory = fileURLToPath(templateUrl);
2940
2953