Skip to content

Commit

Permalink
🎨 (docs): Strip homepage line during mdBook build
Browse files Browse the repository at this point in the history
  • Loading branch information
gabe565 committed Feb 10, 2023
1 parent 9bb9608 commit e997030
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
3 changes: 3 additions & 0 deletions docs/book.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,6 @@ level = 1

[output.html.search]
limit-results = 15

[preprocessor.strip-homepage]
command = '''./hack/preprocessor/replace-content.sh "\*\*Homepage:\*\*.+\n" ""'''
3 changes: 1 addition & 2 deletions docs/hack/prepare-docs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ CHARTS=()
while IFS= read -r -d '' f; do
mkdir -p "docs/src/$(dirname "$f")"

sed '/^\*\*Homepage:\*\*/,+1d' "$f" \
| sed "s|(\./\(.*\.yaml\))|($repo_path/blob/main/$(dirname "$f")/\1)|g" \
sed "s|(\./\(.*\.yaml\))|($repo_path/blob/main/$(dirname "$f")/\1)|g" "$f" \
> "docs/src/$f"

CHARTS+=("$(basename "$(dirname "$f")")")
Expand Down
16 changes: 16 additions & 0 deletions docs/hack/preprocessor/replace-content.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env bash
set -euo pipefail
export IFS=$'\n\t'

# require yq
command -v yq >/dev/null 2>&1 || {
echo >&2 'yq (https://github.com/mikefarah/yq) is not installed. Aborting.'
exit 1
}

if [[ "${3:-}" == supports ]]; then
exit
fi

export FIND="$1" REPLACE="$2"
yq -o json '.[1] | (.. | select(key == "content")) |= sub(strenv(FIND), strenv(REPLACE))' -

0 comments on commit e997030

Please sign in to comment.