summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorVolpeon <git@volpeon.ink>2020-12-30 09:06:31 +0100
committerVolpeon <git@volpeon.ink>2020-12-30 09:06:31 +0100
commit3ab8981195dbbdc553fbe1a14178b6793a81fa3b (patch)
treeeee7ce7de75903d0140245dd1d39686c73113bd3 /scripts
parentFixed regression: Category showed up in child pages as well (diff)
downloadvolpeon.ink-3ab8981195dbbdc553fbe1a14178b6793a81fa3b.tar.gz
volpeon.ink-3ab8981195dbbdc553fbe1a14178b6793a81fa3b.tar.bz2
volpeon.ink-3ab8981195dbbdc553fbe1a14178b6793a81fa3b.zip
Revert to old category metadata collection, add support for authors
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/build_content.sh34
1 files changed, 27 insertions, 7 deletions
diff --git a/scripts/build_content.sh b/scripts/build_content.sh
index 12de8c8..fc5ddea 100755
--- a/scripts/build_content.sh
+++ b/scripts/build_content.sh
@@ -25,6 +25,8 @@ get_filters() {
25 25
26FILTERS=$(get_filters) 26FILTERS=$(get_filters)
27 27
28CATEGORIES=$(cat "$METADATA_DIR/categories.json")
29
28target_filename() { 30target_filename() {
29 filename=$1 31 filename=$1
30 filename=${filename#"$CONTENT_DIR"} 32 filename=${filename#"$CONTENT_DIR"}
@@ -98,6 +100,8 @@ get_subpages_meta() {
98 not_empty: false \ 100 not_empty: false \
99 }") 101 }")
100 102
103 categories="{}"
104
101 if [ ${#child_pages[@]} -ne 0 ]; then 105 if [ ${#child_pages[@]} -ne 0 ]; then
102 #echo -e "\033[0;90m[////////]\033[0m Child pages:" 106 #echo -e "\033[0;90m[////////]\033[0m Child pages:"
103 107
@@ -108,6 +112,8 @@ get_subpages_meta() {
108 112
109 metadata=$(metadata "$file") 113 metadata=$(metadata "$file")
110 114
115 section=$(get_section "$file")
116
111 url_rel=$(target_url_rel "$basedir" "$file" "html") 117 url_rel=$(target_url_rel "$basedir" "$file" "html")
112 url_abs=$(target_url_abs "$file" "html") 118 url_abs=$(target_url_abs "$file" "html")
113 url_full="${SITE%/}$url_abs" 119 url_full="${SITE%/}$url_abs"
@@ -119,6 +125,13 @@ get_subpages_meta() {
119 date_rfc3339=$(date -d "$date" --rfc-3339=seconds | sed 's/ /T/') 125 date_rfc3339=$(date -d "$date" --rfc-3339=seconds | sed 's/ /T/')
120 fi 126 fi
121 127
128 category=$(echo "$metadata" | jq -r .category)
129 category_name=""
130
131 if [ "$section" != "" ] && [ "$category" != "" ]; then
132 category_name=$(echo "$CATEGORIES" | jq -r .$section.$category)
133 fi
134
122 metadata=$(echo "$metadata" | jq ". * { \ 135 metadata=$(echo "$metadata" | jq ". * { \
123 date: { \ 136 date: { \
124 yyyy_mm_dd: \"$date\", \ 137 yyyy_mm_dd: \"$date\", \
@@ -140,16 +153,23 @@ get_subpages_meta() {
140 153
141 pages=$(echo "$pages" | jq ".by_year.\"$date_year\" += [ $metadata ]") 154 pages=$(echo "$pages" | jq ".by_year.\"$date_year\" += [ $metadata ]")
142 fi 155 fi
143 done
144 156
145 pages=$(echo "$pages" \ 157 if [ "$category" != "" ]; then
146 | jq ".all |= (sort_by(.date) | reverse) \ 158 categories=$(echo "$categories" | jq ".$category = { name: \"$category_name\", count: (.$category.count + 1) } ")
147 | .by_year |= (to_entries | sort_by(.key) | reverse \ 159 fi
148 | .[].value |= (sort_by(.date) | reverse))") 160 done
149 fi 161 fi
150 162
163 pages=$(echo "$pages" \
164 | jq ".all |= (sort_by(.date) | reverse) \
165 | .by_year |= (to_entries | sort_by(.key) | reverse \
166 | .[].value |= (sort_by(.date) | reverse))")
167
168 categories=$(echo "$categories" | jq ". | to_entries | sort_by(.key)")
169
151 echo "{}" | jq ". + { \ 170 echo "{}" | jq ". + { \
152 pages: $pages \ 171 pages: $pages, \
172 categories: $categories
153 }" 173 }"
154} 174}
155 175
@@ -163,7 +183,7 @@ handle () {
163 183
164 meta_file=$(mktemp) 184 meta_file=$(mktemp)
165 185
166 metadata=$(metadata "$file") 186 metadata=$(metadata "$1")
167 metadata=$(echo "[ \ 187 metadata=$(echo "[ \
168 $metadata, \ 188 $metadata, \
169 $(get_subpages_meta "$1") \ 189 $(get_subpages_meta "$1") \