vowel 0.6.4 → 0.7.0-beta.0
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/bin.js +47 -27
- package/cli.js +15 -0
- package/config.js +93 -26
- package/extractDate.js +70 -6
- package/index.js +14 -5
- package/package.json +39 -8
- package/plugins/assets/index.js +65 -0
- package/plugins/atproto/index.js +132 -0
- package/plugins/atproto/password.js +71 -0
- package/plugins/atproto/publish.js +406 -0
- package/plugins/atproto/record.js +144 -0
- package/plugins/atproto/rkey.js +54 -0
- package/plugins/deploy-cloudflare/index.js +30 -16
- package/plugins/fonts/index.js +18 -21
- package/plugins/html/assets/bundle-BeK1Hptv.css +21 -0
- package/plugins/html/bundle/assets/index-BeK1Hptv.css +21 -0
- package/plugins/html/bundle/index.js +21145 -0
- package/plugins/html/editor/EditButton.svelte +152 -0
- package/plugins/html/editor/Editor.svelte +51 -0
- package/plugins/html/editor/Overlays.svelte +6 -0
- package/plugins/html/editor/SettingsPanel.svelte +397 -0
- package/plugins/html/editor/Toolbar.svelte +644 -0
- package/plugins/html/editor/create-session.js +250 -0
- package/plugins/html/editor/directives.js +128 -0
- package/plugins/html/editor/frontmatter.js +97 -0
- package/plugins/html/editor/ingest.js +339 -0
- package/plugins/html/editor/main.js +94 -0
- package/plugins/html/editor/nodes/Alert.svelte +21 -0
- package/plugins/html/editor/nodes/Blockquote.svelte +9 -0
- package/plugins/html/editor/nodes/CodeBlock.svelte +19 -0
- package/plugins/html/editor/nodes/Embed.svelte +19 -0
- package/plugins/html/editor/nodes/Emphasis.svelte +11 -0
- package/plugins/html/editor/nodes/Heading.svelte +15 -0
- package/plugins/html/editor/nodes/Highlight.svelte +11 -0
- package/plugins/html/editor/nodes/Image.svelte +18 -0
- package/plugins/html/editor/nodes/InlineCode.svelte +11 -0
- package/plugins/html/editor/nodes/Link.svelte +17 -0
- package/plugins/html/editor/nodes/List.svelte +15 -0
- package/plugins/html/editor/nodes/ListItem.svelte +9 -0
- package/plugins/html/editor/nodes/Page.svelte +21 -0
- package/plugins/html/editor/nodes/Paragraph.svelte +9 -0
- package/plugins/html/editor/nodes/Strikethrough.svelte +11 -0
- package/plugins/html/editor/nodes/Strong.svelte +11 -0
- package/plugins/html/editor/nodes/ThematicBreak.svelte +9 -0
- package/plugins/html/editor/nodes/index.js +18 -0
- package/plugins/html/editor/rollup.config.js +35 -0
- package/plugins/html/editor/serialize.js +157 -0
- package/plugins/html/editor/settings-file.js +83 -0
- package/plugins/html/editor/socket.js +202 -0
- package/plugins/html/editor/source.js +43 -0
- package/plugins/html/image.js +31 -5
- package/plugins/html/index.js +430 -458
- package/plugins/html/partials.js +299 -0
- package/plugins/html/socialLinks.js +67 -0
- package/plugins/html/writeRules.js +377 -0
- package/plugins/icons/index.js +2 -6
- package/plugins/images/index.js +78 -55
- package/plugins/markdown/brandColors.js +10 -0
- package/plugins/markdown/colorScheme.js +64 -0
- package/plugins/markdown/emoji.js +30 -0
- package/plugins/markdown/frontmatter.js +253 -0
- package/plugins/markdown/index.js +276 -334
- package/plugins/markdown/links.js +97 -0
- package/plugins/markdown/metadata.js +229 -68
- package/plugins/markdown/readRules.js +143 -0
- package/plugins/markdown/typography.js +109 -0
- package/plugins/markdown/visitor.js +143 -0
- package/plugins/publish/index.js +34 -0
- package/plugins/robots/agents.js +79 -0
- package/plugins/robots/index.js +30 -10
- package/plugins/robots/robots.js +48 -0
- package/plugins/styles/index.js +111 -18
- package/plugins/styles/theme.js +116 -0
- package/plugins/urls/index.js +49 -62
- package/plugins/urls/urlMetadata.js +246 -0
- package/plugins/vectors/index.js +5 -9
- package/plugins/xml/entryContent.js +103 -0
- package/plugins/xml/index.js +105 -43
- package/secretPaths.js +170 -0
- package/stylesheets/DefaultStyles.css +367 -437
- package/stylesheets/ResetStyles.css +2 -38
- package/stylesheets/SyntaxHighlightingStyles.css +36 -4
- package/stylesheets/TypographyStyles.css +386 -128
- package/systemPaths.js +48 -0
- package/utils.js +56 -5
- package/.github/ISSUE_TEMPLATE/bug_report.md +0 -73
- package/.github/ISSUE_TEMPLATE/config.yml +0 -7
- package/docs-source/.cache.json +0 -9
- package/docs-source/.obsidian/app.json +0 -3
- package/docs-source/.obsidian/appearance.json +0 -3
- package/docs-source/.obsidian/core-plugins-migration.json +0 -30
- package/docs-source/.obsidian/core-plugins.json +0 -20
- package/docs-source/.obsidian/workspace.json +0 -168
- package/docs-source/.stackblitzrc +0 -3
- package/docs-source/.votive.db +0 -0
- package/docs-source/about.md +0 -3
- package/docs-source/blog/home.md +0 -5
- package/docs-source/blog/url-ui.md +0 -21
- package/docs-source/blog.md +0 -5
- package/docs-source/docs/.votive.db +0 -0
- package/docs-source/docs/deploy.md +0 -67
- package/docs-source/docs/file-structure.md +0 -31
- package/docs-source/docs/folder-settings.md +0 -23
- package/docs-source/docs/home.md +0 -55
- package/docs-source/docs/images.md +0 -10
- package/docs-source/docs/items.md +0 -13
- package/docs-source/docs/pages.md +0 -141
- package/docs-source/docs/settings.md +0 -4
- package/docs-source/docs/styling.md +0 -34
- package/docs-source/docs/taxonomies.md +0 -37
- package/docs-source/features/cards.md +0 -7
- package/docs-source/features/editing.md +0 -7
- package/docs-source/features/emoji.md +0 -7
- package/docs-source/features/frontmatter.md +0 -7
- package/docs-source/features/lists.md +0 -7
- package/docs-source/features/navigation.md +0 -7
- package/docs-source/features/rich-previews.md +0 -7
- package/docs-source/features/robots.md +0 -7
- package/docs-source/features/rss.md +0 -7
- package/docs-source/features/sitemap.md +0 -7
- package/docs-source/features/speed.md +0 -7
- package/docs-source/features/static.md +0 -7
- package/docs-source/features/taxonomies.md +0 -7
- package/docs-source/home.md +0 -42
- package/docs-source/output/about.html +0 -1
- package/docs-source/output/blog/url-ui.html +0 -8
- package/docs-source/output/blog.html +0 -1
- package/docs-source/output/default.css +0 -1
- package/docs-source/output/docs/deploy.html +0 -34
- package/docs-source/output/docs/file-structure.html +0 -24
- package/docs-source/output/docs/folder-settings.html +0 -20
- package/docs-source/output/docs/images.html +0 -2
- package/docs-source/output/docs/items.html +0 -6
- package/docs-source/output/docs/pages.html +0 -101
- package/docs-source/output/docs/styling.html +0 -18
- package/docs-source/output/docs/taxonomies.html +0 -20
- package/docs-source/output/docs.html +0 -28
- package/docs-source/output/features/cards.html +0 -1
- package/docs-source/output/features/editing.html +0 -1
- package/docs-source/output/features/emoji.html +0 -1
- package/docs-source/output/features/frontmatter.html +0 -1
- package/docs-source/output/features/lists.html +0 -1
- package/docs-source/output/features/navigation.html +0 -1
- package/docs-source/output/features/rich-previews.html +0 -1
- package/docs-source/output/features/robots.html +0 -1
- package/docs-source/output/features/rss.html +0 -1
- package/docs-source/output/features/sitemap.html +0 -1
- package/docs-source/output/features/speed.html +0 -1
- package/docs-source/output/features/static.html +0 -1
- package/docs-source/output/features/taxonomies.html +0 -1
- package/docs-source/output/features.html +0 -1
- package/docs-source/output/feed.xml +0 -1
- package/docs-source/output/index.html +0 -21
- package/docs-source/output/reset.css +0 -1
- package/docs-source/output/roadmap.html +0 -87
- package/docs-source/output/robots.txt +0 -14
- package/docs-source/output/sitemap.xml +0 -16
- package/docs-source/output/typography.css +0 -1
- package/docs-source/roadmap.md +0 -98
- package/docs-source/settings.md +0 -13
- package/getMetadata.js +0 -41
- package/jsconfig.json +0 -10
- package/plugins/markdown/robots.js +0 -18
- package/regex.js +0 -36
- package/stylesheets/brand-colors.css +0 -119
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
import yaml from "yaml"
|
|
2
|
+
import path from "node:path"
|
|
3
|
+
import { fromMarkdown } from "mdast-util-from-markdown"
|
|
4
|
+
import extractDate from "../../extractDate.js"
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* How vowel handles a frontmatter block. Stated once, here, per Sam
|
|
8
|
+
* (Sept 19); votive's side of the same policy is `votive/lib/attempt.js`.
|
|
9
|
+
*
|
|
10
|
+
* 1. **YAML that does not parse is not frontmatter.** The block goes
|
|
11
|
+
* back into the content as the markdown it would have been without
|
|
12
|
+
* the frontmatter extension - the `---` lines are thematic breaks,
|
|
13
|
+
* the lines between them prose - and an error names the file and the
|
|
14
|
+
* parser's complaint. Nothing is inferred from it. (`readFrontmatter`)
|
|
15
|
+
*
|
|
16
|
+
* 2. **A value that is not what vowel expects is logged and coerced.**
|
|
17
|
+
* `EXPECTED` below is the contract, one entry per key vowel reads:
|
|
18
|
+
* the shape it wants and how a wrong one is coerced. A coercion that
|
|
19
|
+
* can recover a value does (`title: [a, b]` → "a, b"; `tags: x` →
|
|
20
|
+
* ["x"]; `image: {src: x}` → "x"; `date: 03/04/2026` → ISO); one that
|
|
21
|
+
* cannot drops the key (`date: Thursday`), so downstream code never
|
|
22
|
+
* sees a shape it did not ask for. Either way one error line names
|
|
23
|
+
* the file, the key and what was found. Keys not in the table are the
|
|
24
|
+
* author's own and are stored as written. (`coerce`)
|
|
25
|
+
*
|
|
26
|
+
* 3. **A path is a URL path from the root.** `logo: x.svg` and
|
|
27
|
+
* `logo: /x.svg` both mean `/x.svg`; `./x.svg` is resolved against
|
|
28
|
+
* the file's own folder. Lowercased, because every url vowel routes
|
|
29
|
+
* is. (`resolvePath`)
|
|
30
|
+
*
|
|
31
|
+
* A filename vowel cannot route (a malformed `##` marker) is the
|
|
32
|
+
* router's to refuse; votive logs the refusal and ignores the file.
|
|
33
|
+
*/
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* @typedef {"string" | "date" | "path" | "boolean" | "number" | "strings" | "theme" | "links" | "publication" | "object"} Shape
|
|
37
|
+
*/
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* The keys vowel reads and the shape each one has. Everything else in a
|
|
41
|
+
* frontmatter block is the author's own data.
|
|
42
|
+
* @type {Record<string, Shape>}
|
|
43
|
+
*/
|
|
44
|
+
const EXPECTED = {
|
|
45
|
+
title: "string",
|
|
46
|
+
breadcrumb: "string",
|
|
47
|
+
description: "string",
|
|
48
|
+
tagline: "string",
|
|
49
|
+
name: "string",
|
|
50
|
+
author: "string",
|
|
51
|
+
domain: "string",
|
|
52
|
+
date: "date",
|
|
53
|
+
image: "path",
|
|
54
|
+
logo: "path",
|
|
55
|
+
wordmark: "path",
|
|
56
|
+
icon: "path",
|
|
57
|
+
tags: "strings",
|
|
58
|
+
aliases: "strings",
|
|
59
|
+
published: "boolean",
|
|
60
|
+
html_file: "boolean",
|
|
61
|
+
rss_item: "boolean",
|
|
62
|
+
sitemap_item: "boolean",
|
|
63
|
+
global_menu_item: "boolean",
|
|
64
|
+
local_menu_item: "boolean",
|
|
65
|
+
feed_limit: "number",
|
|
66
|
+
theme: "theme",
|
|
67
|
+
social_links: "links",
|
|
68
|
+
robots: "object",
|
|
69
|
+
atproto_did: "string",
|
|
70
|
+
atproto_lexicon: "string",
|
|
71
|
+
atproto_publication: "publication",
|
|
72
|
+
cloudflare_project: "string",
|
|
73
|
+
atproto_pds: "string"
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/** @param {unknown} value */
|
|
77
|
+
const isScalar = (value) => ["string", "number", "boolean"].includes(typeof value)
|
|
78
|
+
|
|
79
|
+
/** @param {unknown} value */
|
|
80
|
+
const isPlainObject = (value) => Boolean(value) && typeof value === "object" && !Array.isArray(value) && !(value instanceof Date)
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* A date in whatever shape it was written - a Date the parser made,
|
|
84
|
+
* "2026-03-04", "January 5, 1000" - as ISO, or undefined when it is not
|
|
85
|
+
* one. ISO sorts lexically (orderBy relies on it) and toISOString pads
|
|
86
|
+
* the year, so 0999 sorts before 1000.
|
|
87
|
+
* @param {unknown} value
|
|
88
|
+
*/
|
|
89
|
+
function toISODate(value) {
|
|
90
|
+
const parsed = value instanceof Date ? value : isScalar(value) ? extractDate(String(value)) : null
|
|
91
|
+
if (!parsed || isNaN(Number(parsed))) return undefined
|
|
92
|
+
return parsed.toISOString()
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* A URL path from the root. `./x` is the file's own folder; anything
|
|
97
|
+
* else is root-relative whether or not it starts with `/`.
|
|
98
|
+
* @param {string} value
|
|
99
|
+
* @param {string} folder - the file's folder, project-relative ("" at the root)
|
|
100
|
+
*/
|
|
101
|
+
function resolvePath(value, folder) {
|
|
102
|
+
const trimmed = value.trim()
|
|
103
|
+
if (/^[a-z]+:/i.test(trimmed)) return trimmed
|
|
104
|
+
const relative = trimmed.startsWith("./") || trimmed.startsWith("../")
|
|
105
|
+
const joined = relative ? path.posix.join("/", folder.split(path.sep).join("/"), trimmed) : path.posix.join("/", trimmed)
|
|
106
|
+
return joined.toLowerCase()
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* One value against one shape. Returns the value to store, or undefined
|
|
111
|
+
* to drop the key; `problem` says what was wrong when it was.
|
|
112
|
+
* @param {Shape} shape
|
|
113
|
+
* @param {unknown} value
|
|
114
|
+
* @param {string} folder
|
|
115
|
+
* @returns {{ value: unknown, problem?: string }}
|
|
116
|
+
*/
|
|
117
|
+
function coerceOne(shape, value, folder) {
|
|
118
|
+
if (shape === "string") {
|
|
119
|
+
if (typeof value === "string") return { value }
|
|
120
|
+
if (isScalar(value) || value instanceof Date) return { value: String(value), problem: `expected text, got ${typeof value}` }
|
|
121
|
+
if (Array.isArray(value) && value.every(isScalar)) return { value: value.map(String).join(", "), problem: "expected text, got a list" }
|
|
122
|
+
return { value: undefined, problem: `expected text, got ${Array.isArray(value) ? "a list" : "an object"}` }
|
|
123
|
+
}
|
|
124
|
+
if (shape === "date") {
|
|
125
|
+
const iso = toISODate(value)
|
|
126
|
+
if (iso !== undefined) return { value: iso }
|
|
127
|
+
return { value: undefined, problem: `expected a date, got ${JSON.stringify(value)}` }
|
|
128
|
+
}
|
|
129
|
+
if (shape === "path") {
|
|
130
|
+
if (typeof value === "string" && value.trim()) return { value: resolvePath(value, folder) }
|
|
131
|
+
const inner = isPlainObject(value) ? [value.src, value.url, value.path].find(candidate => typeof candidate === "string") : Array.isArray(value) ? value.find(candidate => typeof candidate === "string") : undefined
|
|
132
|
+
if (inner) return { value: resolvePath(inner, folder), problem: `expected a path, got ${Array.isArray(value) ? "a list" : "an object"}; using "${inner}"` }
|
|
133
|
+
return { value: undefined, problem: `expected a path, got ${JSON.stringify(value)}` }
|
|
134
|
+
}
|
|
135
|
+
if (shape === "boolean") {
|
|
136
|
+
if (typeof value === "boolean") return { value }
|
|
137
|
+
const word = String(value).trim().toLowerCase()
|
|
138
|
+
if (["true", "yes", "1", "on"].includes(word)) return { value: true, problem: `expected true or false, got ${JSON.stringify(value)}` }
|
|
139
|
+
if (["false", "no", "0", "off"].includes(word)) return { value: false, problem: `expected true or false, got ${JSON.stringify(value)}` }
|
|
140
|
+
return { value: undefined, problem: `expected true or false, got ${JSON.stringify(value)}` }
|
|
141
|
+
}
|
|
142
|
+
if (shape === "number") {
|
|
143
|
+
if (typeof value === "number" && Number.isFinite(value)) return { value }
|
|
144
|
+
const parsed = Number(value)
|
|
145
|
+
if (typeof value === "string" && value.trim() && Number.isFinite(parsed)) return { value: parsed, problem: `expected a number, got text` }
|
|
146
|
+
return { value: undefined, problem: `expected a number, got ${JSON.stringify(value)}` }
|
|
147
|
+
}
|
|
148
|
+
if (shape === "strings") {
|
|
149
|
+
if (Array.isArray(value)) {
|
|
150
|
+
const kept = value.filter(isScalar).map(String)
|
|
151
|
+
return kept.length === value.length ? { value: kept } : { value: kept, problem: "expected a list of text; dropped what was not" }
|
|
152
|
+
}
|
|
153
|
+
if (isScalar(value)) return { value: [String(value)], problem: "expected a list, got one value" }
|
|
154
|
+
return { value: undefined, problem: `expected a list, got ${JSON.stringify(value)}` }
|
|
155
|
+
}
|
|
156
|
+
if (shape === "theme") {
|
|
157
|
+
if (typeof value === "string") return { value }
|
|
158
|
+
if (isPlainObject(value)) return { value }
|
|
159
|
+
return { value: undefined, problem: `expected a theme name or an object, got ${JSON.stringify(value)}` }
|
|
160
|
+
}
|
|
161
|
+
if (shape === "links") {
|
|
162
|
+
if (!Array.isArray(value)) return { value: undefined, problem: "expected a list of links" }
|
|
163
|
+
const kept = value
|
|
164
|
+
.filter(link => isPlainObject(link) && typeof link.url === "string")
|
|
165
|
+
.map(link => typeof link.icon === "string" ? { ...link, icon: resolvePath(link.icon, folder) } : link)
|
|
166
|
+
return kept.length === value.length ? { value: kept } : { value: kept, problem: "expected every link to have a url; dropped those without" }
|
|
167
|
+
}
|
|
168
|
+
if (shape === "publication") {
|
|
169
|
+
if (!isPlainObject(value)) return { value: undefined, problem: `expected an object with description and icon, got ${JSON.stringify(value)}` }
|
|
170
|
+
const { description, icon, ...rest } = value
|
|
171
|
+
const kept = {
|
|
172
|
+
...rest,
|
|
173
|
+
...(typeof description === "string" ? { description } : {}),
|
|
174
|
+
...(typeof icon === "string" && icon.trim() ? { icon: resolvePath(icon, folder) } : {})
|
|
175
|
+
}
|
|
176
|
+
const wrong = [
|
|
177
|
+
...(description === undefined || typeof description === "string" ? [] : ["description is not text"]),
|
|
178
|
+
...(icon === undefined || (typeof icon === "string" && icon.trim()) ? [] : ["icon is not a path"])
|
|
179
|
+
]
|
|
180
|
+
return wrong.length ? { value: kept, problem: `${wrong.join(", ")}; dropped` } : { value: kept }
|
|
181
|
+
}
|
|
182
|
+
if (shape === "object") {
|
|
183
|
+
if (isPlainObject(value)) return { value }
|
|
184
|
+
return { value: undefined, problem: `expected an object, got ${JSON.stringify(value)}` }
|
|
185
|
+
}
|
|
186
|
+
return { value }
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* The block's values, each known key checked against EXPECTED. Returns
|
|
191
|
+
* a new object; keys coerced away are absent from it.
|
|
192
|
+
* @param {Record<string, unknown>} frontmatter
|
|
193
|
+
* @param {string} filePath - project-relative, for the error line
|
|
194
|
+
* @param {string} folder - the folder paths resolve against
|
|
195
|
+
* @param {(message: string) => void} report
|
|
196
|
+
*/
|
|
197
|
+
function coerce(frontmatter, filePath, folder, report) {
|
|
198
|
+
const result = {}
|
|
199
|
+
for (const key in frontmatter) {
|
|
200
|
+
const shape = EXPECTED[key]
|
|
201
|
+
if (!shape) {
|
|
202
|
+
result[key] = frontmatter[key]
|
|
203
|
+
continue
|
|
204
|
+
}
|
|
205
|
+
const { value, problem } = coerceOne(shape, frontmatter[key], folder)
|
|
206
|
+
if (problem) report(`${filePath}: \`${key}:\` ${problem}${value === undefined ? "; ignoring it" : ""}`)
|
|
207
|
+
if (value !== undefined) result[key] = value
|
|
208
|
+
}
|
|
209
|
+
return result
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* Parses a frontmatter node. On a parse error the node is replaced in
|
|
214
|
+
* the tree by the markdown it would have been - rule 1 above - and
|
|
215
|
+
* nothing is returned.
|
|
216
|
+
* @param {object} tree - the mdast root
|
|
217
|
+
* @param {object} node - its `yaml` child
|
|
218
|
+
* @param {string} filePath
|
|
219
|
+
* @param {(message: string) => void} report
|
|
220
|
+
* @returns {Record<string, unknown> | undefined}
|
|
221
|
+
*/
|
|
222
|
+
function parseFrontmatter(tree, node, filePath, report) {
|
|
223
|
+
try {
|
|
224
|
+
// logLevel "error": yaml otherwise prints its own warnings through
|
|
225
|
+
// process.emitWarning, naming no file - `date: {{ date }}` printed
|
|
226
|
+
// "Keys with collection values will be stringified". A value vowel
|
|
227
|
+
// reads is checked by coerce(), which reports it with the path.
|
|
228
|
+
const parsed = yaml.parse(node.value, { logLevel: "error" })
|
|
229
|
+
if (parsed === null || parsed === undefined) return {}
|
|
230
|
+
if (!isPlainObject(parsed)) {
|
|
231
|
+
report(`${filePath}: frontmatter is ${Array.isArray(parsed) ? "a list" : "a single value"}, not a mapping; rendering it as content`)
|
|
232
|
+
return asContent(tree, node)
|
|
233
|
+
}
|
|
234
|
+
return parsed
|
|
235
|
+
} catch (error) {
|
|
236
|
+
report(`${filePath}: frontmatter could not be parsed (${String(error.message).split("\n")[0]}); rendering it as content`)
|
|
237
|
+
return asContent(tree, node)
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* Puts a block back as content: `---`, its lines, `---`, parsed as
|
|
243
|
+
* ordinary markdown, in the node's place.
|
|
244
|
+
* @param {object} tree
|
|
245
|
+
* @param {object} node
|
|
246
|
+
*/
|
|
247
|
+
function asContent(tree, node) {
|
|
248
|
+
const replacement = fromMarkdown(`---\n${node.value}\n---\n`).children
|
|
249
|
+
tree.children.splice(tree.children.indexOf(node), 1, ...replacement)
|
|
250
|
+
return undefined
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
export { EXPECTED, coerce, parseFrontmatter, resolvePath, toISODate }
|