site

package
v0.17.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 1, 2026 License: CC-BY-4.0, ISC Imports: 33 Imported by: 0

Documentation

Overview

Package site builds the astrophena.name static site.

A source tree is expected to contain these directories:

build      Default output directory for the generated site.
pages      Source pages in HTML or Markdown format.
static     Static assets copied into the generated site, with hashing and
           minification applied where appropriate.
templates  HTML templates used to render pages. Front matter selects the
           template for each page, and template files must have a .html
           extension.

Front Matter

Each page must be HTML or Markdown and begin with a JSON front matter object:

{
  "title": "Hello, world!",
  "template": "layout",
  "permalink": "/hello-world"
}

See Page for the full list of front matter fields.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Build

func Build(c *Config) error

Build builds a site based on the provided Config.

func Serve

func Serve(ctx context.Context, c *Config, addr string) error

Serve builds the site and starts serving it on a provided host:port.

Types

type Config

type Config struct {
	// Title is the title of the site.
	Title string
	// Author is the name of the author of the site.
	Author string
	// BaseURL is the base URL of the site.
	BaseURL *url.URL
	// Src is the directory where to read files from. If empty, uses the current
	// directory.
	Src string
	// Dst is the directory where to write files. If empty, uses the build
	// directory.
	Dst string
	// Prod determines if the site should be built in a production mode. This
	// means that drafts are excluded and the base URL is used to derive absolute
	// URLs from relative ones.
	Prod bool
	// SkipFeed disables feed generation.
	SkipFeed bool
	// Vanity indicates that this build is for the vanity import site.
	// When set, navLink uses PrimaryURL instead of BaseURL.
	Vanity bool
	// PrimaryURL is the base URL for navigation links when Vanity set to true.
	PrimaryURL *url.URL
	// contains filtered or unexported fields
}

Config configures a site build or dev server.

type Page

type Page struct {
	Title       string            `json:"title"`                  // title: Page title, required.
	Permalink   string            `json:"permalink"`              // permalink: Output path for the page, required.
	Template    string            `json:"template"`               // template: Template that should be used for rendering this page, required.
	ContentOnly bool              `json:"content_only,omitempty"` // content_only: Determines whether this page should be rendered without header and footer, false by default.
	Date        *date             `json:"date,omitempty"`         // date: Publication date in the 'year-month-day' format, e.g. 2006-01-02, optional.
	Draft       bool              `json:"draft,omitempty"`        // draft: Excludes the page from production builds when true.
	MetaTags    map[string]string `json:"meta_tags,omitempty"`    // meta_tags: Determines additional HTML meta tags that will be added to this page, optional.
	Summary     string            `json:"summary,omitempty"`      // summary: Page summary, used in RSS feed, optional.
	Type        string            `json:"type,omitempty"`         // type: Used to distinguish different kinds of pages, page by default.
	CSS         []string          `json:"css,omitempty"`          // css: Additional CSS files that should be loaded, optional.
	JS          []string          `json:"js,omitempty"`           // js: Additional JavaScript files that should be loaded, optional.
	// contains filtered or unexported fields
}

Page represents a site page. Its exported fields are populated from front matter.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址