Skip to content
Moku LabsDocs
@moku-labs/web pages

site

Default. The frozen site identity: name, URL, author, description, and canonical URLs.

site.mdllms.txt

What it does

Isomorphic default. site holds four values that the rest of the framework reads: the site name, the absolute base URL, the author and the description. It also joins paths into canonical URLs. router, head, build and deploy depend on it.

How it works

The four config fields are the whole model. The accessors read the frozen config and return strings. There is no state and no event.

createApp validates the config right away: name must not be blank and url must be an absolute http or https URL. The defaults are empty strings that only satisfy the type, so every app passes real values, in the Node app and in the browser app.

canonical(path) joins a path to url without a double slash and keeps a trailing slash. canonical("/") and canonical("") return the base URL.

Config

pluginConfigs.site.

OptionTypeDefaultDescription
namestring""The site name: the fallback page title, feeds, the Pages project slug. Required.
urlstring""The absolute base URL, e.g. "https://blog.dev". Required.
authorstring""The default byline, for feeds and article meta.
descriptionstring""The default meta description and feed description.

API

Mounted at app.site, reachable with ctx.require(sitePlugin).

MethodSignatureDescription
name() => stringThe site name.
url() => stringThe base URL.
author() => stringThe author.
description() => stringThe description.
canonical(path: string) => stringThe absolute URL of a path.

Events

Emits

None.

Listens to

None.

Depends on

Nothing.

Example

src/site.ts
import { createApp } from "@moku-labs/web";

export const site = {
  name: "My Blog",
  url: "https://blog.dev",
  author: "Ada Lovelace",
  description: "Notes on computing."
};

const app = createApp({ pluginConfigs: { site } });

console.log(app.site.name()); // "My Blog"
console.log(app.site.canonical("/posts/hello/")); // "https://blog.dev/posts/hello/"
console.log(app.site.canonical("/")); // "https://blog.dev"
  1. Keep it in one module and pass it to the Node app and the browser app.
createApp with a relative URL
bun scripts/build.ts
error: [web] site.url must be a valid absolute URL (http/https), received "blog.dev".
  Provide an absolute URL in pluginConfigs.site.url, e.g. "https://blog.dev".

The error is thrown by createApp, before any build work starts. Bun prints the source line above it; it is left out here.

  • No usable defaults. Without pluginConfigs.site, createApp throws [web] site.name is required. That includes the browser app.
  • url is the production origin. Canonical links, og:url, absolute images, the sitemap and the feeds all start from it. A preview deploy still points them at production.
  • Errors have two lines. The first says what is wrong, the indented second says how to fix it.