Package anchor
import "gitlab.com/zoralab/bissetii/pkg/internal/anchor"
Package anchor is the full package for rendering all compatible <a>
link.
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.
More specification info is available at: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a
Constants
Constants for managing the package as a whole.
const (
// Name is the block name (`{{- define "this-name" -}}`).
Name = "anchor"
// AMPName is the AMP HTML block name.
AMPName = root.AMPPrefix + Name
// ParametersComment are the list of comment headers
// describing inputs.
ParametersComment = `
{{- /* .URL - URL of the link */ -}}
{{- /* .ID - ID attribute for the link */ -}}
{{- /* .Class - Class attribute for the link */ -}}
{{- /* .Rel - Relationship attribute for the link */ -}}
{{- /* .Lang - Language hint attribute */ -}}
{{- /* .Target - Javascript action upon clicking the link */ -}}
{{- /* .Download - Download flag to set link as download */ -}}
{{- /* .Content - Link contents */ -}}
`
)
Full HTML codes for rendering templates without needing to parse file.
const (
// HTML is the vanilla HTML output type.
HTML = `
<a href="{{- .URL -}}"
{{- if .ID }}
id="{{- .ID -}}"
{{- end }}
{{- if .Class }}
class="{{- .Class -}}"
{{- end }}
{{- if .Rel }}
rel="{{- .Rel -}}"
{{- end }}
{{- if .Lang }}
hreflang="{{- .Lang -}}"
{{- end }}
{{- if .Target }}
target="{{- .Target -}}"
{{- end }}
{{- if .Download }}
download
{{- end -}}
>{{- if .Content }}{{ .Content }}{{- end -}}</a>
`
// AMPHTML is the Accelerated Mobile Pages HTML output type.
AMPHTML = HTML
)
Data
type Data struct {
URL string
ID string
Class string
Rel string
Lang string
Target string
Download string
Content string
}
Data is the data structure for rendering the component.