Build blog and community with hugo (#3558)

* Build blog and community with hugo

* Use http-server instead of serve

* Add package.json and ignore temp
This commit is contained in:
Julian Friedman 2021-05-12 22:05:48 +01:00 committed by GitHub
parent 5e9b4024ff
commit 67fda06b05
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 6140 additions and 2 deletions

2
.gitignore vendored
View File

@ -5,6 +5,8 @@
__pycache__
hack/__pycache__
/site/
/temp/
/node_modules/
.settings/

View File

@ -11,3 +11,12 @@
width: 3rem;
height: 2.4rem;
}
.md-tabs {
border-bottom: 1px solid var(--home-color);
}
.md-tabs__list li:nth-last-child(1),
.md-tabs__list li:nth-last-child(2) {
background: var(--home-color);
float: right;
}

77
hack/build-with-blog.sh Executable file
View File

@ -0,0 +1,77 @@
#!/bin/bash
# Builds blog and community into the site by cloning the website repo, copying blog/community dirs in, running hugo.
# - Results are written to site/ as normal.
# - Run as "./hack/build-with-blog.sh serve" to run a local preview server on site/ afterwards (requires `npm install -g http-server`).
# Quit on error
set -e
# Echo each line
set -x
# First, build the main site with mkdocs
rm -rf site/
mkdocs build -d site/docs
# Re-Clone
# TODO(jz) Cache this and just do a pull/update for local dev flow.
# Maybe also support local checkout in siblings?
rm -rf temp
mkdir temp
git clone --recurse-submodules https://github.com/knative/website temp/website
git clone https://github.com/knative/community temp/community
# Move blog files into position
mkdir -p temp/website/content/en
cp -r blog temp/website/content/en/
# Clone community/ in to position too
# This is pretty weird: the base community is in docs, but then the
# community repo is overlayed into the community/contributing subdir.
cp -r community temp/website/content/en/
cp -r temp/community/* temp/website/content/en/community/contributing/
rm -r temp/website/content/en/community/contributing/elections/2021-TOC # Temp fix for markdown that confuses hugo.
# Run the hugo build as normal!
pushd temp/website
hugo
popd
# Hugo builds to public/, just copy over to site/ to match up with mkdocs
mv temp/website/public/blog site/
mv temp/website/public/community site/
mv temp/website/public/css site/
mv temp/website/public/scss site/
mv temp/website/public/webfonts site/
mv temp/website/public/images site/
mv temp/website/public/js site/
# Home page is served from docs, so add a redirect.
# TODO(jz) in production this should be done with a netlify 301 (or maybe just copy docs/index up with a base set).
cat << EOF > site/index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Redirecting</title>
<noscript>
<meta http-equiv="refresh" content="1; url=../dev/" />
</noscript>
<script>
window.location.replace("/docs/");
</script>
</head>
<body>
Redirecting to <a href="/docs/">/docs/</a>...
</body>
</html>
EOF
# Clean up
rm -rf temp
if [ "$1" = "serve" ]; then
pushd site
npx http-server
popd
fi

View File

@ -194,7 +194,8 @@ nav:
- Client:
- CLI tools: client/README.md
- Install kn: client/install-kn.md
- Community: todo
- "Join the Community ➠": /community/
- "Read the Blog ➠": /blog/
theme:
name: material
@ -231,6 +232,7 @@ markdown_extensions:
- pymdownx.superfences
- pymdownx.tabbed
- pymdownx.details
- pymdownx.snippets
- pymdownx.keys
- pymdownx.caret
- pymdownx.mark

6021
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

27
package.json Normal file
View File

@ -0,0 +1,27 @@
{
"name": "knative",
"version": "0.1.0",
"description": "Knative docs",
"main": "index.js",
"devDependencies": {
"autoprefixer": "^9.8.6",
"http-server": "^0.12.3",
"postcss-cli": "^6.1.3"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git+https://github.com/knative/docs.git"
},
"author": "",
"license": "ISC",
"bugs": {
"url": "https://github.com/knative/docs/issues"
},
"homepage": "https://knative.dev",
"engines": {
"node": ">12.0"
}
}