summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorVolpeon <git@volpeon.ink>2020-12-27 22:46:46 +0100
committerVolpeon <git@volpeon.ink>2020-12-27 22:46:46 +0100
commite3a86169d6aaca14e96ecf7c349ec6f7c59b3ad3 (patch)
tree069c9271e3b0f9dd6fdfd9dc91b3a66d2a1453ed /scripts
parentAdded stylelint, generate some metadata automatically (diff)
downloadvolpeon.ink-e3a86169d6aaca14e96ecf7c349ec6f7c59b3ad3.tar.gz
volpeon.ink-e3a86169d6aaca14e96ecf7c349ec6f7c59b3ad3.tar.bz2
volpeon.ink-e3a86169d6aaca14e96ecf7c349ec6f7c59b3ad3.zip
Completed automatic metadata generation
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/build_content.sh24
1 files changed, 10 insertions, 14 deletions
diff --git a/scripts/build_content.sh b/scripts/build_content.sh
index 5b4bb85..298291d 100755
--- a/scripts/build_content.sh
+++ b/scripts/build_content.sh
@@ -34,9 +34,6 @@ get_section() {
34 filename=${filename#"$CONTENT_DIR"} 34 filename=${filename#"$CONTENT_DIR"}
35 filename=${filename%.md} 35 filename=${filename%.md}
36 filename=$(echo "$filename" | cut -f1 -d /) 36 filename=$(echo "$filename" | cut -f1 -d /)
37 if [ "$filename" = "index.md" ]; then
38 filename="home"
39 fi
40 echo "$filename" 37 echo "$filename"
41} 38}
42 39
@@ -70,12 +67,12 @@ get_subpages() {
70 fi 67 fi
71 68
72 if [ ${#child_pages[@]} -ne 0 ]; then 69 if [ ${#child_pages[@]} -ne 0 ]; then
73 echo -e "\033[0;90m[////////]\033[0m Child pages:" 70 #echo -e "\033[0;90m[////////]\033[0m Child pages:"
74 71
75 collected_metadata="[]" 72 collected_metadata="[]"
76 73
77 for file in "${child_pages[@]}"; do 74 for file in "${child_pages[@]}"; do
78 echo -e "\033[0;90m[////////]\033[0m - $file" 75 #echo -e "\033[0;90m[////////]\033[0m - $file"
79 76
80 url_rel=$(target_url_rel "$basedir" "$file") 77 url_rel=$(target_url_rel "$basedir" "$file")
81 url_abs=$(target_url_abs "$file") 78 url_abs=$(target_url_abs "$file")
@@ -90,9 +87,9 @@ get_subpages() {
90 collected_metadata=$(echo "$collected_metadata" | jq ". + [ $metadata ]") 87 collected_metadata=$(echo "$collected_metadata" | jq ". + [ $metadata ]")
91 done 88 done
92 89
93 collected_metadata=$(echo "$collected_metadata" | jq "sort_by(.date)") 90 collected_metadata=$(echo "$collected_metadata" | jq "sort_by(.date) | reverse")
94 91
95 echo "$collected_metadata" 92 echo "{ \"pages\": $collected_metadata }" | jq .
96 fi 93 fi
97} 94}
98 95
@@ -111,23 +108,22 @@ handle () {
111 is_home=true 108 is_home=true
112 fi 109 fi
113 110
114 subpages_meta=$(mktemp) 111 subpages_meta_file=$(mktemp)
115
116 # $(get_subpages "$1") > "$subpages_meta"
117 112
118 get_subpages "$1" 113 echo "$(get_subpages "$1")" > "$subpages_meta_file"
119 114
120 pandoc "$1" \ 115 pandoc "$1" \
121 -f markdown \ 116 -f markdown \
122 -t html5 \ 117 -t html5 \
123 --template "${TEMPLATES_DIR}base.html" \ 118 --template "${TEMPLATES_DIR}base.html" \
124 -o "$target" \ 119 -o "$target" \
125 --metadata isHome=$is_home \ 120 --metadata "ishome"=$is_home \
126 --metadata section=$section \ 121 --metadata section=$section \
122 --metadata "is$section" \
127 --metadata-file metadata/metadata.yaml \ 123 --metadata-file metadata/metadata.yaml \
128 --metadata-file "$subpages_meta" 124 --metadata-file "$subpages_meta_file"
129 125
130 rm "$subpages_meta" 126 rm "$subpages_meta_file"
131 else 127 else
132 echo -e "\033[0;32m[COPY ]\033[0m $1 -> $target" 128 echo -e "\033[0;32m[COPY ]\033[0m $1 -> $target"
133 129