From 99a54a27c2393063a0139ee378cae180c7f38306 Mon Sep 17 00:00:00 2001 From: "jonas-lt@live.dk" Date: Wed, 4 Oct 2023 22:33:13 +0200 Subject: [PATCH 1/2] fix links --- modelina-website/src/components/docs/Docs.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modelina-website/src/components/docs/Docs.tsx b/modelina-website/src/components/docs/Docs.tsx index a81d9abd9e..67808b1900 100644 --- a/modelina-website/src/components/docs/Docs.tsx +++ b/modelina-website/src/components/docs/Docs.tsx @@ -8,7 +8,6 @@ import CodeBlock from '../CodeBlock'; import rehypeRaw from 'rehype-raw'; import GithubButton from '../buttons/GithubButton'; - interface WithRouterProps { router: NextRouter; } @@ -57,6 +56,7 @@ class Docs extends React.Component< render() { let { showMenu } = this.state; const menuItems = this.renderMenuTree(DocsList.tree, true); + const item = (DocsList.unwrapped as any)[this.props.slug]; return (
@@ -130,7 +130,7 @@ class Docs extends React.Component<
From f76ec9e237189dbe0255f653e1058dd38f93eb88 Mon Sep 17 00:00:00 2001 From: "jonas-lt@live.dk" Date: Wed, 4 Oct 2023 23:39:55 +0200 Subject: [PATCH 2/2] various fixes to docs rendering --- docs/README.md | 2 +- modelina-website/scripts/build-docs.js | 6 ++++-- modelina-website/src/components/docs/Docs.tsx | 12 ++++++++---- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/docs/README.md b/docs/README.md index 30cbc85a77..83b34f3286 100644 --- a/docs/README.md +++ b/docs/README.md @@ -48,7 +48,7 @@ Details which different generator options are supported. ### [Presets](./presets.md) Goes more in-depth into how the preset system works, which enables full customization of generators. -### [Interpretation of JSON Schema](./inputs/json-schema.md) +### [Interpretation of JSON Schema](./inputs/json_schema.md) Explains how a JSON Schema is interpreted to a data model. ### [Migration](./migrations/README.md) diff --git a/modelina-website/scripts/build-docs.js b/modelina-website/scripts/build-docs.js index 16f72ae93f..c434dcea43 100644 --- a/modelina-website/scripts/build-docs.js +++ b/modelina-website/scripts/build-docs.js @@ -43,13 +43,14 @@ async function buildDocsTree(rootPath) { if (!fileStat.isDirectory()) { //Ignore non-markdown and README files if(rootPath.endsWith('.md') && !rootPath.includes('README')) { + const relativeRootPath = rootPath.split(MODELINA_ROOT_PATH)[1]; let title = path.basename(rootPath, '.md'); title = title.replace(/_/g, ' '); title = title.replace(/-/g, ' '); title = title.charAt(0).toUpperCase() + title.slice(1); let content = await readFile(rootPath, "utf8"); content = prepareContent(content); - return {type: 'file', fullPath: rootPath, slug: slug.split('.md')[0], title, content}; + return {type: 'file', fullPath: rootPath, relativeRootPath: relativeRootPath, slug: slug.split('.md')[0], title, content}; } return undefined; } @@ -85,8 +86,9 @@ async function buildDocsTree(rootPath) { if(tree !== undefined) subPaths.push(tree); } const folderName = path.basename(rootPath); + const relativeRootPath = rootPath.split(MODELINA_ROOT_PATH)[1] + '/README.md'; const pascalFolderName = folderName.replace(/(\w)(\w*)/g, function(g0,g1,g2){return g1.toUpperCase() + g2.toLowerCase();}); - return {type: 'dir', fullPath: rootPath, title: pascalFolderName, slug, subPaths, content: readmeContent}; + return {type: 'dir', fullPath: rootPath, relativeRootPath: relativeRootPath, title: pascalFolderName, slug, subPaths, content: readmeContent}; } function unwrapTree(tree) { diff --git a/modelina-website/src/components/docs/Docs.tsx b/modelina-website/src/components/docs/Docs.tsx index 67808b1900..90e8320d0c 100644 --- a/modelina-website/src/components/docs/Docs.tsx +++ b/modelina-website/src/components/docs/Docs.tsx @@ -33,6 +33,9 @@ class Docs extends React.Component< this.renderMenuTree = this.renderMenuTree.bind(this); } + /** + * Render the menu items dynamically in a depth first approach + */ renderMenuTree(value: any, isRoot: boolean) { const isSelected = value.slug === `/docs/${this.props.slug}`; if(value.type === 'dir') { @@ -43,8 +46,8 @@ class Docs extends React.Component< } else { headerReadme =
  • {value.title}
  • ; } - return <>{headerReadme}
  • -
      + return <>{headerReadme}
    • +
        {isRoot &&
      • API Docs
      • } {value.subPaths.map((subPath: any) => this.renderMenuTree(subPath, false))}
      @@ -53,6 +56,7 @@ class Docs extends React.Component< return
    • { this.setState({ showMenu: false }) }}>{value.title}
    • ; } } + render() { let { showMenu } = this.state; const menuItems = this.renderMenuTree(DocsList.tree, true); @@ -102,7 +106,7 @@ class Docs extends React.Component<
  • @@ -130,7 +134,7 @@ class Docs extends React.Component<