diff --git a/Makefile b/Makefile index 56150c75bb..4d9e13affc 100644 --- a/Makefile +++ b/Makefile @@ -28,4 +28,7 @@ serve: build @docker run -t -i --sig-proxy=true --rm -v $(shell pwd):/site -w /site -p 1313:1313 $(img) hugo serve --baseURL "http://${ISTIO_SERVE_DOMAIN}:1313/" --bind 0.0.0.0 --disableFastRender netlify: - @scripts/gen_site.sh "$(baseurl)" -minify -aliases + @scripts/gen_site.sh "$(baseurl)" -minify + +netlify_archive: + @scripts/gen_archive_site.sh "$(baseurl)" -minify diff --git a/archive_config.toml b/archive_config.toml new file mode 100644 index 0000000000..c216085eb5 --- /dev/null +++ b/archive_config.toml @@ -0,0 +1,67 @@ +defaultContentLanguage = "en" +languageCode = "en-us" +metaDataFormat = "yaml" +title = "Istio" +uglyURLs = false +enableRobotsTXT = true +pluralizeListTitles = false +canonifyURLs = true +disableKinds = ["taxonomy", "taxonomyTerm"] +anchor = "smart" +enableGitInfo = true +enableEmoji = false +buildFuture = true +ignoreFiles = [ "OWNERS" ] +staticDir = ["static", "generated"] + +# MARKDOWN +## Configuration for BlackFriday markdown parser: https://github.com/russross/blackfriday +[blackfriday] + plainIDAnchors = true + # See https://github.com/gohugoio/hugo/issues/2424 + hrefTargetBlank = false + angledQuotes = false + latexDashes = true + extensions = [""] + +[outputs] + home = ["HTML"] + section = ["HTML"] + +[mediaTypes] + [mediaTypes."text/netlify"] + delimiter = "" + +[outputFormats] + [outputFormats.RSS] + baseName = "feed" + [outputFormats.REDIR] + mediatype = "text/netlify" + baseName = "_redirects" + isPlainText = true + notAlternative = true + +[related] + # Only include matches with rank >= threshold. This is a normalized rank between 0 and 100. + threshold = 80 + + # To get stable "See also" sections we, by default, exclude newer related pages. + includeNewer = true + + # Will lower case keywords in both queries and in the indexes. + toLower = false + + [[related.indices]] + name = "keywords" + weight = 150 + + [[related.indices]] + name = "tags" + weight = 100 + +# internationalization +[languages] + [languages.zh] + contentDir = "content_zh" + [languages.en] + contentDir = "content" diff --git a/layouts/robots.txt b/layouts/robots.txt index a7b329781f..e7a48a5acd 100644 --- a/layouts/robots.txt +++ b/layouts/robots.txt @@ -1,3 +1,5 @@ User-agent: * Disallow: +{{ if not .Site.Data.args.archive_landing -}} Sitemap: {{ .Site.BaseURL }}/sitemap.xml +{{- end -}} diff --git a/scripts/gen_archive_site.sh b/scripts/gen_archive_site.sh new file mode 100755 index 0000000000..61578bd540 --- /dev/null +++ b/scripts/gen_archive_site.sh @@ -0,0 +1,90 @@ +#! /bin/bash +# +# Build the archive site +# + +# List of name:tagOrBranch +TOBUILD=( + v1.0:release-1.0 + v0.8:release-0.8 +) + +TOBUILD_JEKYLL=( +# v0.7:release-0.7 +# v0.6:release-0.6 +# v0.5:release-0.5 +# v0.4:release-0.4 +# v0.3:release-0.3 +# v0.2:release-0.2 +# v0.1:release-0.1 +) + +# Grab the latest version info +export TMP=$(mktemp -d) +cp data/versions.yml ${TMP} + +# Prepare +mkdir ${TMP}/archive +#echo "names:" >> ${TMP}/archives.yml + +for rel in "${TOBUILD[@]}" +do + NAME=$(echo $rel | cut -d : -f 1) + TAG=$(echo $rel | cut -d : -f 2) + BASEURL=$(echo /$NAME) + echo "### Building '$NAME' from $TAG for $BASEURL" + git clean -f + git checkout ${TAG} + cp ${TMP}/versions.yml data + + scripts/gen_site.sh ${BASEURL} + + mv public ${TMP}/archive/${NAME} + echo "- name: \"${NAME}\"" >> ${TMP}/archives.yml +done + +for rel in "${TOBUILD_JEKYLL[@]}" +do + NAME=$(echo $rel | cut -d : -f 1) + TAG=$(echo $rel | cut -d : -f 2) + echo "### Building '$NAME' from $TAG" + git clean -f + git checkout ${TAG} + echo "baseurl: /$NAME" > config_override.yml + cp ${TMP}/versions.yml _data + + bundle install + bundle exec jekyll build --config _config.yml,config_override.yml + + mv _site ${TMP}/archive/${NAME} + echo "- name: \"${NAME}\"" >> ${TMP}/archives.yml +done + +echo "### Building landing page" + +git clean -f +git checkout master + +# Grab the state +cp ${TMP}/archives.yml data + +# Delete stuff we don't want in the archive_landing +rm -fr content_zh content +rm -fr static/talks +mkdir content content_zh +echo "" >content/_index.md +echo "" >content_zh/_index.md +cp archive_config.toml config.toml +sed "s/archive_landing: false/archive_landing: true/" <"data/args.yml" >${TMP}/args.yml +mv ${TMP}/args.yml data + +scripts/gen_site.sh "https://archive.istio.io" + +# fetch the older sites +mv ${TMP}/archive/* public +rm -fr ${TMP} + +git clean -f +git checkout -- . + +echo "All done!"