Documentation
¶
Overview ¶
Package plugins holds tryck's built-in plugins and the registry that enables, configures and orders them for a build.
Index ¶
- Constants
- Variables
- func Each[T any](s *Set) []T
- type Highlight
- func (*Highlight) ConfigKeys() []string
- func (h *Highlight) Extend(m goldmark.Markdown)
- func (h *Highlight) Init(cfg map[string]any, _ plugin.SiteInfo) error
- func (*Highlight) Name() string
- func (h *Highlight) OnBuildComplete(_ plugin.SiteView, out plugin.Outputs) error
- func (*Highlight) Stylesheets() []string
- type LinkCheck
- func (*LinkCheck) ConfigKeys() []string
- func (l *LinkCheck) Init(cfg map[string]any, site plugin.SiteInfo) error
- func (*LinkCheck) Name() string
- func (l *LinkCheck) OnBuildComplete(s plugin.SiteView, _ plugin.Outputs) error
- func (l *LinkCheck) OnPageParsed(p *plugin.Page) error
- func (*LinkCheck) Priority() int
- type Mermaid
- func (*Mermaid) ConfigKeys() []string
- func (m *Mermaid) Extend(md goldmark.Markdown)
- func (m *Mermaid) Init(cfg map[string]any, _ plugin.SiteInfo) error
- func (*Mermaid) Name() string
- func (*Mermaid) OnPageParsed(p *plugin.Page) error
- func (m *Mermaid) OnPageRendered(p *plugin.Page, _ plugin.SiteView) error
- type MermaidBlock
- type ReadingTime
- type Redirects
- type Search
- type Set
- type Sitemap
- type TOC
Constants ¶
const DefaultMermaidURL = "https://cdn.jsdelivr.net/npm/mermaid@11/dist/mermaid.esm.min.mjs"
DefaultMermaidURL loads mermaid 11 from jsDelivr. Point url at a copy in static/ for sites that must work offline.
Variables ¶
var KindMermaidBlock = ast.NewNodeKind("MermaidBlock")
KindMermaidBlock is the node kind of MermaidBlock.
Functions ¶
Types ¶
type Highlight ¶
type Highlight struct {
Theme string `yaml:"theme"`
DarkTheme string `yaml:"darkTheme"` // "" = Theme in both modes
LineNumbers bool `yaml:"lineNumbers"`
}
Highlight colors fenced code blocks with chroma. It emits CSS classes rather than inline styles and writes the theme to /css/chroma.css, so themes and dark mode can be switched in CSS: Theme applies in light mode and DarkTheme in dark mode (see the built-in theme's colorScheme).
func (*Highlight) ConfigKeys ¶ added in v0.2.0
func (*Highlight) OnBuildComplete ¶
func (*Highlight) Stylesheets ¶
type LinkCheck ¶
type LinkCheck struct {
FailOnBroken bool `yaml:"failOnBroken"`
// contains filtered or unexported fields
}
LinkCheck reports internal links to pages or files that do not exist (link.broken) and #fragments missing on their target page (link.anchor). Links are recorded per page while parsing, after tryck has rewritten them to site URLs, and checked once every page is known.
func (*LinkCheck) ConfigKeys ¶ added in v0.2.0
func (*LinkCheck) OnBuildComplete ¶
type Mermaid ¶
type Mermaid struct {
URL string `yaml:"url"`
}
Mermaid renders ```mermaid code blocks as diagrams. Blocks become <pre class="mermaid"> (readable source without JavaScript), and pages that have one get a module script that loads mermaid from URL and draws them, in the dark theme when the page is dark.
func (*Mermaid) ConfigKeys ¶ added in v0.2.0
type MermaidBlock ¶
MermaidBlock is a ```mermaid code block.
func (*MermaidBlock) Dump ¶
func (n *MermaidBlock) Dump(source []byte, level int)
func (*MermaidBlock) IsRaw ¶
func (n *MermaidBlock) IsRaw() bool
func (*MermaidBlock) Kind ¶
func (n *MermaidBlock) Kind() ast.NodeKind
type ReadingTime ¶
type ReadingTime struct {
WordsPerMinute int `yaml:"wordsPerMinute"`
}
ReadingTime stores Data["wordCount"] and Data["readingTime"] (whole minutes, at least 1). Code blocks and raw HTML are not counted.
func (*ReadingTime) ConfigKeys ¶ added in v0.2.0
func (*ReadingTime) ConfigKeys() []string
func (*ReadingTime) Name ¶
func (*ReadingTime) Name() string
func (*ReadingTime) OnPageParsed ¶
func (r *ReadingTime) OnPageParsed(p *plugin.Page) error
type Redirects ¶
type Redirects struct {
// contains filtered or unexported fields
}
Redirects writes a meta-refresh page for every front matter alias: "/old/" becomes old/index.html, "/old.html" becomes old.html.
func (*Redirects) ConfigKeys ¶ added in v0.2.0
type Search ¶
type Search struct {
MaxTextLength int `yaml:"maxTextLength"`
// contains filtered or unexported fields
}
Search writes /search-index.json: [{url, title, headings, text}] for every page that is not a draft, with text cut to MaxTextLength bytes. Code blocks are left out of the text.
func (*Search) ConfigKeys ¶ added in v0.2.0
func (*Search) OnBuildComplete ¶
type Set ¶
type Set struct {
// contains filtered or unexported fields
}
Set is the enabled, initialized plugins of one build, in phase order.
func Load ¶
func Load(cfg *config.Config, site plugin.SiteInfo, extra ...plugin.Plugin) (*Set, []diag.Diagnostic)
Load enables the built-ins plus extra, initializes them and orders them by Priority, then Name. A plugin is enabled unless its section in cfg.Plugins sets enabled: false. Two plugins with the same name are an error and the later one is skipped.
func (*Set) Directives ¶
func (s *Set) Directives() (map[string]plugin.DirectiveRenderer, []diag.Diagnostic)
Directives maps directive names to the plugins rendering them. A name claimed twice, or a built-in name, is an error.
func (*Set) Stylesheets ¶
Stylesheets lists the CSS files enabled plugins need, in phase order.
type Sitemap ¶
type Sitemap struct {
// contains filtered or unexported fields
}
Sitemap writes /sitemap.xml with the absolute URL of every page that is not a draft. It needs a baseUrl with a host.
func (*Sitemap) ConfigKeys ¶ added in v0.2.0
type TOC ¶
TOC stores each page's table of contents as Data["toc"] ([]plugin.TOCEntry), from headings between MinLevel and MaxLevel. Front matter toc: true/false overrides Default.