diff options
author | Volpeon <git@volpeon.ink> | 2020-12-31 16:56:33 +0100 |
---|---|---|
committer | Volpeon <git@volpeon.ink> | 2020-12-31 16:56:33 +0100 |
commit | 19a1a45f992bfb01f44a39dee554552b0b6102d1 (patch) | |
tree | c316405ea0dbe2e9e6fe73615fe2e14d4ec4cc80 | |
parent | Simplified category list (diff) | |
download | volpeon.ink-19a1a45f992bfb01f44a39dee554552b0b6102d1.tar.gz volpeon.ink-19a1a45f992bfb01f44a39dee554552b0b6102d1.tar.bz2 volpeon.ink-19a1a45f992bfb01f44a39dee554552b0b6102d1.zip |
Build script: More efficient way to find subpages
-rwxr-xr-x | scripts/build_content.sh | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/scripts/build_content.sh b/scripts/build_content.sh index 26c936d..a57feed 100755 --- a/scripts/build_content.sh +++ b/scripts/build_content.sh | |||
@@ -57,6 +57,12 @@ get_metadata() { | |||
57 | --template scripts/metadata_tpl.json | 57 | --template scripts/metadata_tpl.json |
58 | } | 58 | } |
59 | 59 | ||
60 | get_content() { | ||
61 | pandoc "$1" \ | ||
62 | -f markdown \ | ||
63 | -t plain | ||
64 | } | ||
65 | |||
60 | get_section() { | 66 | get_section() { |
61 | filename=$1 | 67 | filename=$1 |
62 | filename=${filename#"$CONTENT_DIR"} | 68 | filename=${filename#"$CONTENT_DIR"} |
@@ -79,20 +85,12 @@ get_subpages_meta() { | |||
79 | child_pages=() | 85 | child_pages=() |
80 | 86 | ||
81 | if [ -d "$basedir" ]; then | 87 | if [ -d "$basedir" ]; then |
82 | mapfile -d $'\0' child_pages_1 < <(find $basedir/ \ | 88 | mapfile -d $'\0' child_pages < <(find $basedir/ \ |
83 | -type f \ | 89 | -type f \ |
84 | -name "*.md" ! -name "index.md" \ | 90 | -name "*.md" \ |
85 | -maxdepth 1 \ | 91 | ! -wholename "$basedir/index.md" \ |
86 | -print0) | ||
87 | |||
88 | mapfile -d $'\0' child_pages_2 < <(find $basedir/ \ | ||
89 | -type f \ | ||
90 | -name "index.md" \ | ||
91 | -mindepth 2 \ | ||
92 | -maxdepth 2 \ | 92 | -maxdepth 2 \ |
93 | -print0) | 93 | -print0) |
94 | |||
95 | child_pages=("${child_pages_1[@]}" "${child_pages_2[@]}") | ||
96 | fi | 94 | fi |
97 | 95 | ||
98 | pages=$(echo "{}" | jq ". + { \ | 96 | pages=$(echo "{}" | jq ". + { \ |
@@ -109,6 +107,7 @@ get_subpages_meta() { | |||
109 | #echo -e "\033[0;90m[////////]\033[0m - $file" | 107 | #echo -e "\033[0;90m[////////]\033[0m - $file" |
110 | 108 | ||
111 | metadata=$(get_metadata "$file") | 109 | metadata=$(get_metadata "$file") |
110 | # content=$(get_content "$file") | ||
112 | 111 | ||
113 | section=$(get_section "$file") | 112 | section=$(get_section "$file") |
114 | 113 | ||
@@ -130,6 +129,12 @@ get_subpages_meta() { | |||
130 | category_name=$(echo "$CATEGORIES" | jq -r .$section.$category) | 129 | category_name=$(echo "$CATEGORIES" | jq -r .$section.$category) |
131 | fi | 130 | fi |
132 | 131 | ||
132 | # metadata=$(echo "$metadata" | jq ". + { \ | ||
133 | # content: { \ | ||
134 | # plain: \"$(echo "$content" | sed -z 's/\\/\\\\/g;s/\n/\\n/g;s/"/\"/g')\", \ | ||
135 | # }, \ | ||
136 | # }") | ||
137 | |||
133 | metadata=$(echo "$metadata" | jq ". + { \ | 138 | metadata=$(echo "$metadata" | jq ". + { \ |
134 | date: { \ | 139 | date: { \ |
135 | yyyy_mm_dd: \"$date\", \ | 140 | yyyy_mm_dd: \"$date\", \ |