@lvl99dotcom/edaha.md 0.1.0 → 0.2.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.
Files changed (61) hide show
  1. package/LICENSE +183 -183
  2. package/README.md +7 -252
  3. package/dist/cli/index.d.ts +36 -6
  4. package/dist/cli/index.js +48 -9
  5. package/dist/embeds/blocks/index.d.ts +59 -0
  6. package/dist/embeds/blocks/index.js +103 -0
  7. package/dist/embeds/index.d.ts +122 -19
  8. package/dist/embeds/index.js +381 -41
  9. package/dist/embeds/types/index.d.ts +111 -8
  10. package/dist/generator/article/index.d.ts +52 -12
  11. package/dist/generator/article/index.js +94 -26
  12. package/dist/generator/build/index.d.ts +55 -23
  13. package/dist/generator/build/index.js +151 -81
  14. package/dist/generator/config/index.d.ts +45 -8
  15. package/dist/generator/config/index.js +152 -30
  16. package/dist/generator/configFile/index.d.ts +58 -0
  17. package/dist/generator/configFile/index.js +122 -0
  18. package/dist/generator/fields/index.d.ts +93 -0
  19. package/dist/generator/fields/index.js +186 -0
  20. package/dist/generator/format/index.d.ts +40 -0
  21. package/dist/generator/format/index.js +75 -0
  22. package/dist/generator/lists/index.d.ts +3 -3
  23. package/dist/generator/lists/index.js +9 -8
  24. package/dist/generator/markdown/index.d.ts +8 -3
  25. package/dist/generator/markdown/index.js +11 -4
  26. package/dist/generator/metadata/index.d.ts +150 -0
  27. package/dist/generator/metadata/index.js +361 -0
  28. package/dist/generator/metadataGroups/index.d.ts +45 -0
  29. package/dist/generator/metadataGroups/index.js +169 -0
  30. package/dist/generator/templates/index.d.ts +35 -3
  31. package/dist/generator/templates/index.js +72 -6
  32. package/dist/generator/types/index.d.ts +43 -18
  33. package/dist/generator/urls/index.d.ts +18 -8
  34. package/dist/generator/urls/index.js +22 -12
  35. package/dist/index.d.ts +5 -7
  36. package/dist/index.js +6 -7
  37. package/package.json +18 -47
  38. package/theme/static/{site.css → base.css} +132 -24
  39. package/theme/templates/article/list.njk +6 -6
  40. package/theme/templates/article/single.njk +13 -7
  41. package/theme/templates/layouts/html.njk +54 -32
  42. package/theme/templates/layouts/rssfeed.njk +7 -7
  43. package/theme/templates/page/home.njk +2 -7
  44. package/theme/templates/page/single.njk +2 -2
  45. package/dist/client/assets/index-BbKEbPS8.css +0 -1
  46. package/dist/client/assets/index-DtG7vi1d.js +0 -559
  47. package/dist/client/index.html +0 -13
  48. package/dist/editor/index.d.ts +0 -62
  49. package/dist/editor/index.js +0 -102
  50. package/dist/embeds/bandcamp/index.d.ts +0 -9
  51. package/dist/embeds/bandcamp/index.js +0 -28
  52. package/dist/embeds/youtube/index.d.ts +0 -17
  53. package/dist/embeds/youtube/index.js +0 -48
  54. package/dist/server/app/index.d.ts +0 -39
  55. package/dist/server/app/index.js +0 -138
  56. package/dist/server/convert/index.d.ts +0 -25
  57. package/dist/server/convert/index.js +0 -125
  58. package/dist/server/store/index.d.ts +0 -148
  59. package/dist/server/store/index.js +0 -411
  60. package/dist/server/types/index.d.ts +0 -76
  61. package/dist/server/types/index.js +0 -1
@@ -1,19 +1,19 @@
1
1
  import { cp, mkdir, readdir, readFile, rm, stat, writeFile, } from "node:fs/promises";
