MOTD
motdProcessor
adds a MOTD style global message on the site.
My awesome message of the day!
This processor is also available as the deprecated alias versionBannerProcessor
.
Usage
const docs = new Generator({
processors: [motdProcessor()],
});
If you need a static message (always present) you can set the message
property.
const docs = new Generator({
processors: [
motdProcessor({
message: "Lorem ipsum dolor sit amet.",
}),
],
});
Configuration
The motdProcessor
takes a configuration object:
motdProcessor({
enabled: true,
container: "body:begin",
message: "Lorem ipsum dolor sit amet",
});
enabled
- Type:
boolean
- Default:
true
Enables/disables the MOTD processor.
container
- Type:
string
- Default:
body:begin
The name of a container (in layout template) to render content in. If the container does not exist for given layout the content will not be rendered.
message
- Type:
string
- Required: yes
Output a static message. May contain HTML markup.
API
There is a runtime API to render dynamic messages:
interface MOTDMessage {
/** Text message (may include HTML) */
message: string;
/** ID of message template to use */
template?: string;
/** Optional extra bindings */
bindings?: Record<string, string>;
/** Called with the new DOM element before the element is shown */
preprocess?(element: DocumentFragment): void;
}
declare const motd: {
readonly enabled: boolean;
showMessage(message: MOTDMessage): void;
};
Example usage:
import { motd } from "@forsakringskassan/docs-generator/runtime";
motd.showMessage({
message: "lorem ipsum dolor sit amet",
});