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 a81d9abd9e..90e8320d0c 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; } @@ -34,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') { @@ -44,8 +46,8 @@ class Docs extends React.Component< } else { headerReadme =
  • {value.title}
  • ; } - return <>{headerReadme}
  • -