[web] Restructuring to page bundles
Preview is here: https://ogs.ogs.xyz/-/ogs/-/jobs/179420/artifacts/web/public/index.html
Restructures the /docs
-section to use page bundles.
This will enable correct images in MR web site previews. Still not working are other linked files, e.g. PDFs or supplementary scripts and also images in Jupyter notebooks.
The following script (adapted from https://www.virtuallypotato.com/script-to-convert-posts-to-hugo-page-bundles/) was used:
# Usage: ./convert-to-pagebundle.sh vpotato/content/posts/hello-hugo.md
inputPost="$1" # vpotato/content/posts/hello-hugo.md
postPath=$(dirname $inputPost) # vpotato/content/posts
postTitle=$(basename $inputPost .md) # hello-hugo
newPath="$postPath/$postTitle" # vpotato/content/posts/hello-hugo
newPost="$newPath/index.md" # vpotato/content/posts/hello-hugo/index.md
siteBase=$(echo "$inputPost" | awk -F/ '{ print $1 }') # vpotato
imageLinks=($(ggrep -o -P '\.\./\S*.(png|jpg|pdf|mp4|svg)' $inputPost))
# Ex: '/images/posts/image-name.png'
echo $imageLinks
imageFiles=($(for file in ${imageLinks[@]}; do basename $file; done))
# Ex: 'image-name.png'
imagePaths=($(for file in ${imageLinks[@]}; do echo "$file"; done))
# Ex: 'vpotato/static/images/posts/image-name.png'
mkdir -p "$newPath" # make 'hello-hugo' dir
mv "$inputPost" "$newPost" # move 'hello-hugo.md' to 'hello-hugo/index.md'
for index in ${!imagePaths[@]}; do
mv ${imagePaths[index]} $newPath
# vpotato/static/images/posts/image-name.png --> vpotato/content/posts/hello-hugo/image-name.png
echo "$postPath/${imageFiles[index]} -> $newPath/${imageFiles[index]}"
mv $postPath/${imageFiles[index]} $newPath
echo "s^${imagePaths[index]}^${imageFiles[index]}^"
sed -i '' "s^${imagePaths[index]}^${imageFiles[index]}^" $newPost
done
find content/docs/benchmarks -name '*.md' -not -name '*index.md' -exec ./convert-to-pagebundle.sh {} \;
...
find content/docs/userguide -name '*.md' -not -name '*index.md' -exec ./convert-to-pagebundle.sh {} \;
-
Feature description was added to the changelog -
Tests covering your feature were added?