Package note
import "gitlab.com/zoralab/bissetii/pkg/internal/note"
Package note is the full package for rendering all compatible note banners.
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 = "note"
// AMPName is the AMP HTML block name.
AMPName = root.AMPPrefix + Name
// ParametersComment are the list of comment headers
// describing inputs.
ParametersComment = `
{{- /* .Type - the icon type: 'warning', 'error', 'success' */ -}}
{{- /* .Icon - the icon image data structure */ -}}
{{- /* .Title - the note title */ -}}
{{- /* .Content - the HTML content of the note component */ -}}
`
)
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 = `
{{- define "` + image.Name + `" -}}` + image.HTML + `{{- end -}}
`
// DepAMPHTML is the Accelerated Mobile Pages HTML output
// type.
DepAMPHTML = `
{{- define "` + image.AMPName + `" -}}` + image.AMPHTML + `{{- end -}}
`
)
Full HTML codes for rendering templates without needing to parse file.
const (
// HTML is the vanilla HTML output type.
HTML = `
<aside class="note {{- if .Type }} {{ .Type -}}{{- end -}}">
{{- if .Icon }}
{{- template "` + image.Name + `" .Icon -}}
{{- end -}}
{{- if .Title }}
<p class="note-title">{{- .Title -}}</p>
{{- end }}
<div class="note-content">
{{ .Content }}
</div>
</aside>
`
// AMPHTML is the Accelerated Mobile Pages HTML output type.
AMPHTML = `
<aside class="note {{- if .Type }} {{ .Type -}}{{- end -}}">
{{- if .Icon }}
{{- template "` + image.AMPName + `" .Icon -}}
{{- end -}}
{{- if .Title }}
<p class="note-title">{{- .Title -}}</p>
{{- end }}
<div class="note-content">
{{ .Content }}
</div>
</aside>
`
)
Data
type Data struct {
Type string
Icon *Icon
Title string
Content string
}
Data is the data structure for rendering the component.
Icon
type Icon struct {
URL string
AltText string
}
Icon are the icon data for rendering the note tiny 25x25 animated icon.