this repo has no description

Sitebase publication exporting#

One 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.

Export config#

Export configuration can be specified via command line options, or via a config file.

Config files#

A 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.

Note: Options provided via the command line will override those set in a config file.

Options#

filename#

A handlebars template string representing the filename.

Receives both publication (pub) and document (doc) data.

(TODO: what helpers are available? need some for date string processing at least. what does handlebars come with? register some default helpers?)

Default: `

filenameFn (config file only)#

A function receiving the publication and document data, returning a string that will become the exported document filename.

({ pub: Publication, doc: Document }) => string | Promise<string>

contentTypes#

A list of doc.content.$type values that will be included in the export.

Default: ["markdown", "html"]

includeTags#

A list of tags that, if present, will opt a document in to the export.

If null | undefined, assumes all tags are applicable.

excludeTags#

A list of tags that, if present, will PREVENT a document from being included in the export.

filter (config file only)#

Function accepting publication and document data, returning a boolean to determine whether the document should be included in the export.

Processes after the contentTypes, includeTags, and excludeTags properties have been applied.

({ pub: Publication, doc: Document }) => boolean | Promise<boolean>

contentTemplate#

Path to a handlebars template file used to produce the output doc file content.

contentFn (config file only)#

A function that returns the exported doc file content.

({ pub: Publication, doc: Document }) => string | Promise<string>

Default config#

{
  outputDir: ".",
  contentTypes: ["markdown", "html"],
  filename: (doc) => {
    // TODO: is `publishedAt` always an ISO date string?
    const date = doc.publishedAt.slice(0, 10);
    const docSlug = doc.slug ? basename(doc.slug) : slugify(doc.title);

    let extension = "md";
    if (doc.content.$type === "html") extension = "html";

    return `${date}_${docSlug}.${extension}`;
  },
  contentFn: (doc) => `
---
Bun.YAML.stringify({
  title: doc.title
  tags: doc.tags
  publishedAt: doc.publishedAt
}, null, 2);
---
${doc.content}
  `.trim(),
}