From 07575f872a0267e213faaef9d3181dcf675270fd Mon Sep 17 00:00:00 2001 From: "vault-token-factory-spectrocloud[bot]" <133815545+vault-token-factory-spectrocloud[bot]@users.noreply.github.com> Date: Tue, 9 Jul 2024 20:30:01 +0000 Subject: [PATCH] docs: partial fixes DOC-1263 (#3253) (#3315) * docs: partial fixes DOC-1263 * docs: remove debug line DOC-1263 (cherry picked from commit 709e0181430ecde3f36b9995ca72b4cb0e5bab50) Co-authored-by: Adelina Simion <43963729+addetz@users.noreply.github.com> --- README.md | 14 +++++++++++--- scripts/generate-partials.sh | 10 ++++++---- .../PartialsComponent/PartialsComponent.tsx | 5 +++-- src/components/SimpleCardGrid/SimpleCardGrid.tsx | 1 - 4 files changed, 20 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index a277ac49c8..26f4f39dde 100644 --- a/README.md +++ b/README.md @@ -626,8 +626,16 @@ To add tutorials to an existing category, create a new **.md** file in the respe ## Partials Component -This is a custom component that allows you to create and use -[Import Markdown](https://docusaurus.io/docs/3.2.1/markdown-features/react#importing-markdown). +This is a custom component that allows you to create and use Docusaurus' +[Import Markdown](https://docusaurus.io/docs/markdown-features/react#importing-markdown) functionality. + +> [!IMPORTANT] +> Docusaurus does not provide the ability to dynamically configure table of contents. See +> [this issue](https://github.com/facebook/docusaurus/issues/6201) for more information. This means that you should +> avoid adding headings to partials that you intend to use with the Partials Component. +> +> If you require headings, then you should import your partials using the guidance on the Docusaurus +> [Import Markdown](https://docusaurus.io/docs/markdown-features/react#importing-markdown) page. Partials must be created under the `_partials` folder. They must be named using an `_` prefix and the `*.mdx` filetype. Partials may be organised in any further subfolders as required. For example, you could create @@ -679,7 +687,7 @@ partial_name: palette-setup This is how you set up Palette in {props.cloud}. -This is an . +This is a `. ``` The path of the link should be the path of the destination file from the root directory, without any back operators diff --git a/scripts/generate-partials.sh b/scripts/generate-partials.sh index 12968d7c84..cde57353d1 100755 --- a/scripts/generate-partials.sh +++ b/scripts/generate-partials.sh @@ -15,16 +15,18 @@ touch _partials/index.ts # Make the versioned partials folder to satisfy compiler. mkdir -p versioned_partials +# Make _partials the current working directory. All paths will be relative to it now. +cd _partials + # Create the file and add the generated warning. -echo "// This file is generated. DO NOT EDIT!" >> _partials/index.ts +echo "// This file is generated. DO NOT EDIT!" >> index.ts # Find all the MDX files recursively in the _partials folder. # Loop through each file. -find _partials -name "*.mdx" -print0 | while read -d $'\0' path +find . -name "*.mdx" -print0 | while read -d $'\0' path do module_name=$(basename ${path} .mdx | tr -d '_' | tr -d '-') - file_name=$(basename ${path}) - echo "export * as ${module_name}${RANDOM} from './${file_name}';" >> _partials/index.ts + echo "export * as ${module_name}${RANDOM} from '${path}';" >> index.ts done echo "Completed generation of _partials/index.ts." diff --git a/src/components/PartialsComponent/PartialsComponent.tsx b/src/components/PartialsComponent/PartialsComponent.tsx index 5e344ca134..55fa1d6136 100644 --- a/src/components/PartialsComponent/PartialsComponent.tsx +++ b/src/components/PartialsComponent/PartialsComponent.tsx @@ -20,7 +20,8 @@ export default function PartialsComponent(details: ComponentProperties): React.R // Construct the map key including the version const mapKey = getMapKey(ver, details.category, details.name); - if (!AllPartials[mapKey]) { + const foundPartial = AllPartials[mapKey]; + if (!foundPartial) { throw new Error( "No partial found for name " .concat(details.name) @@ -42,7 +43,7 @@ export default function PartialsComponent(details: ComponentProperties): React.R propAttribute[key] = details[key]; } - return React.createElement(AllPartials[mapKey], propAttribute); + return React.createElement(foundPartial, propAttribute); } function getMapKey(ver: string, category: string, name: string): string { diff --git a/src/components/SimpleCardGrid/SimpleCardGrid.tsx b/src/components/SimpleCardGrid/SimpleCardGrid.tsx index 9dad379038..8c77cee138 100644 --- a/src/components/SimpleCardGrid/SimpleCardGrid.tsx +++ b/src/components/SimpleCardGrid/SimpleCardGrid.tsx @@ -41,7 +41,6 @@ export default function SimpleCardGrid({ cards = [], hideNumber = false }: Simpl } function SimpleCard({ title, index, description, buttonText, relativeURL, hideNumber }: SimpleCard) { - console.log(hideNumber); return (