diff --git a/hack/.templates/jsonschemaforhumans/base.md b/hack/.templates/jsonschemaforhumans/base.md index 3eedb82c45..8c2af4a17e 100644 --- a/hack/.templates/jsonschemaforhumans/base.md +++ b/hack/.templates/jsonschemaforhumans/base.md @@ -1,4 +1,9 @@ -{{ schema.keywords.get("title").literal | default("Zarf Package Schema") | md_heading(0) }} +--- +title: {{ schema.keywords.get("title").literal | default("Zarf Package Schema") }} +weight: 4 +type: docs +--- + {% set contentBase %} {% with schema=schema, skip_headers=False %} {% include "content.md" %} diff --git a/hack/gen-cli-docs.sh b/hack/gen-cli-docs.sh index 59f8201635..41316f9f76 100755 --- a/hack/gen-cli-docs.sh +++ b/hack/gen-cli-docs.sh @@ -2,19 +2,25 @@ printf "Generating CLI docs\n" ZARF_CONFIG=hack/empty-config.toml go run main.go internal gen-cli-docs -# Create the top menu label for the sidebar menu -printf "Generating sidebar menu label\n" -MENU_LABEL='{"label": "CLI Commands"}\n' -printf "${MENU_LABEL}" > docs/2-the-zarf-cli/100-cli-commands/_category_.json +BUILT_BY="" +SEPERATOR="---" +TYPE="type: docs" # The GenMarkdownTree function from cobra/docs starts the headers at H2. -# This breaks the sidebar menu naming for Docusaurus. This command drops -# all headers by 1 level to fix the menu. -printf "Updating section header levels\n" +# This converts the H2 to Hugo frontmatter and reduces all other headers by one level. + +printf "Creating frontmatter from auto-generated title\n" for FILE in $(find docs/2-the-zarf-cli/100-cli-commands -name "*.md") do + sed -i.bak "1s/^/${SEPERATOR}\n/" ${FILE} + sed -i.bak "s/^## \(.*\)/title: \1\n${TYPE}\n---\n\n${BUILT_BY}\n/" ${FILE} sed -i.bak 's/^##/#/g' ${FILE} - sed -i.bak '2s/^/\n/' ${FILE} truncate -s -1 ${FILE} rm ${FILE}.bak done + +# Create the top menu label for the sidebar menu +printf "Generating sidebar menu label\n" +MENU_LABEL='title: CLI Commands' +printf "%s\n%s\ntype: docs\n%s\n\n%s\n" "${SEPERATOR}" "${MENU_LABEL}" "${SEPERATOR}" "${BUILT_BY}" > docs/2-the-zarf-cli/100-cli-commands/_index.md +