Documentation
¶
Overview ¶
Package baseplate is a monolithic CMS that customer projects embed as a Go module:
app := baseplate.New(baseplate.Config{Theme: theme})
app.Use(forms.New())
app.Main()
The resulting binary serves the admin, builds the static site and handles dynamic endpoints such as form submissions.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type App ¶
type App struct {
// Set by setup.
Registry *plugin.Registry
Builder *build.Builder
// contains filtered or unexported fields
}
App is one customer site: configuration, plugins and, after Setup, the wired registry, builder and admin.
func (*App) Handler ¶
Handler returns the HTTP handler of the server: admin, media, plugin routes, and a preview of the last build at /.
type Config ¶
type Config struct {
// Addr is the listen address of `serve` (BASEPLATE_ADDR, default ":8080").
Addr string
// DataDir holds the SQLite database and uploaded media
// (BASEPLATE_DATA_DIR, default "./data").
DataDir string
// DistDir receives the static build (BASEPLATE_DIST_DIR, default "./dist").
DistDir string
// Theme contains "templates/" and optionally "assets/" and "public/"
// (copied 1:1 to the site root).
Theme fs.FS
// SMTP configures outgoing mail (BASEPLATE_SMTP_HOST, _PORT, _USER,
// _PASSWORD, _FROM). Without a host, mails are only logged.
SMTP mail.SMTPConfig
// SecureCookies sets the Secure flag on the admin session cookie; enable
// it behind an HTTPS proxy (BASEPLATE_SECURE_COOKIES=1).
SecureCookies bool
// BuildOnPublish rebuilds the static site in the background after
// published content changes (BASEPLATE_BUILD_ON_PUBLISH=1).
BuildOnPublish bool
// AdminLocale is the admin language (BASEPLATE_ADMIN_LOCALE, default
// "de"). The core ships the "de" catalog (i18n/locales); other locales
// need a catalog, missing keys fall back to German.
AdminLocale string
// TrustedProxyHeader names a header carrying the client IP, e.g.
// "X-Forwarded-For" (BASEPLATE_TRUSTED_PROXY_HEADER). Rate limits use it
// instead of the connection address; the last address in the header
// counts. Only set it behind exactly one proxy that sets or appends the
// header. Default: off.
TrustedProxyHeader string
// Store overrides the storage adapter. Default: SQLite in DataDir.
Store storage.Store
// Mailer overrides the mailer built from SMTP.
Mailer mail.Mailer
Logger *slog.Logger
}
Config configures an App. Every field can be overridden by an environment variable (see LoadEnv), so one binary runs on any host.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package build generates the static site: one HTML file per published routable entry, the output templates (Markdown variants, sitemap.xml, robots.txt, llms.txt, see render.Output) and the public files (theme "public/", plugin.Registry.Public).
|
Package build generates the static site: one HTML file per published routable entry, the output templates (Markdown variants, sitemap.xml, robots.txt, llms.txt, see render.Output) and the public files (theme "public/", plugin.Registry.Public). |
|
Package content describes content types, fields and blocks, and validates entry data against them.
|
Package content describes content types, fields and blocks, and validates entry data against them. |
|
Package entries is the application service for writing content.
|
Package entries is the application service for writing content. |
|
examples
|
|
|
site
command
Example customer project.
|
Example customer project. |
|
Package fields provides baseplate's built-in field kinds, blocks and content types (page, site settings), plus the standard SEO fields.
|
Package fields provides baseplate's built-in field kinds, blocks and content types (page, site settings), plus the standard SEO fields. |
|
Package hook is baseplate's extension mechanism.
|
Package hook is baseplate's extension mechanism. |
|
Package i18n translates the admin interface.
|
Package i18n translates the admin interface. |
|
internal
|
|
|
admin
Package admin is the editor interface: server-rendered templates with Alpine.js for the field editor and htmx for partial updates.
|
Package admin is the editor interface: server-rendered templates with Alpine.js for the field editor and htmx for partial updates. |
|
auth
Package auth handles admin users: password hashing, sessions, CSRF and login rate limiting.
|
Package auth handles admin users: password hashing, sessions, CSRF and login rate limiting. |
|
fileserver
Package fileserver serves static files without directory listings.
|
Package fileserver serves static files without directory listings. |
|
markup
Package markup handles rich-text HTML: SanitizeHTML reduces untrusted HTML to an allowlist, HTMLToMarkdown converts it for Markdown exports, SafeURL checks link targets.
|
Package markup handles rich-text HTML: SanitizeHTML reduces untrusted HTML to an allowlist, HTMLToMarkdown converts it for Markdown exports, SafeURL checks link targets. |
|
media
Package media stores uploaded files in a local directory.
|
Package media stores uploaded files in a local directory. |
|
ratelimit
Package ratelimit counts attempts per key in a sliding window, in memory.
|
Package ratelimit counts attempts per key in a sliding window, in memory. |
|
Package mail sends e-mails.
|
Package mail sends e-mails. |
|
Package markdown escapes plain values for Markdown output, such as the content.Block Markdown funcs behind the .md page variants and llms.txt.
|
Package markdown escapes plain values for Markdown output, such as the content.Block Markdown funcs behind the .md page variants and llms.txt. |
|
Package plugin is baseplate's extension API.
|
Package plugin is baseplate's extension API. |
|
plugins
|
|
|
forms
Package forms is the forms plugin: editors build forms in the admin, place them on pages with the "form" block, and the CMS server receives the submissions of the static site, stores them and sends them by e-mail.
|
Package forms is the forms plugin: editors build forms in the admin, place them on pages with the "form" block, and the CMS server receives the submissions of the static site, stores them and sends them by e-mail. |
|
Package render executes frontend templates.
|
Package render executes frontend templates. |
|
Package settings gives typed access to the site settings (a singleton content type registered by fields.Core).
|
Package settings gives typed access to the site settings (a singleton content type registered by fields.Core). |
|
Package storage defines the persistence contract of baseplate.
|
Package storage defines the persistence contract of baseplate. |
|
sqlite
Package sqlite provides the SQLite storage adapter (pure Go, no CGO).
|
Package sqlite provides the SQLite storage adapter (pure Go, no CGO). |