Skip to content

Commit c1e5eab

Browse files
committed
Update url structure
Signed-off-by: rohan-019 <[email protected]>
1 parent 1cc1ca0 commit c1e5eab

File tree

2 files changed

+115
-56
lines changed

2 files changed

+115
-56
lines changed

hack/build.sh

Lines changed: 33 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -41,55 +41,45 @@ readonly SITE=$PWD/site
4141
rm -rf site/
4242

4343
if [ "$BUILD_VERSIONS" == "no" ]; then
44-
# HEAD to root if we're not doing versioning.
44+
# Build to root if we're not doing versioning
4545
mkdocs build -f mkdocs.yml -d site
4646
else
47-
# Versioning: pre-release (HEAD): docs => development/
48-
cp -r . $TEMP/docs-main
47+
# Build latest version to /docs
48+
cp -r . "$TEMP/docs-main"
4949
curl -f -L --show-error https://raw.githubusercontent.com/knative/serving/main/docs/serving-api.md -s > "$TEMP/docs-main/docs/serving/reference/serving-api.md"
5050
curl -f -L --show-error https://raw.githubusercontent.com/knative/eventing/main/docs/eventing-api.md -s > "$TEMP/docs-main/docs/eventing/reference/eventing-api.md"
51-
pushd "$TEMP/docs-main"; mkdocs build -f mkdocs.yml -d $SITE/development; popd
52-
53-
# Latest release branch to root
54-
git clone --depth 1 -b ${DOCS_BRANCHES[0]} https://github.com/${GIT_SLUG} "$TEMP/docs-$latest"
55-
56-
if [ ${latest#*1.} -gt 6 ]; then
57-
curl -f -L --show-error https://raw.githubusercontent.com/knative/serving/${DOCS_BRANCHES[0]}/docs/serving-api.md -s > "$TEMP/docs-$latest/docs/serving/reference/serving-api.md"
58-
curl -f -L --show-error https://raw.githubusercontent.com/knative/eventing/${DOCS_BRANCHES[0]}/docs/eventing-api.md -s > "$TEMP/docs-$latest/docs/eventing/reference/eventing-api.md"
59-
else
60-
curl -f -L --show-error https://raw.githubusercontent.com/knative/serving/${DOCS_BRANCHES[0]}/docs/serving-api.md -s > "$TEMP/docs-$latest/docs/reference/api/serving-api.md"
61-
curl -f -L --show-error https://raw.githubusercontent.com/knative/eventing/${DOCS_BRANCHES[0]}/docs/eventing-api.md -s > "$TEMP/docs-$latest/docs/reference/api/eventing-api.md"
62-
fi
63-
64-
pushd "$TEMP/docs-$latest"; KNATIVE_VERSION="${VERSIONS[0]}.0" SAMPLES_BRANCH="${DOCS_BRANCHES[0]}" mkdocs build -d $SITE; popd
65-
66-
# Previous release branches release-$version to /v$version-docs
67-
versionjson=""
51+
52+
# Create docs directory structure
53+
mkdir -p "$SITE/docs"
54+
55+
# Build latest docs to /docs
56+
pushd "$TEMP/docs-main"
57+
KNATIVE_VERSION="${VERSIONS[0]}.0" SAMPLES_BRANCH="${DOCS_BRANCHES[0]}" mkdocs build -d "$SITE/docs"
58+
popd
59+
60+
# Build versioned docs to /vX.Y-docs/
6861
for i in "${!previous[@]}"; do
69-
version=${previous[$i]}
70-
versionjson+="{\"version\": \"v$version-docs\", \"title\": \"v$version\", \"aliases\": [\"\"]},"
71-
72-
echo "Building for previous version $version"
73-
git clone --depth 1 -b ${DOCS_BRANCHES[$i+1]} https://github.com/${GIT_SLUG} "$TEMP/docs-$version"
74-
if [ ${version#*1.} -gt 6 ]; then
75-
curl -f -L --show-error https://raw.githubusercontent.com/knative/serving/${DOCS_BRANCHES[i+1]}/docs/serving-api.md -s > "$TEMP/docs-$version/docs/serving/reference/serving-api.md"
76-
curl -f -L --show-error https://raw.githubusercontent.com/knative/eventing/${DOCS_BRANCHES[i+1]}/docs/eventing-api.md -s > "$TEMP/docs-$version/docs/eventing/reference/eventing-api.md"
77-
else
78-
curl -f -L --show-error https://raw.githubusercontent.com/knative/serving/${DOCS_BRANCHES[i+1]}/docs/serving-api.md -s > "$TEMP/docs-$version/docs/reference/api/serving-api.md"
79-
curl -f -L --show-error https://raw.githubusercontent.com/knative/eventing/${DOCS_BRANCHES[i+1]}/docs/eventing-api.md -s > "$TEMP/docs-$version/docs/reference/api/eventing-api.md"
80-
fi
81-
pushd "$TEMP/docs-$version"; KNATIVE_VERSION="${VERSIONS[i+1]}.0" SAMPLES_BRANCH="${DOCS_BRANCHES[i+1]}" VERSION_WARNING=true mkdocs build -d "$SITE/v$version-docs"; popd
82-
62+
version="${previous[$i]}"
63+
branch="${DOCS_BRANCHES[$((i+1))]}"
64+
65+
git clone --depth 1 -b "$branch" "https://github.com/$GIT_SLUG" "$TEMP/docs-$version"
66+
67+
# Copy non-versioned content from main branch
68+
mkdir -p "$TEMP/docs-$version/docs/about"
69+
cp -r "$TEMP/docs-main/docs/about" "$TEMP/docs-$version/docs/"
70+
mkdir -p "$TEMP/docs-$version/docs/community"
71+
cp -r "$TEMP/docs-main/docs/community" "$TEMP/docs-$version/docs/"
72+
73+
pushd "$TEMP/docs-$version"
74+
KNATIVE_VERSION="$version.0" SAMPLES_BRANCH="$branch" mkdocs build -d "$SITE/v$version-docs"
75+
popd
8376
done
84-
85-
# Set up the version file to point to the built docs.
86-
cat << EOF > $SITE/versions.json
87-
[
88-
{"version": "docs", "title": "v$latest", "aliases": [""]},
89-
$versionjson
90-
{"version": "development", "title": "(Pre-release)", "aliases": [""]}
91-
]
92-
EOF
77+
78+
# Move non-versioned content to /docs
79+
mkdir -p "$SITE/docs/about"
80+
cp -r "$TEMP/docs-main/docs/about" "$SITE/docs/"
81+
mkdir -p "$SITE/docs/community"
82+
cp -r "$TEMP/docs-main/docs/community" "$SITE/docs/"
9383
fi
9484

9585
# Create the blog

netlify.toml

Lines changed: 82 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
# Settings in the [build] context are global and are applied to all contexts
22
# unless otherwise overridden by more specific contexts.
33
[build]
4-
command = "./hack/build.sh"
4+
command = "hack/build.sh"
55
publish = "site"
66

77
[build.environment]
8-
NODE_VERSION= "14"
9-
PYTHON_VERSION = "3.8"
8+
PYTHON_VERSION = "3.9"
9+
NODE_VERSION = "16"
10+
NPM_VERSION = "8.5.5"
1011

1112
# Deploy Preview context: all deploys generated from a pull/merge request will
1213
# inherit these settings.
@@ -17,29 +18,97 @@
1718
[context.deploy-preview.environment]
1819
BUILD_VERSIONS="no"
1920

21+
# Handle versioned docs
2022
[[redirects]]
21-
from = "/contributing/"
23+
from = "/v:version-docs/*"
24+
to = "/v:version-docs/:splat"
25+
status = 200
26+
27+
# Redirect old versioned docs to new paths
28+
[[redirects]]
29+
from = "/docs-:version/*"
30+
to = "/v:version-docs/:splat"
31+
status = 301
32+
33+
# Redirect root to /docs for the latest version
34+
[[redirects]]
35+
from = "/"
36+
to = "/docs"
37+
status = 200
38+
39+
# Handle /docs paths
40+
[[redirects]]
41+
from = "/docs"
42+
to = "/docs/"
43+
status = 301
44+
45+
[[redirects]]
46+
from = "/docs/*"
47+
to = "/docs/:splat"
48+
status = 200
49+
50+
# Handle old about and community URLs (root level to /docs/)
51+
[[redirects]]
52+
from = "/about"
53+
to = "/docs/about/"
54+
status = 301
55+
56+
[[redirects]]
57+
from = "/about/*"
58+
to = "/docs/about/:splat"
59+
status = 301
60+
61+
[[redirects]]
62+
from = "/community"
2263
to = "/docs/community/"
2364
status = 301
2465

2566
[[redirects]]
2667
from = "/community/*"
27-
to = "/docs/community/"
68+
to = "/docs/community/:splat"
2869
status = 301
2970

71+
# Handle blog URLs
3072
[[redirects]]
31-
from = "/docs/help/contributor/*"
32-
to = "https://github.com/knative/docs/blob/main/contribute-to-docs/README.md"
73+
from = "/blog/*"
74+
to = "/blog/:splat"
75+
status = 200
76+
77+
# Handle old development URLs
78+
[[redirects]]
79+
from = "/development/*"
80+
to = "/docs/:splat"
3381
status = 301
3482

35-
# Redirect from /docs/* to root to handle the base URL change
83+
# Handle old API reference URLs
3684
[[redirects]]
37-
from = "/docs/*"
38-
to = "/:splat"
85+
from = "/reference/api/*"
86+
to = "/docs/reference/api/:splat"
3987
status = 301
4088

41-
# Redirect old /docs path to root
89+
# Handle old serving and eventing reference URLs
4290
[[redirects]]
43-
from = "/docs"
44-
to = "/"
91+
from = "/serving/reference/*"
92+
to = "/docs/serving/reference/:splat"
93+
status = 301
94+
95+
[[redirects]]
96+
from = "/eventing/reference/*"
97+
to = "/docs/eventing/reference/:splat"
98+
status = 301
99+
100+
# Keep existing contributor redirects
101+
[[redirects]]
102+
from = "/contributing/"
103+
to = "/docs/community/"
104+
status = 301
105+
106+
[[redirects]]
107+
from = "/help/contributing/"
108+
to = "https://github.com/knative/docs/blob/main/contribute-to-docs/README.md"
109+
status = 301
110+
111+
[[redirects]]
112+
from = "/docs/help/contributor/*"
113+
to = "https://github.com/knative/docs/blob/main/contribute-to-docs/README.md"
45114
status = 301

0 commit comments

Comments
 (0)