mirror of
https://github.com/rancher/rancher-docs.git
synced 2026-09-25 20:48:11 +00:00
Upgrade hugo
This commit is contained in:
@@ -1,15 +1,15 @@
|
||||
#! /usr/bin/env node
|
||||
|
||||
'use strict';
|
||||
const jsdom = require("jsdom");
|
||||
const {
|
||||
JSDOM
|
||||
} = jsdom;
|
||||
const md5 = require('md5');
|
||||
const atomicalgolia = require("atomic-algolia");
|
||||
const fs = require('fs');
|
||||
const newNodes = [];
|
||||
const newParagraphs = [];
|
||||
const rawdata = fs.readFileSync('public/algolia.json');
|
||||
const rawdata = fs.readFileSync('/output/algolia.json');
|
||||
const nodes = JSON.parse(rawdata);
|
||||
|
||||
nodes.forEach(node => {
|
||||
@@ -61,19 +61,11 @@ nodes.forEach(node => {
|
||||
|
||||
if (paragraphOut.content) {
|
||||
// limit the content to 10k so we dont blow up just incase someone decides to make a 40k blog post in one paragraph ¯\_(ツ)_/¯
|
||||
paragraphOut.content = paragraphOut.content.substr(0, 18000);
|
||||
paragraphOut.content = paragraphOut.content.substr(0, 9000);
|
||||
|
||||
// objectID is not quite unique yet so hash the entire object
|
||||
paragraphOut.objectID = md5(JSON.stringify(paragraphOut));
|
||||
|
||||
if (true || paragraphOut.objectID === "d41d8cd98f00b204e9800998ecf8427e") {
|
||||
console.log('====================================');
|
||||
console.log('ID:',paragraphOut.objectID);
|
||||
console.log('Paragraph:',paragraphOut)
|
||||
console.log('JSON:',JSON.stringify(paragraphOut))
|
||||
console.log('====================================');
|
||||
}
|
||||
|
||||
newParagraphs.push(paragraphOut);
|
||||
newNodes.push(node);
|
||||
}
|
||||
@@ -89,5 +81,6 @@ nodes.forEach(node => {
|
||||
|
||||
const merged = [...newParagraphs, ...newNodes];
|
||||
|
||||
fs.writeFileSync('public/final.algolia.json', JSON.stringify(merged));
|
||||
fs.writeFileSync('/output/final.algolia.json', JSON.stringify(merged));
|
||||
|
||||
process.exit(0);
|
||||
|
||||
+32
-13
@@ -7,6 +7,7 @@ TAG=dev
|
||||
THEME=
|
||||
BUILD_BUILD=
|
||||
BUILD_DEV=
|
||||
SKIP_PULL=
|
||||
UPLOAD=
|
||||
|
||||
# cd to app root
|
||||
@@ -22,13 +23,14 @@ print_help()
|
||||
cat 1>&2 <<EOF
|
||||
Usage:
|
||||
|
||||
[-b [-u]] [-d] [-p PORT] [-t]
|
||||
[-b | -d] [-p PORT] [-s] [-t DIR] [-u]
|
||||
|
||||
-b - Build the build & dev images instead of pulling from the registry
|
||||
-d - Build the dev image instead of pulling from the registry
|
||||
-p PORT - Port to listen on
|
||||
-s - Skip pulling build/dev images
|
||||
-t DIR - Use DIR to for the theme, to devlop the theme at the same time
|
||||
-u - Upload the build image after building
|
||||
-u - Upload/push the build image after building
|
||||
|
||||
EOF
|
||||
}
|
||||
@@ -44,7 +46,7 @@ absolute() {
|
||||
}
|
||||
|
||||
|
||||
while getopts ":bdp:t:u" opt;do
|
||||
while getopts ":bdp:st:u" opt;do
|
||||
case $opt in
|
||||
b)
|
||||
BUILD_BUILD="true"
|
||||
@@ -56,6 +58,9 @@ while getopts ":bdp:t:u" opt;do
|
||||
p)
|
||||
PORT="${OPTARG}"
|
||||
;;
|
||||
s)
|
||||
SKIP_PULL="true"
|
||||
;;
|
||||
t)
|
||||
THEME="${OPTARG}"
|
||||
;;
|
||||
@@ -82,25 +87,39 @@ if [[ "$THEME" ]]; then
|
||||
THEMEVOLUME="-v ${ABSOLUTE}:/run/node_modules/rancher-website-theme"
|
||||
fi
|
||||
|
||||
if [ -z "$BUILD_BUILD" ]; then
|
||||
echo "Pulling ${IMAGE}:build"
|
||||
docker pull ${IMAGE}:build
|
||||
else
|
||||
if [[ "$BUILD_BUILD" ]]; then
|
||||
echo "Building ${IMAGE}:build"
|
||||
docker build --no-cache -f Dockerfile.build -t ${IMAGE}:build .
|
||||
docker build --no-cache -f Dockerfile.build --build-arg TWITTER_CONSUMER=${TWITTER_CONSUMER} --build-arg TWITTER_SECRET=${TWITTER_SECRET} -t ${IMAGE}:build .
|
||||
if [[ "$UPLOAD" ]]; then
|
||||
docker push ${IMAGE}:build
|
||||
fi
|
||||
elif [[ "$SKIP_PULL" ]]; then
|
||||
echo "Skipping pull of ${IMAGE}:build"
|
||||
else
|
||||
echo "Pulling ${IMAGE}:build"
|
||||
docker pull ${IMAGE}:build
|
||||
fi
|
||||
|
||||
if [ -z "$BUILD_DEV" ]; then
|
||||
echo "Pulling ${IMAGE}:${TAG}"
|
||||
docker pull ${IMAGE}:${TAG}
|
||||
else
|
||||
if [[ "$BUILD_DEV" ]]; then
|
||||
TAG=local
|
||||
echo "Building ${IMAGE}:${TAG}"
|
||||
docker build -f Dockerfile.dev -t ${IMAGE}:${TAG} .
|
||||
elif [[ "$SKIP_PULL" ]]; then
|
||||
echo "Skipping pull of ${IMAGE}:${TAG}"
|
||||
else
|
||||
echo "Pulling ${IMAGE}:${TAG}"
|
||||
docker pull ${IMAGE}:${TAG}
|
||||
fi
|
||||
|
||||
echo "Starting server on http://localhost:${PORT}"
|
||||
docker run --rm -p ${PORT}:${PORT} -it -v $(pwd):/site ${THEMEVOLUME} ${IMAGE}:${TAG} dev --port=${PORT}
|
||||
docker run --rm -p ${PORT}:${PORT} -it \
|
||||
-v $(pwd)/archetypes:/run/archetypes \
|
||||
-v $(pwd)/assets:/run/assets \
|
||||
-v $(pwd)/content:/run/content \
|
||||
-v $(pwd)/data:/run/data \
|
||||
-v $(pwd)/layouts:/run/layouts \
|
||||
-v $(pwd)/scripts:/run/scripts \
|
||||
-v $(pwd)/static:/run/static \
|
||||
-v $(pwd)/.git:/run/.git \
|
||||
-v $(pwd)/config.toml:/run/config.toml \
|
||||
${THEMEVOLUME} ${IMAGE}:${TAG} --port=${PORT}
|
||||
|
||||
Executable
+14
@@ -0,0 +1,14 @@
|
||||
#! /usr/bin/env node
|
||||
'use strict';
|
||||
|
||||
const atomicalgolia = require("atomic-algolia");
|
||||
|
||||
console.log('Publishing to algolia', process.env.ALGOLIA_INDEX_NAME);
|
||||
atomicalgolia(process.env.ALGOLIA_INDEX_NAME, '/run/final.algolia.json', {verbose: true}, (err, result) => {
|
||||
console.log(result);
|
||||
if ( err ) {
|
||||
process.exit(1);
|
||||
} else {
|
||||
process.exit(0);
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user