Documentation
¶
Index ¶
- Variables
- func Author(content string) *element
- func CSP(policy string) *element
- func Charset(charset charset.Charset) *element
- func Description(content string) *element
- func HttpEquiv(directive string, content string) *element
- func Keywords(content string) *element
- func New() *element
- func OG(property string, content string) *element
- func Refresh(seconds int, url string) *element
- func Robots(content string) *element
- func ThemeColor(color string) *element
- func UTF8() *element
- func Viewport(content string) *element
- type Element
Constants ¶
This section is empty.
Variables ¶
var ( TagOpen = []byte("<meta") AttrName = []byte(" name=\"") AttrContent = []byte(" content=\"") AttrCharset = []byte(" charset=\"") AttrHttpEquiv = []byte(" http-equiv=\"") AttrScheme = []byte(" scheme=\"") AttrProperty = []byte(" property=\"") AttrMedia = []byte(" media=\"") )
Byte constants for HTML rendering.
Functions ¶
func Author ¶
func Author(content string) *element
Author Creates a meta author element to identify the document's author. Example: meta.Author("John Doe") Renders: <meta name="author" content="John Doe" />
func CSP ¶ added in v0.3.0
func CSP(policy string) *element
CSP Creates a meta element that sets a Content-Security-Policy for the document. Restricts which resources the browser is allowed to load, helping prevent XSS and data injection attacks. Example: meta.CSP("default-src 'self'; script-src 'self'") Renders: <meta content="default-src 'self'; script-src 'self'" http-equiv="Content-Security-Policy" />
func Charset ¶
Charset Creates a new meta element declaring character encoding. Example: meta.Charset(charset.Custom("custom")) Renders: <meta charset="custom" />
func Description ¶
func Description(content string) *element
Description Creates a meta description element for SEO and search engine snippets. Example: meta.Description("Page description") Renders: <meta name="description" content="Page description" />
func HttpEquiv ¶ added in v0.3.0
HttpEquiv Creates a meta element with an http-equiv directive and content value. Covers directives not wrapped by dedicated constructors like CSP or Refresh. Example: meta.HttpEquiv("X-UA-Compatible", "IE=edge") Renders: <meta content="IE=edge" http-equiv="X-UA-Compatible" />
func Keywords ¶
func Keywords(content string) *element
Keywords Creates a meta keywords element (largely deprecated for SEO). Example: meta.Keywords("html, css, javascript") Renders: <meta name="keywords" content="html, css, javascript" />
func New ¶
func New() *element
New Creates a new meta element without any initial attributes. Example: meta.New() Renders: <meta />
func OG ¶
OG Creates a new meta element for Open Graph protocol properties (social media sharing). Example: meta.OG("title", "My Page Title") Renders: <meta content="My Page Title" property="og:title" />
func Refresh ¶
Refresh Creates a meta refresh element that automatically redirects after specified seconds. Example: meta.Refresh(5, "/new-page") Renders: <meta content="5; url=/new-page" http-equiv="refresh" />
func Robots ¶
func Robots(content string) *element
Robots Creates a meta robots element to control search engine crawling and indexing. Example: meta.Robots("index, follow") Renders: <meta name="robots" content="index, follow" />
func ThemeColor ¶ added in v0.3.0
func ThemeColor(color string) *element
ThemeColor Creates a meta element that sets the browser theme colour for the page. Used by mobile browsers and PWAs to colour the address bar and other UI chrome. Combine with the Media attribute for dark mode support. Example: meta.ThemeColor("#1a1a2e") Renders: <meta name="theme-color" content="#1a1a2e" />