parent
fe10be9677
commit
817fff899e
|
@ -24,4 +24,3 @@ Session.vim
|
|||
tags
|
||||
|
||||
kubernetes.github.io.iml
|
||||
_redirects
|
||||
|
|
5
Makefile
5
Makefile
|
@ -1,4 +1,4 @@
|
|||
.PHONY: all build build-preview generate-redirects help serve
|
||||
.PHONY: all build build-preview help serve
|
||||
|
||||
help: ## Show this help.
|
||||
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {sub("\\\\n",sprintf("\n%22c"," "), $$2);printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)
|
||||
|
@ -11,8 +11,5 @@ build: ## Build site with production settings and put deliverables in _site.
|
|||
build-preview: ## Build site with drafts and future posts enabled.
|
||||
jekyll build --drafts --future
|
||||
|
||||
generate-redirects: ## Generate a redirects file and copy it into the _site directory.
|
||||
mkdir -p _site && REDIRECTS_PATH=_site/_redirects ruby redirects.rb
|
||||
|
||||
serve: ## Boot the development server.
|
||||
jekyll serve
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[build]
|
||||
command = "make build generate-redirects"
|
||||
command = "make build"
|
||||
publish = "_site"
|
||||
|
||||
[context.deploy-preview]
|
||||
command = "make build-preview generate-redirects"
|
||||
command = "make build-preview"
|
||||
|
|
75
redirects.rb
75
redirects.rb
|
@ -1,75 +0,0 @@
|
|||
# This script generates a redirects file that Netlify's CDN
|
||||
# can use to forward visitor to the right content.
|
||||
#
|
||||
# You can read more details about this file in Netlify documentation:
|
||||
#
|
||||
# https://www.netlify.com/docs/redirects/
|
||||
#
|
||||
# USAGE:
|
||||
#
|
||||
# Run this script with Ruby to generate the _redirects file in this repository.
|
||||
# It works with any Ruby version higher than 1.8.
|
||||
#
|
||||
# ruby redirects.rb
|
||||
#
|
||||
# If you want to test a change without modifying the content of the current file,
|
||||
# you can print the output of the script setting the DEBUG environment variable
|
||||
# when you run the script:
|
||||
#
|
||||
# DEBUG=1 ruby redirects.rb
|
||||
#
|
||||
# You can test if the content generated is correct in this playground:
|
||||
#
|
||||
# https://play.netlify.com/redirects
|
||||
#
|
||||
# HOW TO ADD NEW RULES:
|
||||
#
|
||||
# This script is divided in two sections.
|
||||
#
|
||||
# The first section handles static redirects,
|
||||
# those that you know the old path and the new path and never change.
|
||||
#
|
||||
# If you want to add one of these redirects, add the rule to the `fixed_redirects` variable,
|
||||
# in a new line before the closing """. The format for basic 301 redirects is the following one,
|
||||
# check Netlify's documentation linked above for other rules:
|
||||
#
|
||||
# /OLD_PATH /NEW_PATH_OR_URL
|
||||
#
|
||||
# The second section handles redirects that change depending on the branch that's deployed
|
||||
# in the site. For instance, when you want to redirect a path to content in
|
||||
# the kubernetes main repository but the content is specific to a branch that
|
||||
# matches the deployed branch.
|
||||
#
|
||||
# If you want to add one of there redirects, add the old path to the `branch_redirects` list. For instance,
|
||||
# when you deploy the branch release-1.5 on Netlify, this script will generate the following redirects:
|
||||
#
|
||||
# /examples/* https://github.com/kubernetes/kubernetes/tree/release-1.5/examples/:splat
|
||||
# /cluster/* https://github.com/kubernetes/kubernetes/tree/release-1.5/cluster/:splat
|
||||
# /docs/devel/* https://github.com/kubernetes/kubernetes/tree/release-1.5/docs/devel/:splat
|
||||
# /docs/design/* https://github.com/kubernetes/kubernetes/tree/release-1.5/docs/design/:splat
|
||||
#
|
||||
REPO_TMPL = "https://github.com/kubernetes/kubernetes/tree/%s/%s/:splat"
|
||||
|
||||
fixed_redirects = """# 301 redirects (301 is the default status when no other one is provided for each line)
|
||||
/resource-quota /docs/admin/resourcequota/
|
||||
/horizontal-pod-autoscaler /docs/user-guide/horizontal-pod-autoscaling/
|
||||
/docs/user-guide/overview /docs/whatisk8s/
|
||||
/docs/roadmap https://github.com/kubernetes/kubernetes/milestones/
|
||||
/api-ref https://github.com/kubernetes/kubernetes/milestones/
|
||||
/docs/api-reference/apps/v1beta1/definitions/ /docs/api-reference/v1.6/#deployment-v1beta1-apps
|
||||
/docs/api-reference/autoscaling/v1/operations/ /docs/api-reference/v1.6/#horizontalpodautoscaler-v1-autoscaling
|
||||
/docs/api-reference/batch/v1/operations/ /docs/api-reference/v1.6/#job-v1-batch
|
||||
/docs/api-reference/extensions/v1beta1/operations/ /docs/api-reference/extensions/v1beta1/definitions/
|
||||
"""
|
||||
|
||||
branch_redirects = ["examples" , "cluster", "docs/devel", "docs/design"]
|
||||
|
||||
branch_redirects.each do |name|
|
||||
dest = REPO_TMPL % [ENV.fetch("HEAD", "master"), name]
|
||||
rule = "\n/#{name}/* #{dest}"
|
||||
|
||||
fixed_redirects << rule
|
||||
end
|
||||
|
||||
output = ENV["DEBUG"] ? STDOUT : File.open(ENV.fetch("REDIRECTS_PATH", "_redirects"), "w+")
|
||||
output.puts fixed_redirects
|
Loading…
Reference in New Issue