Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[version-4-0] docs: partial fixes DOC-1263 (#3253) #3311

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading