-
Notifications
You must be signed in to change notification settings - Fork 70
Revise build process to reduce amount of file moves and preparation #155
base: main
Are you sure you want to change the base?
Changes from all commits
611fd8e
828125c
4e90dfc
6c9b924
29af6cd
072a706
56e0e0e
192a8a1
c5f0138
757e242
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,5 @@ node_modules/ | |
public/ | ||
content/ | ||
resources/ | ||
docs/ | ||
.DS_Store |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,24 @@ | ||
<div class="td-content"> | ||
<h1>{{ .Title }}</h1> | ||
{{ with .Params.description }}<div class="lead">{{ . | markdownify }}</div>{{ end }} | ||
{{ .Content }} | ||
{{ $out := .Content}} | ||
{{ if not ( in (slice "README.md" "_index.md") .File.LogicalName ) }} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will this exclude hardcoded links to other non-Knative Repo's README.md files? Im not sure we still have or need to accommodate those links that point out to another Repo's README file today but maybe we should avoid changing those URLs if or when someone does add on in the future? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is determining if this file's name is "README.md" or "_index.md". But I've been adding "index.md" files, so I probably need to update this. Thanks for asking! |
||
<!-- non-README.md files will be rendered one level below normal, fix links in them --> | ||
{{ $out = $out | replaceRE "href=\"\\.\\./" "href=\"../../" }} | ||
{{ $out = $out | replaceRE "href=\"\\./" "href=\"../"}} | ||
{{ end }} | ||
<!-- For SEO and aesthetics purposes, clean up GitHub URLs; this is | ||
repeating the hugo "Pretty URLs" pattern on _relative_ links in the | ||
source material. | ||
|
||
The regexp ([^:\"]*(/[^\"]*)?) matches: | ||
- Zero or more non-: or " charaters (: is needed for an absolute URL) | ||
- Followed by a "/" and zero or more non " characters | ||
(which would end the href attribute) | ||
--> | ||
{{ $out = $out | replaceRE "href=\"([^:\"]*(/[^\"]*)?)\\.md\"" "href=\"$1\""}} | ||
{{ $out = $out | replaceRE "href=\"([^:\"]*(/[^\"]*)?)README\"" "href=\"$1\"" }} | ||
{{ $out | safeHTML}} | ||
{{ if (and (not .Params.hide_feedback) (.Site.Params.ui.feedback.enable) (.Site.GoogleAnalytics)) }} | ||
{{ partial "feedback.html" .Site.Params.ui.feedback }} | ||
<br /> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,25 +30,38 @@ then | |
mv content/en/docs content/en/development | ||
# DOCS BRANCHES | ||
echo '------ Cloning all docs releases ------' | ||
|
||
# TODO(Evan): Avoid the need for `mv` above and make the below just ap | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I had to use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I clone the docs outside of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nice. this then renders my concern below needless (content not in the publishing path wont get picked up automatically) |
||
# set of clone + symlink commands | ||
|
||
# Get versions of released docs from their branches in "$FORK"/docs | ||
echo 'The /docs/ section is built from the' "$BRANCH" 'branch of' "$FORK" | ||
# Latest version is defined in website/scripts/docs-version-settings.sh | ||
# If this is a PR build, then build that content as the latest release (assume PR preview builds are always from "latest") | ||
git clone --quiet -b "$BRANCH" https://github.com/"$FORK"/docs.git temp/release/latest | ||
# Only copy and keep the "docs" folder from all branched releases: | ||
mv temp/release/latest/docs content/en/docs | ||
echo 'Getting the archived docs releases from branches in:' "$FORK"'/docs' | ||
############################################################### | ||
# Template for next release: | ||
#git clone -b "release-[VERSION#]" https://github.com/"$FORK"/docs.git temp/release/[VERSION#] | ||
#mv temp/release/[VERSION#]/docs content/en/[VERSION#]-docs | ||
############################################################### | ||
git clone --quiet -b "release-0.15" https://github.com/"$FORK"/docs.git temp/release/v0.15 | ||
mv temp/release/v0.15/docs content/en/v0.15-docs | ||
git clone --quiet -b "release-0.14" https://github.com/"$FORK"/docs.git temp/release/v0.14 | ||
mv temp/release/v0.14/docs content/en/v0.14-docs | ||
git clone --quiet -b "release-0.13" https://github.com/"$FORK"/docs.git temp/release/v0.13 | ||
mv temp/release/v0.13/docs content/en/v0.13-docs | ||
mkdir -p docs # -p won't fail if the file exists | ||
r=$OLDESTVERSION | ||
while [[ $r -le $LATESTVERSION ]] | ||
do | ||
CLONE="docs/release-0.${r}" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this be a variable too for that day when Knative graduates to a MAJOR version? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When that happens, I hope to rewrite more of this anyway. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ive changed this to use the values set in https://github.com/knative/website/blob/master/scripts/docs-version-settings.sh (so on release time, this file does not need to get updated to include the recent version number) |
||
if [[ -e "$CLONE" ]] | ||
then | ||
echo "Skipping ${CLONE}, a copy of those archived docs already exists." | ||
ln -s ../../"$CLONE"/docs content/en/v0."$r"-docs #always recreate symlinks because /content/en always gets wiped out | ||
else | ||
echo 'Getting docs from: release-0.'"${r}" | ||
git clone --quiet -b "release-0.${r}" "https://github.com/${FORK}/docs.git" "$CLONE" | ||
if [ "$r" = "$LATESTVERSION" ] | ||
then | ||
echo 'The /docs/ section is built from:' "$FORK"'/release-0.'"${r}" | ||
mv "$CLONE"/docs content/en/docs | ||
rm -rf "$CLONE" #always get the latest release | ||
else | ||
# Only use the "docs" folder from all branches/releases | ||
ln -s ../../"$CLONE"/docs content/en/v0."$r"-docs | ||
fi | ||
fi | ||
(( r = r + 1 )) | ||
done | ||
|
||
elif [ "$BUILDSINGLEBRANCH" = "true" ] | ||
then | ||
|
@@ -64,6 +77,9 @@ else | |
echo '------ BUILDING ONLY FROM YOUR LOCAL KNATIVE/DOCS CLONE ------' | ||
echo 'Copying local clone of knative/docs into the /docs folder under:' | ||
pwd | ||
|
||
# TODO(Evan): switch this to just be symlinks? | ||
|
||
cp -r ../docs content/en/ | ||
if [ -d "../community" ]; then | ||
echo 'Also copying the local clone of knative/community into the /community/contributing folder.' | ||
|
@@ -77,6 +93,7 @@ if [ "$LOCALBUILD" = "false" ] | |
then | ||
echo '------ Cloning contributor docs ------' | ||
# COMMUNITY | ||
# TODO / Known issue: Auto PR builds will fail if remote fork excludes knative/community -> https://app.netlify.com/sites/knative/deploys | ||
echo 'Getting Knative contributor guidelines from the master branch of' "$FORK"'/community' | ||
git clone --quiet -b master https://github.com/"$FORK"/community.git temp/community | ||
# Move files into existing "contributing" folder | ||
|
@@ -97,40 +114,14 @@ source scripts/convert-repo-ulrs.sh | |
######################################################### | ||
# Process content in .md files (MAKE RELATIVE LINKS WORK) | ||
# We want users to be able view and use the source files in GitHub as well as on the site. | ||
# Therefore, the following changes need to be made to all docs files prior to Hugo site build. | ||
# Convert GitHub enabled source, into HUGO supported content: | ||
# - For all Markdown files under the /content/ directory: | ||
# - Skip all: | ||
# - Markdown link with fully qualified HTTP(s) URL is 'external' | ||
# - GitHub file (.git* files) | ||
# - non-docs directories | ||
# - Ignore Hugo site related files (avoid "readfile" shortcodes): | ||
# - _index.md files (Hugo 'section' files) | ||
# - API shell files (serving-api.md, eventing-contrib-api.md, eventing-api.md) | ||
# - For all remaining Markdown files: | ||
# - Remove all '.md' file extensions from within Markdown links "[]()" | ||
# - For SEO convert README to index: | ||
# - Replace all in-page URLS from "README.md" to "index.html" | ||
# - Rename all files from "README.md" to "index.md" | ||
# - Adjust relative links by adding additional depth: | ||
# - Exclude all README.md & _index.md files | ||
# - Convert './' to '../' | ||
# - Convert '../' to '../../' | ||
echo 'Converting all links in GitHub source files to Hugo supported relative links...' | ||
# Convert relative links to support Hugo | ||
find . -type f -path '*/content/*.md' ! -name '*_index.md' ! -name '*README.md' \ | ||
! -name '*serving-api.md' ! -name '*eventing-contrib-api.md' ! -name '*eventing-api.md' \ | ||
! -name '*build-api.md' ! -name '*.git*' ! -path '*/.github/*' ! -path '*/hack/*' \ | ||
! -path '*/node_modules/*' ! -path '*/test/*' ! -path '*/themes/*' ! -path '*/vendor/*' \ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Im very close to Go illiterate but I didnt see these files obviously ignored up in the Hugo layout? For anything here that is explicitly called out, its because Hugo will build that file into the site and add empty/no title Nav entries into our TOC. They rendered as blank spaces and are clickable but since they lacked front matter (to either add the missing meta or explicitly exclude it from the build) they get added to the site in unwanted and conflicting ways. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I figured out what these actually mapped to and made sure that they rendered correctly as best as I could tell. |
||
-exec sed -i '/](/ { s#(\.\.\/#(../../#g; s#(\.\/#(../#g; }' {} + | ||
# Convert all relative links from README.md to index.html | ||
find . -type f -path '*/content/*.md' ! -name '_index.md' \ | ||
-exec sed -i '/](/ { /http/ !{s#README\.md#index.html#g;s#\.md##g} }' {} + | ||
# | ||
# See layouts/_default/content.html for how this is done. | ||
|
||
############################################### | ||
# Process file names (HIDE README.md FROM URLS) | ||
# For SEO, dont use "README" in the URL | ||
# (convert them to index.md OR use a "readfile" shortcode to nest them within a _index.md section file) | ||
# See also https://github.com/gohugoio/hugo/issues/4691 which would resolve this. | ||
# | ||
# Notes about past docs versions: | ||
# v0.6 and earlier doc releases: Use the "readfile" shortcodes to nest all README.md files within the _index.md files. | ||
|
@@ -152,7 +143,7 @@ find . -type f -path '*/content/*/*/*' -name 'README.md' \ | |
! -path '*/contributing/*' ! -path '*/v0.6-docs/*' ! -path '*/v0.5-docs/*' \ | ||
! -path '*/v0.4-docs/*' ! -path '*/v0.3-docs/*' ! -path '*/.github/*' ! -path '*/hack/*' \ | ||
! -path '*/node_modules/*' ! -path '*/test/*' ! -path '*/themes/*' ! -path '*/vendor/*' \ | ||
-execdir bash -c 'if [ -e _index.md -o -e index.md ]; then echo "_index.md exists - skipping ${PWD#*/}"; else mv "$1" "${1/\README/\index}"; fi' -- {} \; | ||
-execdir bash -c 'if [ -e index.md -o -e _index.md ]; then echo "index.md or _index.md exists - skipping ${PWD#*/}"; else mv "$1" "${1/README/index}"; fi' -- {} \; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It doesnt apply here but I thought I'd mention that Hugo does weird stuff when both an index.md and an _index.md file exist in the same directory (the build only works as expected when only one or the other exist -> an index.md file can be used and reside alone in a folder if thats the only markdown file being build from that folder). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is just avoiding overwriting an |
||
|
||
# GET HANDCRAFTED SITE LANDING PAGE | ||
echo 'Copying the override files into the /content/ folder' | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you also test the local build too? Early on there was a lot of discrepancies between how Netlify built using Hugo and how the default local Hugo server built our content, thus the move to "building" the same way in both places.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I've been using local build to test.