Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-node-resolve": "^13.3.0",
"@types/unist": "^2.0.6",
"@webdoky/yari-ports": "^3.8.1",
"@webdoky/yari-ports": "^3.17.1",
"acorn-import-assertions": "^1.8.0",
"cyrillic-to-translit-js": "^3.2.1",
"github-slugger": "^1.4.0",
Expand All @@ -52,6 +52,7 @@
"lodash-es": "^4.17.21",
"mdast-util-to-hast": "^12.1.1",
"mdast-util-to-string": "^3.1.0",
"mdn-data": "^2.4.0",
"prism-themes": "^1.9.0",
"rehype-autolink-headings": "^6.1.1",
"rehype-external-links": "^1.0.1",
Expand Down
14 changes: 11 additions & 3 deletions src/registry/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,11 @@ enum MetaMacros {
cssref = 'cssref',
jsref = 'jsref',
jssidebar = 'jssidebar',
glossarysidebar = 'glossarysidebar',
htmlsidebar = 'htmlsidebar',
svgref = 'svgref',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the output of meta macros goes separately from other content. So, first:

  • all sidebars should go to meta macros, otherwise they'll output directly into the page and it won't end up well.
  • there also changes to be made on platform, because it also recognizes only a certain subset of macros

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, yes: your change is absolutely necessary here, and also it's no sufficient to get the structure displayed on UI

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No worries, I debugged everything in https://github.com/webdoky/platform-next, just wasn't always sure I know what I'm doing

listsubpagesforsidebar = 'listsubpagesforsidebar',
listsubpages = 'listsubpages',
}

interface SidebarNavLink {
Expand Down Expand Up @@ -198,9 +203,12 @@ class Registry {
(slugKey) => slugKey.startsWith(slug) && slugKey !== slug,
);
if (!includeNested) {
childrenSlugs = childrenSlugs.filter(
(childSlug) => !trimSlashes(childSlug.split(slug).at(-1)).includes('/'),
);
childrenSlugs = childrenSlugs.filter((childSlug) => {
const childSlugWithoutParent = trimSlashes(
childSlug.substring(slug.length + 1),
);
return !childSlugWithoutParent.includes('/');
});
}
return childrenSlugs.map((slugKey) => this.getPageBySlug(slugKey));
}
Expand Down
11 changes: 10 additions & 1 deletion src/registry/macros-runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,16 @@ import { ExpungedMacroInsert } from '../components';
const { macros: Macros, parseMacroArgs, extractMacros } = kuma;

// List of macros that should be processed anyway, i.e for rendering navigation
const navigationalMacros = ['cssref', 'jssidebar', 'jsref', 'htmlref'];
const navigationalMacros = [
'cssref',
'jssidebar',
'jsref',
'glossarysidebar',
'htmlsidebar',
'svgref',
'listsubpagesforsidebar',
'listsubpages',
];

const UNESCAPED_BACKTICK_MATCH = /([^\\])`/g;
const UNESCAPED_SINGLE_QUOTE_MATCH = /([^\\])'/g;
Expand Down
14 changes: 9 additions & 5 deletions src/registry/utils/walk.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import { promises as fs } from 'fs';
import path from 'path';

const walk = async (dirname, deep = true) => {
export default async function walk(
dirname: string,
deep = true,
): Promise<string[]> {
const list = await fs.readdir(dirname);
let files = [];

Expand All @@ -11,17 +14,18 @@ const walk = async (dirname, deep = true) => {

if (fileStat && fileStat.isDirectory()) {
if (deep) {
const innerList = await walk(resolvedFile);
const innerList = await walk(resolvedFile, deep);
files = files.concat(innerList);
}
} else {
if (fileName !== 'index.md') {
return;
}
files.push(resolvedFile);
}
});

await Promise.all(operations);

return files;
};

export default walk;
}
13 changes: 9 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1130,10 +1130,10 @@
resolved "https://registry.yarnpkg.com/@use-it/interval/-/interval-1.0.0.tgz#c42c68f22ca29a0dc929041746373d94496d2b3a"
integrity sha512-WQFcnSt/xM/mS8ZtJ0ut5lhPrl+V0HDPPcI/J0eUClsfiD+/r8A7IeW/pVcfpSVGWRmN3+WnjNteWuKyWs2WZg==

"@webdoky/yari-ports@^3.8.1":
version "3.8.1"
resolved "https://registry.yarnpkg.com/@webdoky/yari-ports/-/yari-ports-3.8.1.tgz#1150503dbd70629d7e2c638a9d13b11c676e5b46"
integrity sha512-2rk7qoP94RUGo9mX4SZ7N48su6Nbwy8DuwD6jkIUou7bEFBVeCDmRznidpukccvE9V9mX5J9KuFuUlnb66pL7g==
"@webdoky/yari-ports@^3.17.1":
version "3.17.1"
resolved "https://registry.yarnpkg.com/@webdoky/yari-ports/-/yari-ports-3.17.1.tgz#d8bc7a49d6fd31ba9216bf29419921199c619e21"
integrity sha512-kBac8XjI+iNGzN/GVsbiOyHuN+ImC8+qFa04K4L25xen/llKFOYTrCBRTjNus3f5B8tsdmtHvyMiX1blVgrr3w==
dependencies:
"@mdn/browser-compat-data" "^4.1.2"
"@mdn/yari" "^1.7.0"
Expand Down Expand Up @@ -5829,6 +5829,11 @@ mdn-data@2.0.27, mdn-data@^2.0.26, mdn-data@^2.0.27:
resolved "https://registry.yarnpkg.com/mdn-data/-/mdn-data-2.0.27.tgz#1710baa7b0db8176d3b3d565ccb7915fc69525ab"
integrity sha512-kwqO0I0jtWr25KcfLm9pia8vLZ8qoAKhWZuZMbneJq3jjBD3gl5nZs8l8Tu3ZBlBAHVQtDur9rdDGyvtfVraHQ==

mdn-data@^2.4.0:
version "2.4.0"
resolved "https://registry.yarnpkg.com/mdn-data/-/mdn-data-2.4.0.tgz#e78cdea15ddf9841c4de44b604ebefa0bce2978a"
integrity sha512-AB4NUFtlTkd4rhr73ocuerhDkpe71kr0VpFLwoYuALjYo8XBrGcBJFgqHADjPHj7Ux50bg+SyLEt6mcodrafzw==

mdurl@^1.0.0:
version "1.0.1"
resolved "https://registry.yarnpkg.com/mdurl/-/mdurl-1.0.1.tgz#fe85b2ec75a59037f2adfec100fd6c601761152e"
Expand Down