@@ -47,14 +47,15 @@ mkdir "$TEMP/content/docs/docs"
4747for path in .nav.yml bookstore client concepts eventing functions getting-started install reference samples serving; do
4848 mv " $TEMP /content/docs/$path " " $TEMP /content/docs/docs/$path "
4949done
50+ echo " " >> " $TEMP /content/docs/docs/README.md" # Placeholder to ensure sitemap entry (for versioning)
5051echo " docs/README.md: docs/concepts/README.md" >> " $TEMP /content/config/redirects.yml"
5152# Copy images for now, until we clean up the above:
5253cp -r " $TEMP /content/docs/images" " $TEMP /content/docs/docs/images"
5354
5455# Point top-level nav to docs directory.
5556echo -e " nav:\n- docs\n- about\n- blog\n- community" > " $TEMP /content/docs/.nav.yml"
5657# We use samples_branch to flag that the documentation is versioned
57- echo -e " \n\nsamples_branch: main" >> " $TEMP /content/docs/docs/.meta.yml"
58+ echo -e " \n\nsamples_branch: main\nversion: development " >> " $TEMP /content/docs/docs/.meta.yml"
5859curl -f -L --show-error https://raw.githubusercontent.com/knative/serving/main/docs/serving-api.md -s > " $TEMP /content/docs/docs/serving/reference/serving-api.md"
5960curl -f -L --show-error https://raw.githubusercontent.com/knative/eventing/main/docs/eventing-api.md -s > " $TEMP /content/docs/docs/eventing/reference/eventing-api.md"
6061versionjson=" {\" version\" : \" docs\" , \" title\" : \" (Pre-release)\" , \" aliases\" : [\"\" ]}"
@@ -64,9 +65,15 @@ BUILD_VERSIONS="yes"
6465
6566if [ " $BUILD_VERSIONS " != " no" ]; then
6667 mv $TEMP /content/docs/docs $TEMP /content/docs/development
68+ # Remove pre-release documents from search. This has to be applied to each markdown, unfortunately.
69+ # This needs to be done as two commands: the first ensures front-matter in files that don't have it,
70+ # and the seconds inserts commands into the front-matter.
71+ find " $TEMP /content/docs/development" -type f -name ' *.md' | xargs sed -i ' 1s/^\([^-]\)/---\n---\n\1/'
72+ find " $TEMP /content/docs/development" -type f -name ' *.md' | xargs sed -i ' 2isearch:\n exclude: true'
73+
6774 echo " - Docs: development" >> " $TEMP /content/docs/.nav.yml"
6875 echo " development/README.md: development/concepts/README.md" >> " $TEMP /content/config/redirects.yml"
69- versionjson=" {\" version\" : \" docs\" , \" title\" : \" v$latest \" , \" aliases\" : [\"\" ]}," # Clear existing content, we'll add development at the _end_.
76+ versionjson=" {\" version\" : \" docs\" , \" title\" : \" v$latest \" , \" aliases\" : [\" v $latest \" ]}," # Clear existing content, we'll add development at the _end_.
7077
7178 # Handle current release specially, as we don't include a version slug
7279 # TODO: can we make one clone and reuse it, possibly with git worktrees?
@@ -82,12 +89,12 @@ if [ "$BUILD_VERSIONS" != "no" ]; then
8289 # Smoketests were written for Hugo, not mkdocs, so remove
8390 rm " $TEMP /content/docs/docs/smoketest.md"
8491 # Fill in meta content for macros.py
85- echo -e " \n\nknative_version: ${VERSIONS[0] } .0\nsamples_branch: ${DOCS_BRANCHES[0]} " >> " $TEMP /content/docs/docs/.meta.yml"
92+ echo -e " \n\nknative_version: ${latest } .0\nsamples_branch: ${DOCS_BRANCHES[0]} \nversion: v ${latest }" >> " $TEMP /content/docs/docs/.meta.yml"
8693
8794
8895 for i in " ${! previous[@]} " ; do
8996 version=${previous[$i]}
90- versionjson+=" {\" version\" : \" v$version -docs\" , \" title\" : \" v$version \" , \" aliases\" : [\"\" ]},"
97+ versionjson+=" {\" version\" : \" v$version -docs\" , \" title\" : \" v$version \" , \" aliases\" : [\" v $version \" ]},"
9198
9299 echo " Building for previous version $version "
93100 git clone --depth 1 -b ${DOCS_BRANCHES[$i+1]} https://github.com/${GIT_SLUG} " $TEMP /docs-$version "
@@ -104,7 +111,12 @@ if [ "$BUILD_VERSIONS" != "no" ]; then
104111 sed ' /- Blog:/,$d' " $TEMP /docs-$version /config/nav.yml" >> " $TEMP /content/docs/v$version -docs/.nav.yml"
105112 fi
106113 # Fill in meta content for macros.py
107- echo -e " \n\nknative_version: ${VERSIONS[i+1]} .0\nsamples_branch: ${DOCS_BRANCHES[i+1]} \nversion_warning: true" >> " $TEMP /content/docs/v$version -docs/.meta.yml"
114+ echo -e " \n\nknative_version: ${version} .0\nsamples_branch: ${DOCS_BRANCHES[i+1]} \nversion_warning: true\nversion: v${version} " >> " $TEMP /content/docs/v$version -docs/.meta.yml"
115+ # Remove older-version documents from search. This has to be applied to each markdown, unfortunately.
116+ # This needs to be done as two commands: the first ensures front-matter in files that don't have it,
117+ # and the seconds inserts commands into the front-matter.
118+ find " $TEMP /content/docs/v$version -docs" -type f -name ' *.md' | xargs sed -i ' 1s/^\([^-]\)/---\n---\n\1/'
119+ find " $TEMP /content/docs/v$version -docs" -type f -name ' *.md' | xargs sed -i ' 2isearch:\n exclude: true'
108120 done
109121
110122 # Put the development version at the end of the JSON list of documentation,
0 commit comments