-
Notifications
You must be signed in to change notification settings - Fork 0
/
soupault.toml
337 lines (258 loc) · 11.5 KB
/
soupault.toml
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
### Configuration file for the soupault website generator ###
## Global settings
[settings]
# Caching
caching = true
# Show build progress
verbose = false
# Show detailed debug information
debug = false
# Fail on page processing errors
strict = true
# Where generated files go
build_dir = "build/"
# Where page files are stored
site_dir = "site/"
# HTML page skeleton file to insert content into
default_template_file = "templates/main.html"
# Insert the content in <main>, after existing children (if any)
default_content_selector = "main"
default_content_action = "append_child"
# Page considered the section index
index_page = "index"
page_file_extensions = ["html", "md"]
doctype = "<!DOCTYPE html>"
# Automatically load Lua plugins from plugins/
# E.g. plugins/reading-time.lua is automatically loaded as "reading-time" widget.
plugin_discovery = true
plugin_dirs = ["plugins"]
# Options in the [custom_options] table aren't soupault built-ins.
# It's a table for options that can be shared between multiple plugins.
[custom_options]
# Number of "lastest post" to display on the main page
blog_summary_max_entries = 10
## Atom feed settings
atom_feeds = true
# If you want to generate Atom feeds, you will need to adjust the site metadata config below:
# Required:
site_url = "https://2ngblog.netlify.app"
# Optional but strongly recommended:
site_author = "Linsy"
site_author_email = "kxiang@umich.edu"
site_title = "2-ng blog"
# site_logo = ""
# Completely optional:
# site_subtitle = "2-ng"
[asset_processors]
ipe = "SRC={{source_file_path}} DSTB={{target_dir}}/{{source_file_base_name}} DST=$DSTB.png TOOL=IPE make $DST"
svg = "SRC={{source_file_path}} DSTB={{target_dir}}/{{source_file_base_name}} DST=$DSTB.png TOOL=SVG make $DST"
# js = "SRC={{source_file_path}} DST={{target_dir}}/{{source_file_base_name}} TOOL=JS make"
[preprocessors]
# Automatically call pandoc on every *.md page to convert it to HTML
md = 'node scripts/md.mjs'
## Autogenerated section index settings
[index]
index = true
# section = "blog/"
sort_descending = true
extract_after_widgets = ['insert-reading-time', 'make-post-header']
sort_by = "initdate"
date_formats = ["%Y-%m-%d %H:%M:%S"]
# A directory with a .leaf file in it is treated as hand-made "clean URL",
# rather than a section.
leaf_file = ".leaf"
[index.fields]
title = { selector = ["#post-title", "h1"] }
excerpt = { selector = ["#post-excerpt", "p"] }
date = { selector = ["#post-date"] }
initdate = { selector = ["#post-initdate"] }
secret = { selector = ["#encrypted"] }
tags = { selector = ".post-tag", select_all = true }
reading_time = { selector = "#reading-time" }
[index.views.blog-index]
# Insert generated index into an element that matches "#blog-index" selector.
index_selector = "#blog-entries"
# Only extract metadata from pages in site/blog/*
section = "blog"
include_subsections = true
# Jingoo template for rendering extracted metadata
index_template = """
{% for e in entries %}
<h2><a href="{{e.url}}">{{e.title}}</a>
{% if e.secret %}
<strong>*</strong>
{% endif %}
</h2>
{% if e.date %}
<div><strong>Last update:</strong> {{e.date}}</div>
{% endif %}
{% if e.initdate %}
<div><strong>Publish date:</strong> {{e.initdate}}</div>
{% endif %}
{% if e.tags %}
<div class="post-tags">
<strong>Tags: </strong>
{%- for t in e.tags -%}
<a href="/blog/tag/{{t}}" style="text-decoration: none;">
<div class="tag-container">
<svg t="1721493582945" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="1460" width="20" height="20"><path d="M323.008 786.752c-52.928 0-96-43.072-96-96s43.072-96 96-96 96 43.072 96 96S375.936 786.752 323.008 786.752zM323.008 658.752c-17.632 0-32 14.336-32 32s14.368 32 32 32 32-14.336 32-32S340.64 658.752 323.008 658.752z" fill="#1296db" p-id="1461"></path><path d="M416.096 927.072 284.224 927.072c-159.936 0-186.912-59.232-186.912-192l0-140.8c0-74.272 14.304-96.256 70.72-150.976l327.04-319.904c36.576-35.488 105.888-35.392 142.304-0.096l263.072 256.032c18.336 17.792 28.864 43.552 28.864 70.656 0 27.296-10.656 53.28-29.248 71.264l-290.016 294.592C544.544 880.416 497.216 927.072 416.096 927.072zM566.24 159.488c-10.496 0-20.16 3.52-26.528 9.696l-327.04 319.936c-49.952 48.48-51.36 54.528-51.36 105.152l0 140.8c0 110.272 8.352 128 122.912 128l131.872 0c52.672 0 83.744-28.48 148.992-92.8l26.656-26.144 263.232-268.256c6.784-6.592 10.336-15.808 10.336-25.888 0-9.888-3.424-18.88-9.472-24.736l-263.072-256.032C586.432 163.04 576.736 159.488 566.24 159.488z" fill="#1296db" p-id="1462"></path></svg>
<p style="margin-left:3px;font-size: 14px; color: #822082" class="post-tag">{{t}}</p>
</div>
</a>
{%- endfor -%}
</div>
{% endif %}
<div><strong>Reading time:</strong> {{e.reading_time}}</div>
<a href="{{e.url}}">Read more</a>
{% endfor %}
"""
# Override soupault's built-in index processor with a custom Lua script.
# That script is written to mimic the built-in indexer behavior,
# it will take a template from the index_template option.
file = "helpers/blog-index.lua"
# This view displays the first ten entries on the main page
[index.views.blog-summary]
index_selector = "#latest-blog-entries"
section = "blog"
include_subsections = true
sort_by = "date"
# In this case index_template is a soupault built-in
index_template = """
{% set limit = int(soupault_config.custom_options.blog_summary_max_entries) %}
<dl>
{% for e in sublist(0, limit, entries) %}
<dt>{{e.date}}</dt>
<dd> <a href="{{e.url}}">{{e.title}}</a> </dd>
{% endfor %}
</ul>
</dl>
"""
## Widgets
# Takes the content of the first #page-title element or <h1> and inserts it into the <title>
# default is used if page has no elements matching those selectors.
[widgets.set-page-title]
widget = "title"
# Must run only after the header with an <h1 id="post-title"> element is inserted, which affects the blog section pages
after = 'make-post-header'
selector = ["#page-title", "h1"]
default = "2-ng blog"
append = " — 2-ng"
# Inserts the contents of templates/header.html right before the <main> element
# There's a variety of actions, including prepend_child and replace_content
[widgets.insert-header]
widget = "include"
selector = "main"
action = "insert_before"
file = "templates/header.html"
# This widget comes from plugins/section-link-highlight.lua
# It highlights the "active" link in the navigation menu,
# that is, the link that matches the current page URL
[widgets.highlight-active-link]
widget = "section-link-highlight"
# Must run only after the header with a navigation menu is inserted
after = ["insert-header"]
selector = "nav"
active_link_class = "nav-active"
# Inserts the contents of templates/footer.html at the end of the <body>
[widgets.insert-footer]
widget = "include"
selector = "body"
action = "append_child"
file = "templates/footer.html"
[widgets.make-post-header]
widget = "post-header"
section = "blog/"
include_subsections = true
exclude_page = "blog/index.md"
content_container_selector = "main"
post_header_template = '''
<div id="post-header">
<h1 id="post-title">{{title}}</h1>
{% if date %}
<div><strong>Last update:</strong> <time id="post-date" datetime="{{date}}">{{date}}</time></div>
{% endif %}
{% if initdate %}
<div><strong>Publish date:</strong> <time id="post-initdate" datetime="{{initdate}}">{{initdate}}</time></div>
{% endif %}
{% if tags %}
<div class="post-tags">
<span><strong>Tags:</strong> </span>
{%- for t in tags -%}
<a href="/blog/tag/{{t}}" style="text-decoration: none;">
<div class="tag-container">
<svg t="1721493582945" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="1460" width="20" height="20"><path d="M323.008 786.752c-52.928 0-96-43.072-96-96s43.072-96 96-96 96 43.072 96 96S375.936 786.752 323.008 786.752zM323.008 658.752c-17.632 0-32 14.336-32 32s14.368 32 32 32 32-14.336 32-32S340.64 658.752 323.008 658.752z" fill="#1296db" p-id="1461"></path><path d="M416.096 927.072 284.224 927.072c-159.936 0-186.912-59.232-186.912-192l0-140.8c0-74.272 14.304-96.256 70.72-150.976l327.04-319.904c36.576-35.488 105.888-35.392 142.304-0.096l263.072 256.032c18.336 17.792 28.864 43.552 28.864 70.656 0 27.296-10.656 53.28-29.248 71.264l-290.016 294.592C544.544 880.416 497.216 927.072 416.096 927.072zM566.24 159.488c-10.496 0-20.16 3.52-26.528 9.696l-327.04 319.936c-49.952 48.48-51.36 54.528-51.36 105.152l0 140.8c0 110.272 8.352 128 122.912 128l131.872 0c52.672 0 83.744-28.48 148.992-92.8l26.656-26.144 263.232-268.256c6.784-6.592 10.336-15.808 10.336-25.888 0-9.888-3.424-18.88-9.472-24.736l-263.072-256.032C586.432 163.04 576.736 159.488 566.24 159.488z" fill="#1296db" p-id="1462"></path></svg>
<p style="margin-left:3px;font-size: 14px; color: #822082" class="post-tag">{{t}}</p>
</div>
</a>
{%- endfor -%}
</div>
{% endif %}
{% if secret %}
<div><strong id="encrypted">This is a secret post.</strong></div>
{% endif %}
</div>
'''
# Why require adding a target element for the reading-time plugin by hand?
# We'll insert it automatically
[widgets.insert-reading-time-container]
widget = "insert_html"
after = "make-post-header"
# Reading time container should only be in blog/*
section = "blog/"
include_subsections = true
# ...but not in blog/index.html
exclude_path_regex = "blog/tag/*"
# Insert the reading time container right after the post title in <h1>
action = "append_child"
selector = "#post-header"
html = '<div><strong>Reading time:</strong> <span id="reading-time"></span></div>'
# This widget comes from plugins/reading-time.lua
# It calculates estimated reading time based on word count
[widgets.insert-reading-time]
widget = "reading-time"
reading_speed = 100
# If this widget runs before "insert-reading-time-container",
# there will be nowhere to insert the reading time.
# This is why we explicitly schedule it to run after that widget.
after = "insert-reading-time-container"
selector = "#reading-time"
# The element where it looks for page "content"
content_selector = "main"
# Inserts a table of contents generated from page headings
[widgets.table-of-contents]
#exclude_path_regex = '/index(.*)'
widget = "toc"
selector = "#generated-toc"
min_level = 2
toc_list_class = "toc"
toc_class_levels = false
valid_html = true
numbered_list = true
heading_links = true
heading_link_text = "→ "
heading_link_class = "here"
use_heading_slug = true
[widgets.insert-footnotes-container]
widget = "insert-if"
selector = "main"
check_selector = "fn"
html = '<div id="footnotes"> </div>'
[widgets.footnotes]
widget = "footnotes"
after = "insert-footnotes-container"
selector = "div#footnotes"
footnote_selector = ["fn"]
footnote_link_class = "footnote"
back_links = true
link_id_prepend = "footnote-"
back_link_id_append = "-ref"
[widgets.atom]
widget = "atom"
page = "blog/index.md"
feed_file = "atom.xml"
use_section = "blog"
include_subsections = true
[widgets.highlight]
widget = "preprocess_element"
selector = '*[class^="language-"]'
command = 'highlight -O html -f --syntax=$(echo $ATTR_CLASS | sed -e "s/language-//")'