Documentation
¶
Overview ¶
Package htmlrewrite provides transforms applied while generating HTML pages and their resources. Document transforms rewrite parsed HTML in place.
Index ¶
- func AddFontPreloads(node *html.Node, outDir, pageDir string, mode MissingResourceMode) error
- func AddResourceVersions(node *html.Node, outDir, pageDir string, mode MissingResourceMode) error
- func Minify(node *html.Node) error
- func MinifyCSS(out io.Writer, in io.Reader) error
- func MinifyJS(out io.Writer, in io.Reader) error
- func RewritePageLinks(node *html.Node, keepHTMLExtension bool)
- type MissingResourceMode
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddFontPreloads ¶
func AddFontPreloads(node *html.Node, outDir, pageDir string, mode MissingResourceMode) error
AddFontPreloads appends a <link rel="preload"> element to the end of the document's <head> for every woff2 font used by the document's local stylesheets. pageDir is the document's directory relative to the site root, used to resolve relative stylesheet URLs. mode controls missing stylesheets.
func AddResourceVersions ¶
func AddResourceVersions(node *html.Node, outDir, pageDir string, mode MissingResourceMode) error
AddResourceVersions appends a content hash query to every local resource URL. mode controls missing resources.
func Minify ¶
Minify minifies the document, including CSS in style elements and JavaScript in script elements.
func RewritePageLinks ¶
RewritePageLinks adjusts every hyperlink to a local page so that it matches the URL that page is served at.
Types ¶
type MissingResourceMode ¶
type MissingResourceMode int
MissingResourceMode controls how missing local resources are handled.
const ( ErrorOnMissingResource MissingResourceMode = iota IgnoreMissingResource )