-
-
Notifications
You must be signed in to change notification settings - Fork 246
/
pages_create.sh
executable file
·49 lines (43 loc) · 1.39 KB
/
pages_create.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/env bash
set -xeuo pipefail
cd "$(dirname "$(readlink -f "$0")")"
mkdir -vp pages
repourl="${GITHUB_SERVER_URL:-https://github.com}/${GITHUB_REPOSITORY:-AstroNvim/astrocommunity}/tree/main"
{
# Generate pandoc metadata file.
cat <<EOF
---
title: "[AstroNvim Community Repository Pages]($repourl)"
date: $(LC_ALL=C date --utc)
abstract: |
Autogenerated site from README.md of all the plugins in astrocommunity repository.
---
EOF
} >pages/metadata.yaml
{
# Generate markdown of all descriptions.
prevsection=
shopt -s globstar
for readme in lua/astrocommunity/**/README.md; do
IFS=/ read -r _ _ section name _ <<<"$readme"
if [[ "$prevsection" != "$section" ]]; then
echo "# [$section]($repourl/lua/astrocommunity/$section)"
echo
prevsection=$section
fi
cat <<EOF
## [$section.$name]($repourl/lua/astrocommunity/$section/$name/init.lua)
\`\`\`
{ import = "astrocommunity.$section.$name" }
\`\`\`
EOF
# Indent markdown sections two sections up.
sed "s/^#/###/" <"$readme"
echo
done
} >pages/index.md
# Use pandoc to convert from markdown to html.
docker run -i --rm --mount type=bind,source="$PWD",target="$PWD",readonly --workdir "$PWD" pandoc/core:3.5 \
--from markdown --standalone --toc --toc-depth 2 --number-sections \
--metadata-file pages/metadata.yaml pages/index.md >pages/index.html
echo "SUCCESS - generated pages/index.html"