Skip to content

Commit

Permalink
docs: partial fixes DOC-1263 (#3253) (#3313)
Browse files Browse the repository at this point in the history
* docs: partial fixes DOC-1263

* docs: remove debug line DOC-1263

(cherry picked from commit 709e018)

Co-authored-by: Adelina Simion <43963729+addetz@users.noreply.github.com>
  • Loading branch information
1 parent 13c2150 commit 3558f11
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 10 deletions.
14 changes: 11 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -602,8 +602,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
Expand Down Expand Up @@ -655,7 +663,7 @@ partial_name: palette-setup
This is how you set up Palette in {props.cloud}.
This is an <VersionedLink name="Internal Link" url="/getting-started/additional-capabilities"/>.
This is a <VersionedLink text="Internal Link" url="/getting-started/additional-capabilities"/>`.
```
The path of the link should be the path of the destination file from the root directory, without any back operators
Expand Down
10 changes: 6 additions & 4 deletions scripts/generate-partials.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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."
5 changes: 3 additions & 2 deletions src/components/PartialsComponent/PartialsComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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 {
Expand Down
1 change: 0 additions & 1 deletion src/components/SimpleCardGrid/SimpleCardGrid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<a href={relativeURL}>
<div className={styles.simpleCard}>
Expand Down

0 comments on commit 3558f11

Please sign in to comment.