Package link

import "gitlab.com/zoralab/bissetii/pkg/internal/link"

Package link is the full package for rendering HTML <link> tag.

The HTML template codes are written in Go’s string format under the corresponding group. This allows one to embed the HTML codes instead of parsing it from file.

Constants

Constants for managing the package as a whole.

const (
	// Name is the block name (`{{- define "this-name" -}}`).
	Name = "link"

	// AMPName is the AMP HTML block name.
	AMPName = root.AMPPrefix + Name

	// ParametersComment are the list of comment headers
	// describing inputs.
	ParametersComment = `
{{- /* .URL             = Link source URL value for href= attribute       */ -}}
{{- /* .Type            = Link type= value                                */ -}}
{{- /* .Rel             = Link relationship value for rel= attribute      */ -}}
{{- /* .As              = Link as= value                                  */ -}}
{{- /* .CrossOrigin     = Link CORS ID (MUST have .Integrity)             */ -}}
{{- /*                     1. 'anonymous' - no credential needed          */ -}}
{{- /*                     2. 'use-credentials' - use credentials         */ -}}
{{- /* .Integrity       = Link SRI (MUST have .CrossOrigin)               */ -}}
{{- /* .Disabled        = Link disabled flag                              */ -}}
{{- /* .Media           = Link media= value                               */ -}}
{{- /* .OnLoad          = Link onload= value                              */ -}}
{{- /* .Lang            = Link language hinting for hreflang= attribute   */ -}}
{{- /* .ImageSizes      = Link imagesizes= value                          */ -}}
{{- /* .ImageSrcSet     = Link imagesrcset= value                         */ -}}
{{- /* .Sizes           = Link sizes= value                               */ -}}
{{- /* .Title           = Link title= value                               */ -}}
{{- /* .Referrer        = Link referrerpolicy= value                      */ -}}
`
)

Dependencies are the dependent codes for building independent template.

This is useful for rendering portable template usage like Hugo partials where they do not share a common definition source.

const (
	// DepHTML is the vanilla HTML output type.
	DepHTML = ``

	// DepAMPHTML is the Accelerated Mobile Pages HTML output
	// type.
	DepAMPHTML = ``
)

Full HTML codes for rendering templates without needing to parse file.

const (
	// HTML is the vanilla HTML output type.
	HTML = `
<link href="{{- .URL -}}"
{{- if .Type }}

	{{ .Type -}}
{{- end }}

{{- if .Rel }}

	rel="{{ .Rel -}}"
{{- end }}

{{- if .Sizes }}

	sizes="{{ .Sizes -}}"
{{- end }}

{{- if .As }}

	as="{{ .As -}}"
{{- end }}

{{- if and .Integrity .CrossOrigin }}

	integrity="{{- .Integrity -}}"

	crossorigin="{{- .CrossOrigin -}}"
{{- end }}

{{- if .Disabled }}

	disabled
{{- end }}

{{- if .Lang }}

	hreflang="{{- .Lang -}}"
{{- end }}

{{- if .ImageSizes }}

	imageSizes="{{- .ImageSizes -}}"
{{- end }}

{{- if .ImageSrcSet }}

	imageSrcSet="{{- .ImageSrcSet -}}"
{{- end }}

{{- if .Title }}

	title="{{- .Title -}}"
{{- end }}

{{- if .Referrer }}

	referrer="{{- .Referrer -}}"
{{- end }}

{{- if .Media }}

	media="{{- .Media -}}"
{{- end }}

{{- if .OnLoad }}

	onload="{{- .OnLoad -}}"
{{- end -}}
/>
`

	// AMPHTML is the Accelerated Mobile Pages HTML output type.
	AMPHTML = HTML
)

Data

type Data struct {
	URL         string
	Type        string
	Rel         string
	As          string
	CrossOrigin string
	Integrity   string
	Disabled    bool
	Lang        string
	ImageSizes  string
	ImageSrcSet string
	Media       string
	Sizes       string
	Title       string
	Referrer    string
}

Data is the data structure for rendering the component.