diff options
-rw-r--r-- | assets/css/_basics.scss | 4 | ||||
-rw-r--r-- | assets/css/components/_nav.scss | 6 | ||||
-rw-r--r-- | assets/css/components/_page.scss | 11 | ||||
-rw-r--r-- | assets/css/scopes/_code.scss | 2 | ||||
-rw-r--r-- | metadata/categories.json | 6 | ||||
-rw-r--r-- | metadata/metadata.yaml | 6 | ||||
-rwxr-xr-x | scripts/build_content.sh | 200 | ||||
-rw-r--r-- | scripts/metadata_filter.lua | 225 | ||||
-rwxr-xr-x | scripts/metadata_tpl.json | 7 | ||||
-rw-r--r-- | site.defaults.conf | 2 | ||||
-rw-r--r-- | templates/base.html | 17 | ||||
-rw-r--r-- | templates/feed.xml | 10 | ||||
-rw-r--r-- | templates/list.html | 4 | ||||
-rw-r--r-- | templates/partials/pageHeaderSm.html | 2 |
14 files changed, 301 insertions, 201 deletions
diff --git a/assets/css/_basics.scss b/assets/css/_basics.scss index 05d2974..b18ca57 100644 --- a/assets/css/_basics.scss +++ b/assets/css/_basics.scss | |||
@@ -182,7 +182,7 @@ hr { | |||
182 | 182 | ||
183 | blockquote { | 183 | blockquote { |
184 | position: relative; | 184 | position: relative; |
185 | margin: ($line-height * 1em) 0 0; | 185 | margin: ($line-height * 1em) 0 0 1px; |
186 | padding-left: calc(#{$subcontent--indent} - 2px); | 186 | padding-left: calc(#{$subcontent--indent} - 3px); |
187 | border-left: 2px solid var(--obj); | 187 | border-left: 2px solid var(--obj); |
188 | } | 188 | } |
diff --git a/assets/css/components/_nav.scss b/assets/css/components/_nav.scss index 60b3584..6d087ad 100644 --- a/assets/css/components/_nav.scss +++ b/assets/css/components/_nav.scss | |||
@@ -40,6 +40,12 @@ | |||
40 | color: var(--nav--item--hover--fg); | 40 | color: var(--nav--item--hover--fg); |
41 | font-weight: bold; | 41 | font-weight: bold; |
42 | } | 42 | } |
43 | |||
44 | &--active { | ||
45 | border-color: var(--nav--item--active--fg); | ||
46 | color: var(--nav--item--active--fg); | ||
47 | font-weight: bold; | ||
48 | } | ||
43 | } | 49 | } |
44 | 50 | ||
45 | @media (max-width: map-get($breakpoints, 'sm')) { | 51 | @media (max-width: map-get($breakpoints, 'sm')) { |
diff --git a/assets/css/components/_page.scss b/assets/css/components/_page.scss index c9a4650..bccf069 100644 --- a/assets/css/components/_page.scss +++ b/assets/css/components/_page.scss | |||
@@ -8,7 +8,8 @@ | |||
8 | } | 8 | } |
9 | 9 | ||
10 | &__code { | 10 | &__code { |
11 | padding-left: calc(#{$subcontent--indent} - 2px); | 11 | margin-left: 1px; |
12 | padding-left: calc(#{$subcontent--indent} - 3px); | ||
12 | border-left: 2px solid var(--obj); | 13 | border-left: 2px solid var(--obj); |
13 | } | 14 | } |
14 | 15 | ||
@@ -49,8 +50,8 @@ | |||
49 | &--pre { | 50 | &--pre { |
50 | $scale-factor: $font-size / $code-block--font-size; | 51 | $scale-factor: $font-size / $code-block--font-size; |
51 | 52 | ||
52 | // margin-left: calc(#{-1 * $page--item-prefix--width} * #{$scale-factor}); | 53 | margin-left: calc(#{-1 * $page--item-prefix--width} * #{$scale-factor}); |
53 | // padding-left: calc(#{$page--item-prefix--width} * #{$scale-factor}); | 54 | padding-left: calc(#{$page--item-prefix--width} * #{$scale-factor}); |
54 | border-left: 0; | 55 | border-left: 0; |
55 | 56 | ||
56 | &::before { | 57 | &::before { |
@@ -58,8 +59,8 @@ | |||
58 | height: 100%; | 59 | height: 100%; |
59 | overflow: hidden; | 60 | overflow: hidden; |
60 | color: var(--page--item-prefix--fg); | 61 | color: var(--page--item-prefix--fg); |
61 | // font-size: px-to-em($font-size, $code-block--font-size); | 62 | font-size: px-to-em($font-size, $code-block--font-size); |
62 | // line-height: $code-block--line-height / $scale-factor; | 63 | line-height: $code-block--line-height / $scale-factor; |
63 | } | 64 | } |
64 | } | 65 | } |
65 | 66 | ||
diff --git a/assets/css/scopes/_code.scss b/assets/css/scopes/_code.scss index cdc9425..f6697aa 100644 --- a/assets/css/scopes/_code.scss +++ b/assets/css/scopes/_code.scss | |||
@@ -6,6 +6,8 @@ | |||
6 | line-height: $line-height; | 6 | line-height: $line-height; |
7 | } | 7 | } |
8 | 8 | ||
9 | /* stylelint-disable selector-class-pattern */ | ||
10 | |||
9 | .c { | 11 | .c { |
10 | color: var(--fg-hi); | 12 | color: var(--fg-hi); |
11 | } | 13 | } |
diff --git a/metadata/categories.json b/metadata/categories.json deleted file mode 100644 index 9ce0815..0000000 --- a/metadata/categories.json +++ /dev/null | |||
@@ -1,6 +0,0 @@ | |||
1 | { | ||
2 | "blog": { | ||
3 | "tes": "Testing", | ||
4 | "per": "Personal" | ||
5 | } | ||
6 | } | ||
diff --git a/metadata/metadata.yaml b/metadata/metadata.yaml index c060e79..51e8cda 100644 --- a/metadata/metadata.yaml +++ b/metadata/metadata.yaml | |||
@@ -1,6 +1,7 @@ | |||
1 | site: | 1 | site: |
2 | title: Volpeon's Den | 2 | title: Volpeon's Den |
3 | logo: \\\\/ | 3 | logo: \\\\/ |
4 | url: https://volpeon.ink/ | ||
4 | 5 | ||
5 | author: | 6 | author: |
6 | - name: Volpeon | 7 | - name: Volpeon |
@@ -17,3 +18,8 @@ menus: | |||
17 | feeds: | 18 | feeds: |
18 | - title: Blog | 19 | - title: Blog |
19 | url: /blog/index.xml | 20 | url: /blog/index.xml |
21 | |||
22 | categories: | ||
23 | blog: | ||
24 | tes: Testing | ||
25 | per: Personal | ||
diff --git a/scripts/build_content.sh b/scripts/build_content.sh index c640b12..c88ea86 100755 --- a/scripts/build_content.sh +++ b/scripts/build_content.sh | |||
@@ -23,8 +23,6 @@ get_filters() { | |||
23 | 23 | ||
24 | FILTERS=$(get_filters) | 24 | FILTERS=$(get_filters) |
25 | 25 | ||
26 | CATEGORIES=$(cat "$METADATA_DIR/categories.json") | ||
27 | |||
28 | get_target_filename() { | 26 | get_target_filename() { |
29 | filename=$1 | 27 | filename=$1 |
30 | filename=${filename#"$CONTENT_DIR"} | 28 | filename=${filename#"$CONTENT_DIR"} |
@@ -34,43 +32,29 @@ get_target_filename() { | |||
34 | echo "$OUTPUT_DIR$filename" | 32 | echo "$OUTPUT_DIR$filename" |
35 | } | 33 | } |
36 | 34 | ||
37 | get_url_rel() { | ||
38 | basedir=$1 | ||
39 | filename=$2 | ||
40 | ext=$3 | ||
41 | filename=$(realpath --relative-to="$basedir" "$filename") | ||
42 | filename="${filename%.md}.$ext" | ||
43 | if [ "${filename##*/}" = "index.html" ]; then | ||
44 | filename=${filename%index.html} | ||
45 | fi | ||
46 | echo "$filename" | ||
47 | } | ||
48 | |||
49 | get_url_abs() { | ||
50 | echo "/$(get_url_rel "$CONTENT_DIR" "$1" "$2")" | ||
51 | } | ||
52 | |||
53 | get_metadata() { | 35 | get_metadata() { |
54 | pandoc "$1" \ | 36 | pandoc "$2" \ |
55 | -f markdown \ | 37 | -f markdown \ |
56 | -t plain \ | 38 | -t plain \ |
39 | --metadata content_dir="$CONTENT_DIR" \ | ||
40 | --metadata base_file="$1" \ | ||
41 | --metadata file="$2" \ | ||
42 | --metadata-file metadata/metadata.yaml \ | ||
57 | --no-highlight \ | 43 | --no-highlight \ |
58 | --template scripts/metadata_tpl.json | 44 | --template scripts/metadata_tpl.json \ |
45 | --lua-filter scripts/metadata_filter.lua | ||
59 | } | 46 | } |
60 | 47 | ||
61 | get_content() { | 48 | get_content() { |
62 | pandoc "$1" \ | 49 | pandoc "$2" \ |
63 | -f markdown \ | 50 | -f markdown \ |
64 | -t plain \ | 51 | -t plain \ |
65 | --no-highlight | 52 | --metadata content_dir="$CONTENT_DIR" \ |
66 | } | 53 | --metadata base_file="$1" \ |
67 | 54 | --metadata file="$2" \ | |
68 | get_section() { | 55 | --metadata-file metadata/metadata.yaml \ |
69 | filename=$1 | 56 | --no-highlight \ |
70 | filename=${filename#"$CONTENT_DIR"} | 57 | --lua-filter scripts/metadata_filter.lua |
71 | filename=${filename%.md} | ||
72 | filename=$(echo "$filename" | cut -f1 -d /) | ||
73 | echo "$filename" | ||
74 | } | 58 | } |
75 | 59 | ||
76 | get_subpages_basedir() { | 60 | get_subpages_basedir() { |
@@ -82,7 +66,7 @@ get_subpages_basedir() { | |||
82 | echo "$filename" | 66 | echo "$filename" |
83 | } | 67 | } |
84 | 68 | ||
85 | get_subpages_meta() { | 69 | get_subpages_metadata() { |
86 | basedir=$(get_subpages_basedir "$1") | 70 | basedir=$(get_subpages_basedir "$1") |
87 | child_pages=() | 71 | child_pages=() |
88 | 72 | ||
@@ -97,98 +81,25 @@ get_subpages_meta() { | |||
97 | -print0) | 81 | -print0) |
98 | fi | 82 | fi |
99 | 83 | ||
100 | pages=$(echo "{}" | jq ". + { \ | 84 | pages="[]" |
101 | all: [], \ | ||
102 | by_year: {}, \ | ||
103 | }") | ||
104 | |||
105 | categories="{}" | ||
106 | 85 | ||
107 | if [ ${#child_pages[@]} -ne 0 ]; then | 86 | if [ ${#child_pages[@]} -ne 0 ]; then |
108 | #echo -e "\033[0;90m[////////]\033[0m Child pages:" | ||
109 | |||
110 | for file in "${child_pages[@]}"; do | 87 | for file in "${child_pages[@]}"; do |
111 | #echo -e "\033[0;90m[////////]\033[0m - $file" | 88 | metadata=$(get_metadata "$1" "$file" | jq "{ \ |
112 | 89 | url: .url, \ | |
113 | metadata=$(get_metadata "$file") | 90 | author: .author, \ |
114 | 91 | title: .title, \ | |
115 | section=$(get_section "$file") | 92 | date: .date, \ |
116 | 93 | last_update: .last_update, \ | |
117 | url_rel=$(get_url_rel "$basedir" "$file" "html") | 94 | category: .category, \ |
118 | url_abs=$(get_url_abs "$file" "html") | 95 | content: \"$(get_content "$1" "$file" | sed -z 's/\\/\\\\/g;s/\n/\\n/g;s/"/\"/g')\" \ |
119 | url_full="${SITE%/}$url_abs" | 96 | } | del(.[] | nulls)") |
120 | 97 | ||
121 | date=$(echo "$metadata" | jq -r .date) | 98 | pages=$(echo "$pages" | jq ". += [ $metadata ]") |
122 | date_rfc3339="" | ||
123 | |||
124 | if [ "$date" != "" ]; then | ||
125 | date_rfc3339=$(date -d "$date" --rfc-3339=seconds | sed 's/ /T/') | ||
126 | fi | ||
127 | |||
128 | last_update=$(echo "$metadata" | jq -r .last_update) | ||
129 | last_update_rfc3339="" | ||
130 | |||
131 | if [ "$last_update" != "" ]; then | ||
132 | last_update=$date | ||
133 | fi | ||
134 | |||
135 | if [ "$last_update" != "" ]; then | ||
136 | last_update_rfc3339=$(date -d "$last_update" --rfc-3339=seconds | sed 's/ /T/') | ||
137 | fi | ||
138 | |||
139 | category=$(echo "$metadata" | jq -r .category) | ||
140 | category_name="" | ||
141 | |||
142 | if [ "$section" != "" ] && [ "$category" != "" ]; then | ||
143 | category_name=$(echo "$CATEGORIES" | jq -r ".$section.$category") | ||
144 | fi | ||
145 | |||
146 | content=$(get_content "$file") | ||
147 | |||
148 | metadata=$(echo "$metadata" | jq ". + { \ | ||
149 | content: \"$(echo "$content" | sed -z 's/\\/\\\\/g;s/\n/\\n/g;s/"/\"/g')\", \ | ||
150 | date: { \ | ||
151 | yyyy_mm_dd: \"$date\", \ | ||
152 | rfc3339: \"$date_rfc3339\" \ | ||
153 | }, \ | ||
154 | last_update: { \ | ||
155 | yyyy_mm_dd: \"$last_update\", \ | ||
156 | rfc3339: \"$last_update_rfc3339\" \ | ||
157 | }, \ | ||
158 | url: { \ | ||
159 | rel: \"$url_rel\", \ | ||
160 | abs: \"$url_abs\", \ | ||
161 | full: \"$url_full\" \ | ||
162 | } \ | ||
163 | }") | ||
164 | |||
165 | pages=$(echo "$pages" | jq ".all += [ $metadata ]") | ||
166 | |||
167 | if [ "$date" != "" ]; then | ||
168 | date_year=$(date -d "$date" +%Y) | ||
169 | #date_month=$(date -d "$date" +%m) | ||
170 | #date_day=$(date -d "$date" +%d) | ||
171 | |||
172 | pages=$(echo "$pages" | jq ".by_year.\"$date_year\" += [ $metadata ]") | ||
173 | fi | ||
174 | |||
175 | if [ "$category" != "" ]; then | ||
176 | categories=$(echo "$categories" | jq ".$category = { name: \"$category_name\", count: (.$category.count + 1) } ") | ||
177 | fi | ||
178 | done | 99 | done |
179 | fi | 100 | fi |
180 | 101 | ||
181 | pages=$(echo "$pages" \ | 102 | echo "{ \"pages\": $pages }" |
182 | | jq ".all |= (sort_by(.date) | reverse) \ | ||
183 | | .by_year |= (to_entries | sort_by(.key) | reverse \ | ||
184 | | .[].value |= (sort_by(.date) | reverse))") | ||
185 | |||
186 | categories=$(echo "$categories" | jq ". | to_entries | { by_id: (. | sort_by(.key)), by_count: (. | sort_by(.value.count) | reverse) }") | ||
187 | |||
188 | echo "{}" | jq ". + { \ | ||
189 | pages: $pages, \ | ||
190 | categories: $categories | ||
191 | }" | ||
192 | } | 103 | } |
193 | 104 | ||
194 | handle () { | 105 | handle () { |
@@ -201,47 +112,10 @@ handle () { | |||
201 | 112 | ||
202 | echo -e "\033[0;90m[COMPILE ]\033[0m Getting metadata" | 113 | echo -e "\033[0;90m[COMPILE ]\033[0m Getting metadata" |
203 | 114 | ||
204 | included_metadata=$(get_metadata "$1") | 115 | included_metadata=$(get_metadata "$1" "$1") |
116 | added_metadata=$(get_subpages_metadata "$1") | ||
205 | 117 | ||
206 | create_feed=$(echo "$included_metadata" | jq -r .create_feed) | 118 | create_feed=$(echo "$included_metadata" | jq -r .create_feed) |
207 | |||
208 | url_abs=$(get_url_abs "$1" "html") | ||
209 | url_full="${SITE%/}$url_abs" | ||
210 | |||
211 | section=$(get_section "$1") | ||
212 | |||
213 | is_home=false | ||
214 | if [ "$target_file" = "${OUTPUT_DIR}index.html" ]; then | ||
215 | is_home=true | ||
216 | fi | ||
217 | |||
218 | added_metadata=$(echo "$(get_subpages_meta "$1")" | jq ". + { \ | ||
219 | url: { \ | ||
220 | abs: \"$url_abs\", \ | ||
221 | full: \"$url_full\" \ | ||
222 | }, \ | ||
223 | section: { \ | ||
224 | id: \"$section\", \ | ||
225 | is_$section: true \ | ||
226 | }, \ | ||
227 | is_home: $is_home \ | ||
228 | }") | ||
229 | |||
230 | if [ "$create_feed" = "true" ]; then | ||
231 | feed_url_abs="$(get_url_abs "$1" "xml")" | ||
232 | feed_url_full="${SITE%/}$feed_url_abs" | ||
233 | last_update=$(echo "$added_metadata" | jq -r ".pages.all[0].last_update") | ||
234 | |||
235 | added_metadata=$(echo "$added_metadata" | jq ". + { \ | ||
236 | feed: { \ | ||
237 | last_update: $last_update, \ | ||
238 | url: { \ | ||
239 | abs: \"$feed_url_abs\", \ | ||
240 | full: \"$feed_url_full\" \ | ||
241 | } \ | ||
242 | } \ | ||
243 | }") | ||
244 | fi | ||
245 | 119 | ||
246 | meta_file=$(mktemp) | 120 | meta_file=$(mktemp) |
247 | 121 | ||
@@ -256,8 +130,13 @@ handle () { | |||
256 | --no-highlight \ | 130 | --no-highlight \ |
257 | --template "${TEMPLATES_DIR}feed.xml" \ | 131 | --template "${TEMPLATES_DIR}feed.xml" \ |
258 | -o "${target_file%.html}.xml" \ | 132 | -o "${target_file%.html}.xml" \ |
133 | --metadata content_dir="$CONTENT_DIR" \ | ||
134 | --metadata base_file="$1" \ | ||
135 | --metadata file="$1" \ | ||
136 | --metadata type=feed \ | ||
259 | --metadata-file metadata/metadata.yaml \ | 137 | --metadata-file metadata/metadata.yaml \ |
260 | --metadata-file "$meta_file" \ | 138 | --metadata-file "$meta_file" \ |
139 | --lua-filter scripts/metadata_filter.lua \ | ||
261 | $FILTERS | 140 | $FILTERS |
262 | fi | 141 | fi |
263 | 142 | ||
@@ -269,15 +148,18 @@ handle () { | |||
269 | --no-highlight \ | 148 | --no-highlight \ |
270 | --template "${TEMPLATES_DIR}base.html" \ | 149 | --template "${TEMPLATES_DIR}base.html" \ |
271 | -o "$target_file" \ | 150 | -o "$target_file" \ |
151 | --metadata content_dir="$CONTENT_DIR" \ | ||
152 | --metadata base_file="$1" \ | ||
153 | --metadata file="$1" \ | ||
272 | --metadata-file metadata/metadata.yaml \ | 154 | --metadata-file metadata/metadata.yaml \ |
273 | --metadata-file "$meta_file" \ | 155 | --metadata-file "$meta_file" \ |
156 | --lua-filter scripts/metadata_filter.lua \ | ||
274 | $FILTERS | 157 | $FILTERS |
275 | 158 | ||
276 | rm "$meta_file" | 159 | rm "$meta_file" |
277 | 160 | ||
278 | # echo $(pandoc "$1" \ | 161 | # echo "$included_metadata" |
279 | # -f markdown \ | 162 | # echo "$added_metadata" |
280 | # -t json) | ||
281 | 163 | ||
282 | echo -e "\033[0;90m[COMPILE ]\033[0m Done" | 164 | echo -e "\033[0;90m[COMPILE ]\033[0m Done" |
283 | else | 165 | else |
diff --git a/scripts/metadata_filter.lua b/scripts/metadata_filter.lua new file mode 100644 index 0000000..f31bc1f --- /dev/null +++ b/scripts/metadata_filter.lua | |||
@@ -0,0 +1,225 @@ | |||
1 | function format_date(date) | ||
2 | if date == nil then | ||
3 | return date | ||
4 | end | ||
5 | |||
6 | date = pandoc.utils.normalize_date(pandoc.utils.stringify(date)) | ||
7 | local year, month, day = date:match("(%d%d%d%d)-(%d%d)-(%d%d)") | ||
8 | if year == nil then | ||
9 | return nil | ||
10 | end | ||
11 | |||
12 | local time = os.time({ | ||
13 | year = tonumber(year), | ||
14 | month = tonumber(month), | ||
15 | day = tonumber(day) | ||
16 | }) | ||
17 | return pandoc.MetaMap({ | ||
18 | yyyy_mm_dd = pandoc.MetaString(os.date("%F", time)), | ||
19 | yyyy = pandoc.MetaString(os.date("%Y", time)), | ||
20 | mm_dd = pandoc.MetaString(os.date("%m-%d", time)), | ||
21 | rfc3339 = pandoc.MetaString(os.date("%FT%T+00:00", time)) | ||
22 | }) | ||
23 | end | ||
24 | |||
25 | function table_to_list(t, cmp) | ||
26 | local l = pandoc.MetaList({}) | ||
27 | |||
28 | for key, value in pairs(t) do | ||
29 | l:insert(pandoc.MetaMap({ | ||
30 | key = key, | ||
31 | value = value | ||
32 | })) | ||
33 | end | ||
34 | |||
35 | l:sort(cmp or function(i1, i2) | ||
36 | return i1.key < i2.key | ||
37 | end) | ||
38 | |||
39 | return l | ||
40 | end | ||
41 | |||
42 | function splitstr(input, sep) | ||
43 | sep = sep or "%s" | ||
44 | local t = {} | ||
45 | for str in input:gmatch("([^" .. sep .. "]+)") do | ||
46 | table.insert(t, str) | ||
47 | end | ||
48 | return t | ||
49 | end | ||
50 | |||
51 | function relative_to(dir, target) | ||
52 | dir = splitstr(dir, "/") | ||
53 | target = splitstr(target, "/") | ||
54 | |||
55 | local prefix = true | ||
56 | local path = "" | ||
57 | |||
58 | for i = 1, math.min(#dir, #target) do | ||
59 | local t = target[i] | ||
60 | if prefix then | ||
61 | if dir[i] ~= t then | ||
62 | prefix = false | ||
63 | path = "../" .. t | ||
64 | end | ||
65 | else | ||
66 | path = "../" .. path .. "/" .. t | ||
67 | end | ||
68 | end | ||
69 | |||
70 | if #dir < #target then | ||
71 | for i = #dir + 1, #target do | ||
72 | path = path .. (path == "" and "" or "/") .. target[i] | ||
73 | end | ||
74 | elseif #dir > #target then | ||
75 | for i = #target + 1, #dir do | ||
76 | path = "../" .. path | ||
77 | end | ||
78 | end | ||
79 | |||
80 | return path | ||
81 | end | ||
82 | |||
83 | function resolve_url(page_type, site_url, content_dir, base_dir, cur_file) | ||
84 | if page_type == "page" then | ||
85 | cur_file = cur_file:gsub("%.md$", ".html") | ||
86 | elseif page_type == "feed" then | ||
87 | cur_file = cur_file:gsub("%.md$", ".xml") | ||
88 | end | ||
89 | |||
90 | local abs = cur_file:gsub("^" .. content_dir, ""):gsub("/index.html$", "/") | ||
91 | local rel = relative_to(base_dir, cur_file):gsub("/index.html$", "/") | ||
92 | |||
93 | return pandoc.MetaMap({ | ||
94 | abs = pandoc.MetaString(abs), | ||
95 | rel = pandoc.MetaString(rel), | ||
96 | full = pandoc.MetaString(site_url .. abs) | ||
97 | }) | ||
98 | end | ||
99 | |||
100 | function resolve_section(abs_url) | ||
101 | local section = abs_url:match("^/(.-)[/.]") or "index" | ||
102 | return pandoc.MetaMap({ | ||
103 | id = pandoc.MetaString(section), | ||
104 | ["is_" .. section] = pandoc.MetaBool(true) | ||
105 | }) | ||
106 | end | ||
107 | |||
108 | function organize_subpages(site_url, content_dir, base_dir, pages, categories) | ||
109 | local categories_data = pandoc.MetaList({}) | ||
110 | |||
111 | pages:sort(function(p1, p2) | ||
112 | if p1.date and p2.date then | ||
113 | return pandoc.utils.stringify(p1.date.yyyy_mm_dd) > pandoc.utils.stringify(p2.date.yyyy_mm_dd) | ||
114 | elseif p2.date then | ||
115 | return true | ||
116 | elseif p1.date then | ||
117 | return false | ||
118 | else | ||
119 | return pandoc.utils.stringify(p1.title) < pandoc.utils.stringify(p2.title) | ||
120 | end | ||
121 | end) | ||
122 | |||
123 | local pages_data = pandoc.MetaMap({ | ||
124 | all = pages, | ||
125 | by_year = pandoc.MetaList({}), | ||
126 | last_update = nil | ||
127 | }) | ||
128 | |||
129 | if pages then | ||
130 | local pages_by_year_map = {} | ||
131 | local categories_map = {} | ||
132 | |||
133 | for i = 1, #pages do | ||
134 | local page = pages[i] | ||
135 | |||
136 | if page.date then | ||
137 | local yyyy = pandoc.utils.stringify(page.date.yyyy) | ||
138 | local pages_by_yyyy = pages_by_year_map[yyyy] | ||
139 | |||
140 | if not pages_by_yyyy then | ||
141 | pages_by_yyyy = pandoc.MetaList(pandoc.List()) | ||
142 | pages_by_year_map[yyyy] = pages_by_yyyy | ||
143 | end | ||
144 | |||
145 | pages_by_yyyy:insert(page) | ||
146 | end | ||
147 | |||
148 | if page.category and categories then | ||
149 | local category = pandoc.utils.stringify(page.category) | ||
150 | |||
151 | if categories[category] then | ||
152 | local current_category = categories_map[category] | ||
153 | |||
154 | if not current_category then | ||
155 | current_category = pandoc.MetaMap({ | ||
156 | name = pandoc.MetaString(categories[category]), | ||
157 | count = 0 | ||
158 | }) | ||
159 | categories_map[category] = current_category | ||
160 | end | ||
161 | |||
162 | current_category.count = current_category.count + 1 | ||
163 | end | ||
164 | end | ||
165 | end | ||
166 | |||
167 | pages_data.by_year = table_to_list(pages_by_year_map, function(i1, i2) | ||
168 | return i1.key > i2.key | ||
169 | end) | ||
170 | |||
171 | categories_data = table_to_list(categories_map) | ||
172 | |||
173 | for _, item in ipairs(categories_data) do | ||
174 | item.value.count = pandoc.MetaString(("%d"):format(item.value.count)) | ||
175 | end | ||
176 | |||
177 | if #pages_data.by_year ~= 0 then | ||
178 | pages_data.last_update = pages_data.by_year[1].value[1].last_update | ||
179 | end | ||
180 | end | ||
181 | |||
182 | return pages_data, categories_data | ||
183 | end | ||
184 | |||
185 | function Meta(meta) | ||
186 | meta.content_dir = meta.content_dir:gsub("/$", "") | ||
187 | meta.site.url = pandoc.utils.stringify(meta.site.url):gsub("/$", "") | ||
188 | meta.base_dir = meta.base_file:gsub("^(.*)/.-$", "%1") | ||
189 | meta.type = meta.type or "page" | ||
190 | |||
191 | meta.date = format_date(meta.date) | ||
192 | if meta.last_update ~= nil then | ||
193 | meta.last_update = format_date(meta.last_update) | ||
194 | else | ||
195 | meta.last_update = meta.date | ||
196 | end | ||
197 | |||
198 | if meta.type == "feed" then | ||
199 | meta.page = pandoc.MetaMap({ | ||
200 | url = resolve_url("page", meta.site.url, meta.content_dir, meta.base_dir, meta.file) | ||
201 | }) | ||
202 | end | ||
203 | |||
204 | meta.url = resolve_url(meta.type, meta.site.url, meta.content_dir, meta.base_dir, meta.file) | ||
205 | meta.section = resolve_section(meta.url.abs) | ||
206 | meta.categories = meta.categories[meta.section.id] | ||
207 | |||
208 | if meta.menus and meta.menus.main then | ||
209 | for i = 1, #meta.menus.main do | ||
210 | local item = meta.menus.main[i] | ||
211 | item.active = pandoc.MetaBool(pandoc.utils.stringify(item.id) == meta.section.id) | ||
212 | end | ||
213 | end | ||
214 | |||
215 | if meta.pages then | ||
216 | local pages, categories = organize_subpages(meta.site.url, meta.content_dir, meta.base_dir, meta.pages, | ||
217 | meta.categories) | ||
218 | meta.pages = pages | ||
219 | meta.categories = categories | ||
220 | else | ||
221 | meta.categories = nil | ||
222 | end | ||
223 | |||
224 | return meta | ||
225 | end | ||
diff --git a/scripts/metadata_tpl.json b/scripts/metadata_tpl.json index 79eabe1..fb36f0f 100755 --- a/scripts/metadata_tpl.json +++ b/scripts/metadata_tpl.json | |||
@@ -1,6 +1 @@ | |||
1 | { | $meta-json$ | |
2 | "title": "$title$", | ||
3 | "date": "$date$", | ||
4 | "category": "$category$", | ||
5 | "create_feed": "$create_feed$" | ||
6 | } | ||
diff --git a/site.defaults.conf b/site.defaults.conf index b57abc1..50e45b5 100644 --- a/site.defaults.conf +++ b/site.defaults.conf | |||
@@ -1,5 +1,3 @@ | |||
1 | SITE="https://volpeon.ink/" | ||
2 | |||
3 | DEPLOY_TARGET="vulpes@94.130.78.123:/srv/http/volpeon.ink/" | 1 | DEPLOY_TARGET="vulpes@94.130.78.123:/srv/http/volpeon.ink/" |
4 | 2 | ||
5 | CONTENT_DIR="content/" | 3 | CONTENT_DIR="content/" |
diff --git a/templates/base.html b/templates/base.html index 18d65c8..3e079a1 100644 --- a/templates/base.html +++ b/templates/base.html | |||
@@ -22,22 +22,13 @@ | |||
22 | <link href="$it.url$" type="application/atom+xml" rel="alternate" title="$it.title$ – $site.title$" /> | 22 | <link href="$it.url$" type="application/atom+xml" rel="alternate" title="$it.title$ – $site.title$" /> |
23 | $endfor$ | 23 | $endfor$ |
24 | 24 | ||
25 | <title>$if(is_home)$$else$$title$ – $endif$$site.title$</title> | 25 | <title>$if(section.is_index)$$else$$title$ – $endif$$site.title$</title> |
26 | 26 | ||
27 | <link rel="preload" href="/style.css" as="style" /> | 27 | <link rel="preload" href="/style.css" as="style" /> |
28 | <link rel="preload" href="/iosevka-term-ss09-regular.woff2" as="font" type="font/woff2" crossorigin /> | 28 | <link rel="preload" href="/iosevka-term-ss09-regular.woff2" as="font" type="font/woff2" crossorigin /> |
29 | <link rel="preload" href="/iosevka-term-ss09-bold.woff2" as="font" type="font/woff2" crossorigin /> | 29 | <link rel="preload" href="/iosevka-term-ss09-bold.woff2" as="font" type="font/woff2" crossorigin /> |
30 | 30 | ||
31 | <link rel="stylesheet" href="/style.css" /> | 31 | <link rel="stylesheet" href="/style.css" /> |
32 | $if(section.id)$ | ||
33 | <style> | ||
34 | .c-nav__item--$section.id$ { | ||
35 | border-color: var(--nav--item--active--fg); | ||
36 | color: var(--nav--item--active--fg); | ||
37 | font-weight: bold; | ||
38 | } | ||
39 | </style> | ||
40 | $endif$ | ||
41 | </head> | 32 | </head> |
42 | 33 | ||
43 | <body> | 34 | <body> |
@@ -45,14 +36,14 @@ | |||
45 | <div class="c-nav__items l-container"> | 36 | <div class="c-nav__items l-container"> |
46 | <a class="c-nav__logo" href="/" title="$site.title$">$site.logo$</a> | 37 | <a class="c-nav__logo" href="/" title="$site.title$">$site.logo$</a> |
47 | $for(menus.main)$ | 38 | $for(menus.main)$ |
48 | <a class="c-nav__item c-nav__item--$it.id$" href="$it.url$">$it.label$</a> | 39 | <a class="c-nav__item $if(it.active)$c-nav__item--active$endif$" href="$it.url$">$it.label$</a> |
49 | $endfor$ | 40 | $endfor$ |
50 | </div> | 41 | </div> |
51 | </nav> | 42 | </nav> |
52 | 43 | ||
53 | <main class="c-page s-page l-container l-container--content l-container--pad-v"> | 44 | <main class="c-page s-page l-container l-container--content l-container--pad-v"> |
54 | <div class="c-page__content"> | 45 | <div class="c-page__content"> |
55 | $if(is_home)$ | 46 | $if(section.is_index)$ |
56 | <header class="c-page-header u-hidden@sm-down" role="presentation"> | 47 | <header class="c-page-header u-hidden@sm-down" role="presentation"> |
57 | ${partials/pageHeader()} | 48 | ${partials/pageHeader()} |
58 | </header> | 49 | </header> |
@@ -66,7 +57,7 @@ ${page()} | |||
66 | </div> | 57 | </div> |
67 | </main> | 58 | </main> |
68 | 59 | ||
69 | $if(is_home)$ | 60 | $if(section.is_index)$ |
70 | <template id="header-sm"> | 61 | <template id="header-sm"> |
71 | ${partials/pageHeaderSm()} | 62 | ${partials/pageHeaderSm()} |
72 | </template> | 63 | </template> |
diff --git a/templates/feed.xml b/templates/feed.xml index 4cc2c17..083049e 100644 --- a/templates/feed.xml +++ b/templates/feed.xml | |||
@@ -1,9 +1,9 @@ | |||
1 | <?xml version="1.0" encoding="utf-8"?> | 1 | <?xml version="1.0" encoding="utf-8"?> |
2 | <feed xmlns="http://www.w3.org/2005/Atom"> | 2 | <feed xmlns="http://www.w3.org/2005/Atom"> |
3 | <title>$if(is_home)$$else$$title$ – $endif$$site.title$</title> | 3 | <title>$if(section.is_index)$$else$$title$ – $endif$$site.title$</title> |
4 | <link href="$feed.url.full$" rel="self"/> | 4 | <link href="$url.full$" rel="self"/> |
5 | <link href="$url.full$"/> | 5 | <link href="$page.url.full$"/> |
6 | <updated>$feed.last_update.rfc3339$</updated> | 6 | <updated>$pages.last_update.rfc3339$</updated> |
7 | <id>$url.full$</id> | 7 | <id>$url.full$</id> |
8 | $for(author)$ | 8 | $for(author)$ |
9 | <author> | 9 | <author> |
@@ -16,7 +16,7 @@ | |||
16 | 16 | ||
17 | $for(pages)$ | 17 | $for(pages)$ |
18 | $for(it.all)$ | 18 | $for(it.all)$ |
19 | $if(it.date.rfc3339)$ | 19 | $if(it.date)$ |
20 | <entry> | 20 | <entry> |
21 | <id>$it.url.full$</id> | 21 | <id>$it.url.full$</id> |
22 | <title type="html"><![CDATA[$it.title$]]></title> | 22 | <title type="html"><![CDATA[$it.title$]]></title> |
diff --git a/templates/list.html b/templates/list.html index 4d62d47..2d663e0 100644 --- a/templates/list.html +++ b/templates/list.html | |||
@@ -1,8 +1,8 @@ | |||
1 | $body$ | 1 | $body$ |
2 | 2 | ||
3 | $if(categories.by_id)$ | 3 | $if(categories)$ |
4 | <ul class="c-hlist"> | 4 | <ul class="c-hlist"> |
5 | $for(categories.by_id)$ | 5 | $for(categories)$ |
6 | <li class="c-hlist__item"><strong>$it.key/uppercase$</strong> $it.value.name$</li> | 6 | <li class="c-hlist__item"><strong>$it.key/uppercase$</strong> $it.value.name$</li> |
7 | $endfor$ | 7 | $endfor$ |
8 | </ul> | 8 | </ul> |
diff --git a/templates/partials/pageHeaderSm.html b/templates/partials/pageHeaderSm.html index 4255de0..92359fa 100644 --- a/templates/partials/pageHeaderSm.html +++ b/templates/partials/pageHeaderSm.html | |||
@@ -3,7 +3,7 @@ $-- | _.~-"""-----~`` ,-´ ' ' |' | ' ' | |||
3 | $-- '| .´ ,~'\ ).,__,)/,," ' . ' | | | ' .' | 3 | $-- '| .´ ,~'\ ).,__,)/,," ' . ' | | | ' .' |
4 | $-- |_ `~´ (/\\, (/\\, _' '_ _| ' |_ _' '_ | 4 | $-- |_ `~´ (/\\, (/\\, _' '_ _| ' |_ _' '_ |
5 | 5 | ||
6 | <pre class="c-page-header__pre c-page__prefixed c-page__prefixed--pre u-mt0 $if(is_home)$u-hidden@sm-up$endif$"> | 6 | <pre class="c-page-header__pre c-page__prefixed c-page__prefixed--pre u-mt0 $if(section.is_index)$u-hidden@sm-up$endif$"> |
7 | .| <strong> //\__</strong> ' .' | . | ' . ' | 7 | .| <strong> //\__</strong> ' .' | . | ' . ' |
8 | | <strong> _.~-"""-----~`` ,-´</strong> ' ' |' | ' ' | 8 | | <strong> _.~-"""-----~`` ,-´</strong> ' ' |' | ' ' |
9 | '| <strong>.´ ,~'\ ).,__,)/,," </strong> ' . ' | | | ' .' | 9 | '| <strong>.´ ,~'\ ).,__,)/,," </strong> ' . ' | | | ' .' |