this repo has no description
1# Sitebase publication exporting
2
3One of the primary features of sitebase is being able to export your `standard.site` publication to static files that can be deployed through the method of your choice.
4
5## Export config
6
7Export configuration can be specified via command line options, or via a config file.
8
9### Config files
10
11A config file can be specified with the `--config` flag. If a `.sitebase.config.{js|ts}` file is in the current directory, this will be autodetected and used.
12
13**Note**: Options provided via the command line will override those set in a config file.
14
15### Options
16
17#### `filename`
18
19A handlebars template string representing the filename.
20
21Receives both publication (`pub`) and document (`doc`) data.
22
23(TODO: what helpers are available? need some for date string processing at least. what does handlebars come with? [register some default helpers?](https://handlebarsjs.com/guide/expressions.html#helpers))
24
25Default: `
26
27#### `filenameFn` (config file only)
28
29A function receiving the publication and document data, returning a string that will become the exported document filename.
30
31```
32({ pub: Publication, doc: Document }) => string | Promise<string>
33```
34
35#### `contentTypes`
36
37A list of `doc.content.$type` values that will be included in the export.
38
39Default: `["markdown", "html"]`
40
41#### `includeTags`
42
43A list of tags that, if present, will opt a document in to the export.
44
45If `null | undefined`, assumes all tags are applicable.
46
47#### `excludeTags`
48
49A list of tags that, if present, will PREVENT a document from being included in the export.
50
51#### `filter` (config file only)
52
53Function accepting publication and document data, returning a boolean to determine whether the document should be included in the export.
54
55Processes _after_ the `contentTypes`, `includeTags`, and `excludeTags` properties have been applied.
56
57```
58({ pub: Publication, doc: Document }) => boolean | Promise<boolean>
59```
60
61#### `contentTemplate`
62
63Path to a handlebars template file used to produce the output doc file content.
64
65#### `contentFn` (config file only)
66
67A function that returns the exported doc file content.
68
69```
70({ pub: Publication, doc: Document }) => string | Promise<string>
71```
72
73### Default config
74
75```
76{
77 outputDir: ".",
78 contentTypes: ["markdown", "html"],
79 filename: (doc) => {
80 // TODO: is `publishedAt` always an ISO date string?
81 const date = doc.publishedAt.slice(0, 10);
82 const docSlug = doc.slug ? basename(doc.slug) : slugify(doc.title);
83
84 let extension = "md";
85 if (doc.content.$type === "html") extension = "html";
86
87 return `${date}_${docSlug}.${extension}`;
88 },
89 contentFn: (doc) => `
90---
91Bun.YAML.stringify({
92 title: doc.title
93 tags: doc.tags
94 publishedAt: doc.publishedAt
95}, null, 2);
96---
97${doc.content}
98 `.trim(),
99}
100```
101
102