Documentation ¶
Index ¶
- Constants
- func Iframe(si SiteInfo, yb []byte) ([]byte, error)
- func Thumb(p string, width, height int) (string, error)
- type NavItem
- type PageFeedInfo
- type SiteInfo
- func (si *SiteInfo) AbsURL(u string) (string, error)
- func (si *SiteInfo) CheckStatic(p string) error
- func (si *SiteInfo) IframeDir() string
- func (si *SiteInfo) InlineDir() string
- func (si *SiteInfo) InlineGenDir() string
- func (si *SiteInfo) PageDir() string
- func (si *SiteInfo) ReadInline(fn string) string
- func (si *SiteInfo) StaticDir() string
- func (si *SiteInfo) StaticGenDir() string
- func (si *SiteInfo) TemplateDir() string
Constants ¶
const ( // Extensions for non-AMP and AMP pages. HTMLExt = ".html" AMPExt = ".amp.html" IndexPage = indexFileBase + HTMLExt // FeedFile is the filename for the site's Atom feed. FeedFile = "atom.xml" )
const IframeOutDir = "iframes"
IframeOutDir is the subdirectory under the output dir for generated iframe pages.
const (
// WebPExt is the extension for generated WebP image files.
WebPExt = ".webp"
)
Variables ¶
This section is empty.
Functions ¶
Types ¶
type NavItem ¶
type NavItem struct { string `yaml:"name"` // It may also be e.g. a "mailto:" link, or an empty string for the site's index page. URL string `yaml:"url"` // It may be empty if the item doesn't correspond to the top of a page // (e.g. if it contains a fragment). ID string `yaml:"id"` // described page itself is currently active). OmitFromMenu bool `yaml:"omit_from_menu"` Children []*NavItem `yaml:"children"` }Name
NavItem describes a single item displayed in the site navigation menu.
func (*NavItem) AMPURL ¶
AMPURL returns the the AMP version of n.URL, e.g. "page.html#frag" becomes "page.amp.html#frag". If n does not represent a page, n.URL is returned unchanged.
func (*NavItem) FindID ¶
FindID returns the item with the supplied ID (possibly n itself) rooted at n. Returns nil if the item is not found.
func (*NavItem) IsBarePage ¶
IsBarePage returns true if n.URL represents a bare page without a fragment, e.g. "foo.html". If n does not represent a bare page, an empty string is returned.
func (*NavItem) VisibleChildren ¶
VisibleChildren returns children that have not been explicitly omitted from the navigation menu.
type PageFeedInfo ¶
PageFeedInfo contains metadata about a page that is needed to generate an Atom feed.
func Page ¶
Page renders and returns the page described by the supplied Markdown data. The id parameter specifies the page's default ID, although this can be overriden in the page block. The amp parameter specifies whether the AMP or non-AMP version of the page should be rendered. The returned feed info is nil if the page should not be included in the Atom feed.
type SiteInfo ¶
type SiteInfo struct { // BaseURL is the base site URL with a trailing slash, e.g. "https://www.example.org/". BaseURL string `yaml:"base_url"` // TitleSuffix is appended to page titles that don't explicitly forbid it. TitleSuffix string `yaml:"title_suffix"` // DefaultDesc is used as the default meta description for pages. DefaultDesc string `yaml:"default_desc"` // ManifestPath contains the path to the web manifest file, e.g. "site.webmanifest". ManifestPath string `yaml:"manifest_path"` // FaviconPaths contains paths to favicon images in the order they should be listed. // See https://dev.to/masakudamatsu/favicon-nightmare-how-to-maintain-sanity-3al7. FaviconPaths []string `yaml:"favicon_paths"` // AppleTouchIconPath is the path to the apple-touch-icon image. // Per https://realfavicongenerator.net/faq, this should be a 180x180 PNG named "apple-touch-icon.png". AppleTouchIconPath string `yaml:"apple_touch_icon_path"` NavText string `yaml:"nav_text"` // FeedTitle is used as the title for the RSS (Atom) feed. FeedTitle string `yaml:"feed_title"` // FeedDesc is used as the description for the RSS (Atom) feed. FeedDesc string `yaml:"feed_desc"` // LogoPathHTML is the image at the top of the page for non-AMP, e.g. "resources/logo-*.png". // The image's intrinsic dimensions for larger displays come from the smallest image. // The second-smallest image is used for mobile if it isn't a 2x version of the smallest image. LogoPathHTML string `yaml:"logo_path_html"` // LogoWidthHTML contains LogoPathHTML's width in pixels. Only needed for SVG. LogoWidthHTML int `yaml:"logo_width_html"` // LogoHeightHTML contains LogoPathHTML's height in pixels. Only needed for SVG. LogoHeightHTML int `yaml:"logo_height_html"` // LogoPathAMP is the AMP analogue to LogoPathHTML. LogoPathAMP string `yaml:"logo_path_amp"` // LogoWidthAMP contains LogoPathAMP's width in pixels. Only needed for SVG. LogoWidthAMP int `yaml:"logo_width_amp"` // LogoHeightAMP contains LogoPathAMP's height in pixels. Only needed for SVG. LogoHeightAMP int `yaml:"logo_height_amp"` // LogoAlt contains the alt text for the logo image. LogoAlt string `yaml:"logo_alt"` NavTogglePath string `yaml:"nav_toggle_path"` NavToggleWidth int `yaml:"nav_toggle_width"` NavToggleHeight int `yaml:"nav_toggle_height"` // MenuButtonPath is the image used to show the menu on AMP. MenuButtonPath string `yaml:"menu_button_path"` // MenuButtonWidth contains MenuButtonPath's width in pixels. Only needed for SVG. MenuButtonWidth int `yaml:"menu_button_width"` // MenuButtonHeight contains MenuButtonPath's height in pixels. Only needed for SVG. MenuButtonHeight int `yaml:"menu_button_height"` // DarkButtonPath is the image used to toggle between light and dark mode. DarkButtonPath string `yaml:"dark_button_path"` // DarkButtonWidth contains DarkButtonPath's width in pixels. Only needed for SVG. DarkButtonWidth int `yaml:"dark_button_width"` // DarkButtonHeight contains DarkButtonPath's height in pixels. Only needed for SVG. DarkButtonHeight int `yaml:"dark_button_height"` // The following fields are used in structured data. AuthorName string `yaml:"author_name"` AuthorEmail string `yaml:"author_email"` PublisherName string `yaml:"publisher_name"` PublisherLogoPath string `yaml:"publisher_logo_path"` // GoogleAnalyticsCode uniquely identifies the site, e.g. "UA-123456-1". // Google Analytics is only used for the AMP version of the page (typically served from a CDN), // and only if this field is non-empty. GoogleAnalyticsCode string `yaml:"google_analytics_code"` // GoogleMapsAPIKey is used for Google Maps API billing. // It is only needed if maps are embedded in the site. GoogleMapsAPIKey string `yaml:"google_maps_api_key"` // CloudflareAnalyticsToken identifies the site for Cloudflare Web Analytics, // e.g. "4d65822107fcfd524d65822107fcfd52". This is only used for the non-AMP version of the page, // and only if this field is non-empty. CloudflareAnalyticsToken string `yaml:"cloudflare_analytics_token"` // D3ScriptURL is the URL of the minified d3.js to use for graphs. // The CDN-hosted version of the file is used by default. D3ScriptURL string `yaml:"d3_script_url"` // ExtraStaticDirs contains extra dirs to copy into the output dir. // Keys are paths relative to the site dir and values are paths relative to the output dir. ExtraStaticDirs map[string]string `yaml:"extra_static_dirs"` // CodeStyleLight contains the Chroma style to use when highlighting code in the light theme. // See https://xyproto.github.io/splash/docs/all.html for available styles. CodeStyleLight string `yaml:"code_style_light"` // CodeStyleDark is like CodeStyleLight, but used for the dark theme. CodeStyleDark string `yaml:"code_style_dark"` // CodeForcePlain indicates that bold, italic, and underline formatting should be removed from // Chroma styles. CodeForcePlain bool `yaml:"code_force_plain"` NavItems []*NavItem `yaml:"nav_items"` // LinkTags is automatically generated from ManifestPath, FaviconPaths, and AppleTouchIconPath. LinkTags []linkTagInfo `yaml:"-"` // CloudflareAnalyticsScriptURL is sourced for Cloudflare Web Analytics. CloudflareAnalyticsScriptURL string `yaml:"-"` // CloudflareAnalyticsConnectPattern is a CSP connect-src pattern matching connections // made by CloudflareAnalyticsScriptURL. CloudflareAnalyticsConnectPattern string `yaml:"-"` // CompressPages specifies whether a .html.gz, gzip-compressed file should be generated // alongside every .html file. This is useful for web hosts that don't automatically compress // pages when they are being served. CompressPages bool `yaml:"compress_pages"` // contains filtered or unexported fields }
SiteInfo specifies high-level information about the site.
func NewSiteInfo ¶
NewSiteInfo constructs a new SiteInfo from the YAML file at p.
func (*SiteInfo) AbsURL ¶
AbsURL converts the supplied string into an absolute URL by appending it to si.BaseURL. Returns the unchanged string if it's already absolute. Returns an error if the URL is absolute but not prefixed by si.BaseURL.
func (*SiteInfo) CheckStatic ¶
CheckStatic returns an error if p (e.g. "foo/bar.png") doesn't exist in si.StaticDir, si.StaticGenDir, or in the matching si.ExtraStaticDirs source dir.
func (*SiteInfo) InlineGenDir ¶
func (*SiteInfo) ReadInline ¶
ReadInline reads and returns the contents of the named file in si.InlineDir or si.InlineGenDir. It returns an empty string if the file does not exist and panics if the file cannot be read.