File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -51,6 +51,7 @@ ARG DOCS_URL="https://docs.docker.com"
5151ENV HUGO_CACHEDIR="/tmp/hugo_cache"
5252RUN --mount=type=cache,target=/tmp/hugo_cache \
5353 hugo --gc --minify -e $HUGO_ENV -b $DOCS_URL
54+ RUN ./hack/flatten-markdown.sh public
5455
5556# lint lints markdown files
5657FROM ghcr.io/igorshubovych/markdownlint-cli:v0.45.0 AS lint
Original file line number Diff line number Diff line change 1+ #! /bin/sh
2+ set -e
3+
4+ # Flatten markdown files from public/path/to/page/index.md to public/path/to/page.md
5+ # This makes markdown output links work correctly
6+
7+ PUBLIC_DIR=" ${1:- public} "
8+
9+ [ -d " $PUBLIC_DIR " ] || { echo " Error: Directory $PUBLIC_DIR does not exist" ; exit 1; }
10+
11+ find " $PUBLIC_DIR " -type f -name ' index.md' | while read -r file; do
12+ # Skip the root index.md
13+ [ " $file " = " $PUBLIC_DIR /index.md" ] && continue
14+
15+ # Get the directory containing index.md
16+ dir=" ${file%/* } "
17+
18+ # Move index.md to parent directory with directory name
19+ mv " $file " " ${dir%/* } /${dir##*/ } .md"
20+ done
21+
22+ echo " Flattened markdown files in $PUBLIC_DIR "
You can’t perform that action at this time.
0 commit comments