From 0231823030919050fc9f5eafe2bbb13acfb4e8f3 Mon Sep 17 00:00:00 2001 From: "jonas-lt@live.dk" Date: Thu, 28 Sep 2023 22:30:38 +0200 Subject: [PATCH] fix remaining problems --- docs/README.md | 4 ++-- modelina-website/scripts/build-docs.js | 11 +++++++++-- modelina-website/src/components/docs/Docs.tsx | 10 ++++++++++ 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/docs/README.md b/docs/README.md index 7c999b791f..30cbc85a77 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) @@ -59,7 +59,7 @@ Contains specific information about the differences between a lot of other commo ### [API Documentation](https://modelina.org/apidocs) -No one wants to read the code to find information about it, instead use the [/docs/api](https://modelina.org/docs/api) page on the website to find what you are looking for! +No one wants to read the code to find information about it, instead use the [/apidocs](https://modelina.org/apidocs) page on the website to find what you are looking for! ### Languages Each language has its own limitations, corner cases, and features; thus, each language has separate documentation. diff --git a/modelina-website/scripts/build-docs.js b/modelina-website/scripts/build-docs.js index 8cc9c8df63..f4aa443778 100644 --- a/modelina-website/scripts/build-docs.js +++ b/modelina-website/scripts/build-docs.js @@ -10,6 +10,7 @@ function prepareContent(content) { content = content.replace('', ''); content = content.replace('', ''); content = content.replace(/\.md/g, ''); + content = content.replace(/README/g, ''); // Use correct example links content = content.replace(/\]\((.*?)examples\/(.*?)\/?\)/g, '](/examples?selectedExample=$2)'); @@ -36,8 +37,8 @@ async function buildDocsTree(rootPath) { //Ignore non-markdown and README files if(rootPath.endsWith('.md') && !rootPath.includes('README')) { let title = path.basename(rootPath, '.md'); - title = title.replaceAll('-', ' '); - title = title.replaceAll('_', ' '); + 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); @@ -52,10 +53,16 @@ async function buildDocsTree(rootPath) { //Check if directory has main README file and use it's content try{ const dirRootReadmePath = path.resolve(rootPath, './README.md'); + const isRootReadme = path.resolve(__dirname, '../../docs') === rootPath; let readmeFileStat = await stat(dirRootReadmePath); if(readmeFileStat.isFile()){ readmeContent = await readFile(dirRootReadmePath, "utf8"); readmeContent = prepareContent(readmeContent); + + if(isRootReadme) { + // Replace relative references (./some-ref.md) to absolute refs (/docs/some-ref) + readmeContent = readmeContent.replace(/\]\(\.\/(.*?)\)/g, '](/docs/$1)'); + } } } catch(e) {} diff --git a/modelina-website/src/components/docs/Docs.tsx b/modelina-website/src/components/docs/Docs.tsx index d9bd72383b..01deed1817 100644 --- a/modelina-website/src/components/docs/Docs.tsx +++ b/modelina-website/src/components/docs/Docs.tsx @@ -6,6 +6,7 @@ import rehypeSlug from "rehype-slug"; import remarkGfm from "remark-gfm"; import CodeBlock from '../CodeBlock'; import rehypeRaw from 'rehype-raw'; +import GithubButton from '../buttons/GithubButton'; interface WithRouterProps { @@ -46,6 +47,7 @@ class Docs extends React.Component< return <>{headerReadme}
  • ; } else { @@ -124,6 +126,14 @@ class Docs extends React.Component<
    + +
    + +