poops 1.5.0 → 1.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/lib/markup/engines/liquid.js +9 -1
- package/lib/markup/engines/nunjucks.js +11 -2
- package/lib/markups.js +4 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -910,7 +910,7 @@ All filters are available in both engines. The only syntax difference is how arg
|
|
|
910
910
|
|
|
911
911
|
- `jsonify` — serializes a value to JSON. Usage: `{{ myObject | jsonify }}`
|
|
912
912
|
|
|
913
|
-
- `markdown` — renders a markdown string to HTML with GitHub
|
|
913
|
+
- `markdown` — renders a markdown string to HTML with GitHub Flavored Markdown extras: emoji shortcodes (e.g. `:rocket:` → 🚀), alert callouts (`> [!NOTE]`, `[!TIP]`, `[!IMPORTANT]`, `[!WARNING]`, `[!CAUTION]`, `[!INFO]`) and footnotes (`[^1]`). Code fences are syntax-highlighted and headings get slug `id`s plus permalink anchors. Usage: `{{ "**bold** :rocket:" | markdown }}`
|
|
914
914
|
|
|
915
915
|
- `date` — formats a date string. Uses [dayjs](https://day.js.org/) format tokens. A default format can be set via the `timeDateFormat` config option.
|
|
916
916
|
- Nunjucks: `{{ "2024-01-15" | date("MMMM D, YYYY") }}`
|
|
@@ -27,7 +27,11 @@ export default class LiquidEngine {
|
|
|
27
27
|
this.engine = new Liquid({
|
|
28
28
|
root: roots,
|
|
29
29
|
extname: '.liquid',
|
|
30
|
-
cache:
|
|
30
|
+
// Parsed-template cache: without it every {% render %}/{% include %}
|
|
31
|
+
// re-resolves (realpath per root) and re-parses the partial on every
|
|
32
|
+
// page — dominates build time on partial-heavy sites. Cleared per
|
|
33
|
+
// compile (clearCache) so watch-mode edits are picked up.
|
|
34
|
+
cache: true,
|
|
31
35
|
dynamicPartials: true,
|
|
32
36
|
strictFilters: false,
|
|
33
37
|
strictVariables: false,
|
|
@@ -106,6 +110,10 @@ export default class LiquidEngine {
|
|
|
106
110
|
delete this.globals[key]
|
|
107
111
|
}
|
|
108
112
|
|
|
113
|
+
clearCache() {
|
|
114
|
+
if (this.engine.options.cache) this.engine.options.cache.clear()
|
|
115
|
+
}
|
|
116
|
+
|
|
109
117
|
async render(templateName, context) {
|
|
110
118
|
let source
|
|
111
119
|
const frontMatterResult = parseFrontMatter(templateName)
|
|
@@ -30,6 +30,7 @@ class RelativeLoader extends nunjucks.Loader {
|
|
|
30
30
|
}
|
|
31
31
|
if (!fs.existsSync(fullPath)) {
|
|
32
32
|
log({ tag: 'markup', error: true, text: 'Template not found:', link: name })
|
|
33
|
+
// noCache so a template created mid-watch is found on the next compile
|
|
33
34
|
return { src: '', path: fullPath, noCache: true }
|
|
34
35
|
}
|
|
35
36
|
|
|
@@ -53,7 +54,10 @@ class RelativeLoader extends nunjucks.Loader {
|
|
|
53
54
|
source = `{% extends '${frontMatter.layout}.html' %}\n{% block content %}\n${source}\n{% endblock %}`
|
|
54
55
|
}
|
|
55
56
|
|
|
56
|
-
|
|
57
|
+
// Cached: getSource does glob resolution + front matter + markdown per
|
|
58
|
+
// call, so re-running it per include per page dominates builds. Cleared
|
|
59
|
+
// per compile (clearCache) so watch-mode edits are picked up.
|
|
60
|
+
return { src: source, path: fullPath, noCache: false }
|
|
57
61
|
}
|
|
58
62
|
|
|
59
63
|
resolve(from, to) {
|
|
@@ -67,10 +71,15 @@ export default class NunjucksEngine {
|
|
|
67
71
|
|
|
68
72
|
this.env = new nunjucks.Environment(
|
|
69
73
|
new RelativeLoader(templatesDir, includePaths),
|
|
70
|
-
{ autoescape, watch: false
|
|
74
|
+
{ autoescape, watch: false }
|
|
71
75
|
)
|
|
72
76
|
}
|
|
73
77
|
|
|
78
|
+
clearCache() {
|
|
79
|
+
// nunjucks keeps compiled templates on each loader's cache object
|
|
80
|
+
for (const loader of this.env.loaders) loader.cache = {}
|
|
81
|
+
}
|
|
82
|
+
|
|
74
83
|
get fileExtension() { return '.njk' }
|
|
75
84
|
get indexableExtensions() { return new Set(['.html', '.md', '.njk']) }
|
|
76
85
|
get markupExtensions() { return 'html|xml|rss|atom|json|njk|md' }
|
package/lib/markups.js
CHANGED
|
@@ -375,6 +375,9 @@ export default class Markups {
|
|
|
375
375
|
throw err
|
|
376
376
|
} finally {
|
|
377
377
|
clearFrontMatterCache()
|
|
378
|
+
// Engine template caches live for one compile: fast within a build,
|
|
379
|
+
// watch-mode edits always picked up on the next one
|
|
380
|
+
if (typeof this.engine.clearCache === 'function') this.engine.clearCache()
|
|
378
381
|
}
|
|
379
382
|
}
|
|
380
383
|
|
|
@@ -426,6 +429,7 @@ export default class Markups {
|
|
|
426
429
|
throw err
|
|
427
430
|
} finally {
|
|
428
431
|
clearFrontMatterCache()
|
|
432
|
+
if (typeof this.engine.clearCache === 'function') this.engine.clearCache()
|
|
429
433
|
}
|
|
430
434
|
}
|
|
431
435
|
|