2
- import { dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
3
- import { EmbedResolver } from "../../embeds/index.js";
2
+ import { basename, dirname, isAbsolute, join, relative, resolve, sep, } from "node:path";
3
+ import { cachedFetch, EMBED_PAGE_PARTS, EmbedResolver, } from "../../embeds/index.js";
4
4
  import { loadArticle } from "../article/index.js";
5
- import { defaultTypeConfig, parseConfig, RESERVED_TYPES, } from "../config/index.js";
5
+ import { MetadataValidator, typeMetadataKeys } from "../metadata/index.js";
6
+ import { defaultTypeConfig, RESERVED_TYPES, SOURCE_FOLDERS, } from "../config/index.js";
7
+ import { loadSiteConfig } from "../configFile/index.js";
6
8
  import { collectLists, PAGE_SIZE, pageFile, paginate } from "../lists/index.js";
7
9
  import { createMarkdown, renderMarkdown } from "../markdown/index.js";
8
10
  import { isSlug } from "../slug/index.js";
9
11
  import { THEME_DIR } from "../../theme/index.js";
10
12
  import { Templates } from "../templates/index.js";
11
- import { checkTypePaths, folderPath, folderUrl, slugProblem, } from "../urls/index.js";
13
+ import { checkTypePaths, folderPath, baseUrlOf, folderUrl, slugProblem, } from "../urls/index.js";
12
14
  export { RESERVED_TYPES } from "../config/index.js";
13
- /** Used for feeds when neither `SITE_URL` nor `siteUrl` in config.yml is set */
15
+ /** Used for feeds when neither `SITE_URL` nor `siteUrl` in the config file is set */
14
16
  export const DEFAULT_SITE_URL = "http://localhost";
15
- /** The site's folders that hold its sources, which built files must never be written into */
16
- const SOURCE_FOLDERS = ["articles", "templates", "static"];
17
17
  /** List the names of sub-folders in a folder (none if it doesn't exist) */
18
18
  const subfolders = async (dir) => {
19
19
  try {
@@ -52,32 +52,35 @@ const overlaps = (a, b) => {
52
52
  return !fromA || !fromB || !fromA.startsWith("..") || !fromB.startsWith("..");
53
53
  };
54
54
  /**
55
- * Resolve `outputDir` from config.yml: a folder inside the site folder, apart from its source folders, as it is
56
- * emptied on every build.
55
+ * Resolve `outputDir` from the config file: a folder inside the site folder, apart from its source folders (the
56
+ * articles, templates and static files folders), as it is emptied on every build.
57
+ *
58
+ * @param sources - the source folders, relative to the site folder (default: the default ones)
57
59
  *
58
60
  * @example
59
- * resolveOutputDir("/site", "dist"); // "/site/dist"
61
+ * resolveOutputDir("/site", "build"); // "/site/build"
62
+ * resolveOutputDir("/site", "site/build", ["site/content", "site/templates", "site/static"]); // "/site/site/build"
60
63
  */
61
- export const resolveOutputDir = (siteDir, folder) => {
64
+ export const resolveOutputDir = (siteDir, folder, sources = Object.values(SOURCE_FOLDERS)) => {
62
65
  const dir = resolve(siteDir, folder);
63
66
  const fromSite = relative(resolve(siteDir), dir);
64
67
  if (!fromSite || fromSite.startsWith("..") || isAbsolute(fromSite))
65
- throw new Error(`config.yml: "outputDir" must be a folder inside the site folder, got "${folder}"`);
66
- if (SOURCE_FOLDERS.some((source) => overlaps(join(siteDir, source), dir)))
67
- throw new Error(`config.yml: "outputDir" must be apart from ${SOURCE_FOLDERS.join(", ")}, got "${folder}"`);
68
+ throw new Error(`"outputDir" must be a folder inside the site folder, got "${folder}"`);
69
+ if (sources.some((source) => overlaps(join(siteDir, source), dir)))
70
+ throw new Error(`"outputDir" must be apart from ${sources.join(", ")}, got "${folder}"`);
68
71
  return dir;
69
72
  };
70
73
  /**
71
- * Resolve `publishDir` from config.yml, relative to the site folder: any folder apart from the site folder, e.g.
74
+ * Resolve `publishDir` from the config file, relative to the site folder: any folder apart from the site folder, e.g.
72
75
  * another app's build folder.
73
76
  *
74
77
  * @example
75
- * resolvePublishDir("/work/blog", "../app/dist"); // "/work/app/dist"
78
+ * resolvePublishDir("/work/site", "../app/dist"); // "/work/app/dist"
76
79
  */
77
80
  export const resolvePublishDir = (siteDir, folder) => {
78
81
  const dir = resolve(siteDir, folder);
79
82
  if (overlaps(resolve(siteDir), dir))
80
- throw new Error(`config.yml: "publishDir" must be a folder apart from the site folder, got "${folder}"`);
83
+ throw new Error(`"publishDir" must be a folder apart from the site folder, got "${folder}"`);
81
84
  return dir;
82
85
  };
83
86
  /**
@@ -93,78 +96,145 @@ export const staticFiles = async (dirs) => {
93
96
  for (const dir of dirs)
94
97
  for (const file of await listFiles(dir))
95
98
  files.set(file, join(dir, file));
96
- return new Map([...files].sort(([a], [b]) => (a < b ? -1 : 1)));
99
+ // Sorted by path, comparing characters (not the locale's order)
100
+ return new Map([...files].sort(([a], [b]) => Number(a > b) - Number(a < b)));
97
101
  };
98
102
  /**
99
103
  * An article type's template data: its settings and URL.
100
104
  */
101
- const typeData = (blogPath, config) => ({
105
+ const typeData = (sitePath, config, baseUrl) => ({
102
106
  ...config,
103
- url: folderUrl(folderPath(blogPath, config.path)),
107
+ url: folderUrl(folderPath(sitePath, config.path), baseUrl),
104
108
  });
105
109
  /**
106
- * The blog's template data: its name, description and URL, and each article type's settings and URL.
110
+ * The website's template data: its name, description, absolute URL and home URL, default author, and each article
111
+ * type's settings and URL.
107
112
  *
108
113
  * @param typeConfigs - the article types' settings (configured ones, plus defaults for any others)
114
+ * @param url - the website's absolute URL (a trailing slash is removed)
115
+ *
116
+ * @example
117
+ * siteData(config, config.types, "https://example.com").types.news.url; // "/news/"
118
+ */
119
+ export const siteData = (config, typeConfigs, url) => {
120
+ const baseUrl = baseUrlOf(url);
121
+ return {
122
+ name: config.name,
123
+ description: config.description,
124
+ url: url.replace(/\/+$/, ""),
125
+ baseUrl,
126
+ path: folderUrl(folderPath(config.path), baseUrl),
127
+ author: config.author === false
128
+ ? undefined
129
+ : (config.author ?? { name: config.name }),
130
+ types: Object.fromEntries(Object.entries(typeConfigs).map(([type, typeConfig]) => [
131
+ type,
132
+ typeData(config.path, typeConfig, baseUrl),
133
+ ])),
134
+ };
135
+ };
136
+ /**
137
+ * The template data for an article's page, with its type's list for an index article.
109
138
  *
110
139
  * @example
111
- * blogData(config, config.types).types.news.url; // "/news/"
140
+ * articlePageData(site, article); // { site, type: "news", isArticle: true, isList: false, article }
112
141
  */
113
- export const blogData = (config, typeConfigs) => ({
114
- name: config.name,
115
- description: config.description,
116
- path: config.path,
117
- url: folderUrl(folderPath(config.path)),
118
- types: Object.fromEntries(Object.entries(typeConfigs).map(([type, typeConfig]) => [
119
- type,
120
- typeData(config.path, typeConfig),
121
- ])),
142
+ export const articlePageData = (site, article, list) => ({
143
+ site,
144
+ type: article.type,
145
+ isArticle: true,
146
+ isList: false,
147
+ article,
148
+ ...(list ? { list } : {}),
122
149
  });
123
150
  /**
124
- * Build the blog: render every published and unlisted article with its assets, then each type's paginated list and
151
+ * The template data for a list's page or feed.
152
+ *
153
+ * @example
154
+ * listPageData(site, list); // { site, type: "news", isArticle: false, isList: true, list }
155
+ */
156
+ export const listPageData = (site, list) => ({
157
+ site,
158
+ type: list.type,
159
+ isArticle: false,
160
+ isList: true,
161
+ list,
162
+ });
163
+ /**
164
+ * The embed plugins to build with: the config file's, then the given ones whose keys the config file doesn't use.
165
+ *
166
+ * @example
167
+ * withPlugins([youtube], [youtube2, mermaidjs]); // [youtube, mermaidjs]
168
+ */
169
+ export const withPlugins = (configPlugins, plugins = []) => {
170
+ const keys = new Set(configPlugins.map((plugin) => plugin.key));
171
+ return [
172
+ ...configPlugins,
173
+ ...plugins.filter((plugin) => !keys.has(plugin.key)),
174
+ ];
175
+ };
176
+ /**
177
+ * Build the site: render every published and unlisted article with its assets, then each type's paginated list and
125
178
  * RSS feed, and its tag and author lists, and copy the static files (the theme's, overridden by the site's `static/`)
126
179
  * as they are. Files are written to `outputDir` (emptied first). If `publishDir` is set, they are then copied into it
127
180
  * (the website's root): the files published by the previous build are removed from it first, and the build stops if a
128
181
  * file is already there.
129
182
  *
130
183
  * @example
131
- * await buildBlog({ siteDir: "my-site", siteUrl: "https://example.com" });
184
+ * await buildSite({ siteDir: "my-site", siteUrl: "https://example.com" });
132
185
  */
133
- export const buildBlog = async (options) => {
186
+ export const buildSite = async (options) => {
134
187
  const logger = options.logger ?? console;
135
- const siteDir = resolve(options.siteDir);
188
+ const { configFile, siteDir, config } = await loadSiteConfig({
189
+ siteDir: options.siteDir,
190
+ configFile: options.configFile,
191
+ logger,
192
+ });
193
+ const configName = basename(configFile);
136
194
  const themeDir = options.themeDir ?? THEME_DIR;
137
- const config = parseConfig(await readFile(join(siteDir, "config.yml"), "utf8"));
138
- const outputDir = resolveOutputDir(siteDir, config.outputDir);
195
+ /** Run a check of the config's settings, naming the config file in its error */
196
+ const checkConfig = (check) => {
197
+ try {
198
+ return check();
199
+ }
200
+ catch (error) {
201
+ throw new Error(`${configName}: ${error.message}`, {
202
+ cause: error,
203
+ });
204
+ }
205
+ };
206
+ const outputDir = checkConfig(() => resolveOutputDir(siteDir, config.outputDir, [
207
+ config.articlesDir,
208
+ config.templatesDir,
209
+ config.staticDir,
210
+ ]));
139
211
  const publishDir = config.publishDir === undefined
140
212
  ? undefined
141
- : resolvePublishDir(siteDir, config.publishDir);
142
- const templates = new Templates([join(siteDir, "templates"), join(themeDir, "templates")], logger);
213
+ : checkConfig(() => resolvePublishDir(siteDir, config.publishDir));
214
+ const templates = new Templates([join(siteDir, config.templatesDir), join(themeDir, "templates")], logger);
143
215
  const siteUrl = options.siteUrl || config.siteUrl;
144
216
  if (!siteUrl)
145
- logger.warn(`SITE_URL is not set and config.yml has no "siteUrl"; feeds will link to ${DEFAULT_SITE_URL}`);
146
- const site = {
147
- url: (siteUrl || DEFAULT_SITE_URL).replace(/\/+$/, ""),
148
- };
217
+ logger.warn(`SITE_URL is not set and ${configName} has no "siteUrl"; feeds will link to ${DEFAULT_SITE_URL}`);
149
218
  // Article types: configured ones, plus any other type folders (with defaults)
150
- const articlesDir = join(siteDir, "articles");
219
+ const articlesDir = join(siteDir, config.articlesDir);
151
220
  const typeFolders = await subfolders(articlesDir);
152
221
  const typeConfigs = { ...config.types };
153
222
  for (const type of typeFolders) {
154
223
  if (!isSlug(type) || RESERVED_TYPES.includes(type))
155
- throw new Error(`articles/${type}: article types must be lowercase kebab-case and not ${RESERVED_TYPES.join(" or ")}`);
224
+ throw new Error(`${config.articlesDir}/${type}: article types must be lowercase kebab-case and not ${RESERVED_TYPES.join(" or ")}`);
156
225
  if (!typeConfigs[type]) {
157
- logger.warn(`articles/${type}: type "${type}" is not in config.yml; using the default settings`);
226
+ logger.warn(`${config.articlesDir}/${type}: type "${type}" is not in ${configName}; using the default settings`);
158
227
  typeConfigs[type] = defaultTypeConfig(type);
159
228
  }
160
229
  }
161
- checkTypePaths(config.path, typeConfigs, config.reservedPaths);
162
- const blog = blogData(config, typeConfigs);
230
+ checkConfig(() => checkTypePaths(config.path, typeConfigs, config.reservedPaths));
231
+ const site = siteData(config, typeConfigs, siteUrl || DEFAULT_SITE_URL);
163
232
  const markdown = createMarkdown();
164
233
  const embeds = new EmbedResolver({
165
- fetch: options.fetch ?? fetch,
234
+ // Pages that show the same embed don't fetch it again
235
+ fetch: cachedFetch(options.fetch ?? fetch),
166
236
  logger,
167
- renderers: options.embedRenderers,
237
+ plugins: withPlugins(config.plugins, options.plugins),
168
238
  });
169
239
  // Remove what the previous build published, then empty the build folder
170
240
  if (publishDir)
@@ -178,14 +248,17 @@ export const buildBlog = async (options) => {
178
248
  await writeFile(path, contents);
179
249
  files.push(file);
180
250
  };
251
+ // Validates articles' custom metadata
252
+ const validator = new MetadataValidator(config.metadata);
181
253
  // Load articles (types that generate nothing are still checked for errors)
182
254
  const articles = [];
183
255
  for (const type of typeFolders) {
184
- const typeConfig = blog.types[type];
256
+ const typeConfig = site.types[type];
185
257
  const built = typeConfig.generate.article;
186
- const typeFolder = typeConfig.url.slice(1);
258
+ // The type's folder in the output folder: its URL without the site's base URL
259
+ const typeFolder = typeConfig.url.slice(site.baseUrl.length + 1);
187
260
  for (const slug of await subfolders(join(articlesDir, type))) {
188
- const source = `articles/${type}/${slug}`;
261
+ const source = `${config.articlesDir}/${type}/${slug}`;
189
262
  if (!isSlug(slug))
190
263
  throw new Error(`${source}: folder names must be lowercase kebab-case`);
191
264
  const problem = slugProblem(slug, type, config.path, typeConfigs, config.reservedPaths);
@@ -203,17 +276,21 @@ export const buildBlog = async (options) => {
203
276
  // An index article is its type's front page
204
277
  const folder = slug === "index" ? typeFolder : `${typeFolder}${slug}/`;
205
278
  const article = await loadArticle(text, type, {
206
- blog,
279
+ site,
207
280
  dir,
208
281
  slug,
209
- url: folderUrl(folder),
282
+ url: folderUrl(folder, site.baseUrl),
210
283
  typeUrl: typeConfig.url,
211
284
  source,
212
- // Embeds aren't fetched for articles that won't be built
213
- replaceEmbeds: built
214
- ? (md) => embeds.replaceBlocks(md, source)
215
- : async (md) => md,
216
- renderMarkdown: (md, baseUrl) => renderMarkdown(markdown, md, baseUrl),
285
+ // Embeds are rendered with the pages that show them
286
+ replaceEmbeds: async (md) => embeds.replaceBlocks(md, source),
287
+ renderMarkdown: (md, baseUrl) => renderMarkdown(markdown, md, baseUrl, site.baseUrl),
288
+ metadata: {
289
+ validator,
290
+ keys: typeMetadataKeys(config.metadata, typeConfigs[type]?.metadata),
291
+ typeLabel: typeConfig.labelPlural,
292
+ warn: (message) => logger.warn(message),
293
+ },
217
294
  });
218
295
  if (article && built)
219
296
  articles.push({ article, dir, folder });
@@ -226,7 +303,9 @@ export const buildBlog = async (options) => {
226
303
  const listed = articles
227
304
  .map(({ article }) => article)
228
305
  .filter((article) => article.status === "published" && article.slug !== "index");
229
- const lists = collectLists(listed, blog, withIndex);
306
+ const lists = collectLists(listed, site, withIndex);
307
+ /** Render a page's template, then the embeds it shows (see EmbedResolver.renderPage) */
308
+ const renderPage = (template, data, url) => embeds.renderPage(templates.render(template, { ...data, embeds: EMBED_PAGE_PARTS }), url);
230
309
  const firstPages = new Map();
231
310
  for (const list of lists) {
232
311
  const pages = paginate(list);
@@ -235,18 +314,15 @@ export const buildBlog = async (options) => {
235
314
  if (list.pages) {
236
315
  const listTemplate = templates.resolve(list.type, "list");
237
316
  for (const page of pages)
238
- await write(list.dir + pageFile(page.pagination.page.index), templates.render(listTemplate, { site, blog, list: page }));
317
+ await write(list.dir + pageFile(page.pagination.page.index), await renderPage(listTemplate, listPageData(site, page), page.pagination.page.url));
239
318
  }
240
319
  if (list.feed)
241
- await write(`${list.dir}feed.xml`, templates.render("layouts/rssfeed.njk", {
242
- site,
243
- blog,
244
- // The feed has the newest articles that can be in feeds
245
- list: {
246
- ...pages[0],
247
- articles: list.feedArticles.slice(0, PAGE_SIZE),
248
- },
249
- }));
320
+ await write(`${list.dir}feed.xml`, await renderPage("layouts/rssfeed.njk",
321
+ // The feed has the newest articles that can be in feeds
322
+ listPageData(site, {
323
+ ...pages[0],
324
+ articles: list.feedArticles.slice(0, PAGE_SIZE),
325
+ }), `${list.dir}feed.xml`));
250
326
  }
251
327
  // Article pages with their assets; index articles also get their type's list
252
328
  for (const { article, dir, folder } of articles) {
@@ -254,23 +330,17 @@ export const buildBlog = async (options) => {
254
330
  recursive: true,
255
331
  filter: (path) => path !== join(dir, "article.md"),
256
332
  });
257
- await write(`${folder}index.html`, templates.render(templates.resolve(article.type, article.template), {
258
- site,
259
- blog,
260
- article,
261
- ...(article.slug === "index"
262
- ? { list: firstPages.get(article.type) }
263
- : {}),
264
- }));
333
+ const list = article.slug === "index" ? firstPages.get(article.type) : undefined;
334
+ await write(`${folder}index.html`, await renderPage(templates.resolve(article.type, article.template), articlePageData(site, article, list), article.url));
265
335
  }
266
336
  // Static files (stylesheet, fonts) at the website's root, beside the articles
267
337
  const statics = await staticFiles([
268
338
  join(themeDir, "static"),
269
- join(siteDir, "static"),
339
+ join(siteDir, config.staticDir),
270
340
  ]);
271
341
  for (const file of statics.keys())
272
342
  if (await exists(join(outputDir, file)))
273
- throw new Error(`static/${file} has the same path as an article's file; rename one of them`);
343
+ throw new Error(`${config.staticDir}/${file} has the same path as an article's file; rename one of them`);
274
344
  for (const [file, source] of statics) {
275
345
  await mkdir(dirname(join(outputDir, file)), { recursive: true });
276
346
  await cp(source, join(outputDir, file));
@@ -1,3 +1,7 @@
1
+ import type { EmbedPlugin } from "../../embeds/types/index.ts";
2
+ import type { AuthorConfig } from "../article/index.ts";
3
+ import { type MetadataDefinitions } from "../metadata/index.ts";
4
+ import { type MetadataGroupConfig } from "../metadataGroups/index.ts";
1
5
  /** What is built for an article type */
2
6
  export interface GenerateConfig {
3
7
  /** Build the type's articles (when false, nothing else is built for it either) */
@@ -13,7 +17,7 @@ export interface GenerateConfig {
13
17
  }
14
18
  /** Settings of an article type */
15
19
  export interface ArticleTypeConfig {
16
- /** The type's URL path ("" for the blog's root), e.g. "news" */
20
+ /** The type's URL path ("" for the site's root), e.g. "news" */
17
21
  path: string;
18
22
  /** Label for one article, e.g. "Article" */
19
23
  labelSingle: string;
@@ -21,25 +25,46 @@ export interface ArticleTypeConfig {
21
25
  labelPlural: string;
22
26
  /** What is built for the type */
23
27
  generate: GenerateConfig;
28
+ /** The custom metadata fields the type uses: those listed, none for `false`, or all when undefined */
29
+ metadata?: string[] | false | undefined;
30
+ /** The author of the type's articles that don't name one, or `false` for none. Default: the site's `author` */
31
+ author?: AuthorConfig | false | undefined;
24
32
  }
25
- /** Blog-level settings from `config.yml` */
26
- export interface BlogConfig {
33
+ /** The site's settings from the config file */
34
+ export interface EdahaConfig {
27
35
  /** The name of the website */
28
36
  name: string;
29
37
  /** The description of the website */
30
38
  description: string;
31
39
  /** The URL path prefix of every article type ("" for the website's root) */
32
40
  path: string;
33
- /** The build folder, relative to the site folder and inside it (emptied on every build). Default: "dist" */
41
+ /** The build folder, relative to the site folder and inside it (emptied on every build). Default: "build" */
34
42
  outputDir: string;
43
+ /** The articles folder, relative to the site folder and inside it. Default: "articles" */
44
+ articlesDir: string;
45
+ /** The site's templates folder, over the theme's, relative to the site folder and inside it. Default: "templates" */
46
+ templatesDir: string;
47
+ /** The site's static files folder, over the theme's, relative to the site folder and inside it. Default: "static" */
48
+ staticDir: string;
35
49
  /** Optional; where built files are copied to, relative to the site folder (e.g. another app's build folder) */
36
50
  publishDir?: string | undefined;
37
51
  /** Optional; the website's absolute URL for feeds, used when the `SITE_URL` environment variable isn't set */
38
52
  siteUrl?: string | undefined;
39
- /** Paths at the website's root that the blog can't use, e.g. another app's routes. Default: none */
53
+ /** Paths at the website's root that the site can't use, e.g. another app's routes. Default: none */
40
54
  reservedPaths: string[];
41
55
  /** Article type settings, by type */
42
56
  types: Record<string, ArticleTypeConfig>;
57
+ /**
58
+ * Embed plugins, for `<!-- embed:<key> -->` blocks. The config file names their packages (loaded by loadSiteConfig);
59
+ * a JavaScript config file can also give the plugins themselves. Default: none
60
+ */
61
+ plugins: EmbedPlugin[];
62
+ /** Custom metadata fields' JSON Schemas, by the key articles store their values under. Default: none */
63
+ metadata: MetadataDefinitions;
64
+ /** Groups of settings in the editor, besides the built-in ones, by key. Default: none */
65
+ metadataGroups: Record<string, MetadataGroupConfig>;
66
+ /** The author of articles that don't name one (unless their type has its own), or `false` for none. Default: none (the website's name is used) */
67
+ author?: AuthorConfig | false | undefined;
43
68
  }
44
69
  /** List folders that can't be used as article types */
45
70
  export declare const RESERVED_TYPES: string[];
@@ -51,9 +76,21 @@ export declare const RESERVED_TYPES: string[];
51
76
  */
52
77
  export declare const defaultTypeConfig: (type: string) => ArticleTypeConfig;
53
78
  /**
54
- * Parse and validate the contents of the blog's `config.yml`.
79
+ * Read the optional list of reserved paths: URL path segments or file names, e.g. "app" or "jwks.json".
80
+ */
81
+ /** The site's source folders' settings, with their defaults */
82
+ export declare const SOURCE_FOLDERS: {
83
+ readonly articlesDir: "articles";
84
+ readonly templatesDir: "templates";
85
+ readonly staticDir: "static";
86
+ };
87
+ /**
88
+ * Validate the settings read from the site's config file (YAML, JSON or JavaScript) and fill in defaults. Errors start
89
+ * with the config file's name.
90
+ *
91
+ * @param source - the config file's name, for errors
55
92
  *
56
93
  * @example
57
- * parseConfig("name: News\ndescription: Updates\noutputDir: dist");
94
+ * parseConfig({ name: "News", description: "Updates" }, "edaha.config.json");
58
95
  */
59
- export declare const parseConfig: (text: string) => BlogConfig;
96
+ export declare const parseConfig: (data: unknown, source?: string) => EdahaConfig;