Documentation ¶
Index ¶
- Constants
- Variables
- func ExecCommand(printOutput bool, commandName string, args ...string) error
- func FormatRenderedPages() error
- func GenerateTailwindCSS(cssFileName string) error
- func NewMarkdownRenderer(opts ...html.Option) render.NodeRenderer
- func RenderPages(contentPaths ContentPaths, commonData CommonPageData, icons IconMap, ...) error
- type BasicPageMarkdown
- type BasicPageTemplate
- type CommonPageData
- type ContentPaths
- type GoPackage
- type IconMap
- type Image
- type IndexPageBase
- type IndexPageMarkdown
- type IndexPageTemplate
- type LinkGroup
- type LinkItem
- type MarkdownRenderer
- func (renderer MarkdownRenderer) RegisterFuncs(registerer render.NodeRendererFuncRegisterer)
- func (renderer MarkdownRenderer) RenderImage(writer util.BufWriter, source []byte, node ast.Node, entering bool) (ast.WalkStatus, error)
- func (renderer MarkdownRenderer) RenderLink(writer util.BufWriter, source []byte, node ast.Node, entering bool) (ast.WalkStatus, error)
- func (renderer MarkdownRenderer) RenderParagraph(writer util.BufWriter, source []byte, node ast.Node, entering bool) (ast.WalkStatus, error)
- type Page
- type PageRenderer
- func (renderer *PageRenderer) BuildSitemap() error
- func (renderer *PageRenderer) RenderBasicPage(contentPath string) (err error)
- func (renderer *PageRenderer) RenderIcons() (err error)
- func (renderer *PageRenderer) RenderIndexPage(contentPath string) (err error)
- func (renderer *PageRenderer) RenderProjectPage(projectFile ProjectContentFile) (err error)
- type ParsedProject
- type ParsedProjectGroup
- type ParsedProjectGroups
- type PersonalInfoMarkdown
- type ProjectBase
- type ProjectContentFile
- type ProjectGroupMarkdown
- type ProjectGroupTemplate
- type ProjectMarkdown
- type ProjectPageTemplate
- type ProjectProfile
- type ProjectTemplate
- type TechStackItemMarkdown
- type TechStackItemTemplate
- type TemplateMetadata
Constants ¶
View Source
const ( ProjectPageTemplateName = "project_page.html.tmpl" DefaultTechStackTitle = "Built with" )
View Source
const ( BaseContentDir = "content" BaseOutputDir = "static" PageTemplatesDir = "templates/pages" ComponentTemplatesDir = "templates/components" IconDir = "img/icons" )
View Source
const BasicPageTemplateName = "basic_page.html.tmpl"
Variables ¶
View Source
var TemplateFunctions = template.FuncMap{ "plus1": func(x int) int { return x + 1 }, "personalInfoTextWrapping": func(infoText string) template.HTML { words := strings.Split(infoText, " ") wordCount := len(words) if wordCount < 3 { return template.HTML(infoText) } var builder strings.Builder builder.WriteString(`<span class="whitespace-nowrap">`) cutoff := (wordCount - 1) / 2 for i, word := range words { builder.WriteString(word) if i == cutoff { builder.WriteString("</span>") } if i != wordCount-1 { builder.WriteString(" ") } } return template.HTML(builder.String()) }, }
Functions ¶
func FormatRenderedPages ¶
func FormatRenderedPages() error
func GenerateTailwindCSS ¶
func NewMarkdownRenderer ¶
func NewMarkdownRenderer(opts ...html.Option) render.NodeRenderer
func RenderPages ¶
func RenderPages( contentPaths ContentPaths, commonData CommonPageData, icons IconMap, devMode bool, ) error
Types ¶
type BasicPageMarkdown ¶
type BasicPageMarkdown struct {
Page `yaml:",inline"`
}
type BasicPageTemplate ¶
type BasicPageTemplate struct { Meta TemplateMetadata Content template.HTML }
type CommonPageData ¶
type CommonPageData struct { SiteName string `validate:"required"` SiteDescription string `validate:"required"` BaseURL string `validate:"required,url"` GitHubIssuesLink string `validate:"required,url"` // contains filtered or unexported fields }
func (CommonPageData) GitHubIcon ¶
func (commonData CommonPageData) GitHubIcon() template.HTML
type ContentPaths ¶
type IndexPageBase ¶
type IndexPageMarkdown ¶
type IndexPageMarkdown struct { IndexPageBase ` yaml:",inline"` Page ` yaml:",inline"` PersonalInfo PersonalInfoMarkdown `yaml:"personalInfo"` ProjectGroups []ProjectGroupMarkdown `yaml:"projectGroups,flow" validate:"required,dive"` }
type IndexPageTemplate ¶
type IndexPageTemplate struct { IndexPageBase Meta TemplateMetadata AboutMe template.HTML PersonalInfo []LinkItem // May omit Link field. ProjectGroups []ProjectGroupTemplate }
type MarkdownRenderer ¶
Custom markdown renderer which:
- adds class="break-words" to all links, and target="_blank" to all external links
- adds stand-alone images as <figure>, with alt text in a <figcaption>
Rendering implementations are based on the originals from Goldmark: https://github.com/yuin/goldmark/blob/b2df67847ed38c31cf4f9e32483377a8e907a6ae/renderer/html/html.go
func (MarkdownRenderer) RegisterFuncs ¶
func (renderer MarkdownRenderer) RegisterFuncs(registerer render.NodeRendererFuncRegisterer)
func (MarkdownRenderer) RenderImage ¶
func (renderer MarkdownRenderer) RenderImage( writer util.BufWriter, source []byte, node ast.Node, entering bool, ) (ast.WalkStatus, error)
func (MarkdownRenderer) RenderLink ¶
func (renderer MarkdownRenderer) RenderLink( writer util.BufWriter, source []byte, node ast.Node, entering bool, ) (ast.WalkStatus, error)
func (MarkdownRenderer) RenderParagraph ¶
func (renderer MarkdownRenderer) RenderParagraph( writer util.BufWriter, source []byte, node ast.Node, entering bool, ) (ast.WalkStatus, error)
type Page ¶
type Page struct { Title string `yaml:"title" validate:"required"` Path string `yaml:"path" validate:"required,startswith=/"` TemplateName string `yaml:"templateName" validate:"required,filepath"` RedirectPath string `yaml:"redirectPath"` // Optional. // Must be set with [Page.SetCanonicalURL] after parsing. CanonicalURL string // Nil if page does not host a Go package. GoPackage *GoPackage `yaml:"goPackage" validate:"omitempty"` }
func (*Page) SetCanonicalURL ¶
type PageRenderer ¶
type PageRenderer struct {
// contains filtered or unexported fields
}
func NewPageRenderer ¶
func NewPageRenderer( commonData CommonPageData, icons IconMap, projectCount int, basicPageCount int, otherPagesCount int, devMode bool, ) (PageRenderer, error)
func (*PageRenderer) BuildSitemap ¶
func (renderer *PageRenderer) BuildSitemap() error
func (*PageRenderer) RenderBasicPage ¶
func (renderer *PageRenderer) RenderBasicPage(contentPath string) (err error)
func (*PageRenderer) RenderIcons ¶
func (renderer *PageRenderer) RenderIcons() (err error)
func (*PageRenderer) RenderIndexPage ¶
func (renderer *PageRenderer) RenderIndexPage(contentPath string) (err error)
func (*PageRenderer) RenderProjectPage ¶
func (renderer *PageRenderer) RenderProjectPage(projectFile ProjectContentFile) (err error)
type ParsedProject ¶
type ParsedProject struct { ProjectTemplate Page Page ContentDir string }
type ParsedProjectGroup ¶
type ParsedProjectGroup struct { ProjectGroupTemplate // contains filtered or unexported fields }
type ParsedProjectGroups ¶
type ParsedProjectGroups struct {
// contains filtered or unexported fields
}
func (*ParsedProjectGroups) AddIfIncluded ¶
func (groups *ParsedProjectGroups) AddIfIncluded(project ParsedProject) error
func (*ParsedProjectGroups) IsFull ¶
func (groups *ParsedProjectGroups) IsFull() bool
func (*ParsedProjectGroups) ToSlice ¶
func (groups *ParsedProjectGroups) ToSlice() []ProjectGroupTemplate
type PersonalInfoMarkdown ¶
type ProjectBase ¶
type ProjectBase struct { ProjectProfile `yaml:",inline"` // Optional, defaults to DefaultTechStackTitle when TechStack is not empty. TechStackTitle string `yaml:"techStackTitle"` LinkGroups []LinkGroup `yaml:"linkGroups,flow"` // Optional. Footnote template.HTML `yaml:"footnote"` // Optional. }
type ProjectContentFile ¶
type ProjectContentFile struct {
// contains filtered or unexported fields
}
type ProjectGroupMarkdown ¶
type ProjectGroupTemplate ¶
type ProjectGroupTemplate struct { Title string Projects []ProjectProfile }
type ProjectMarkdown ¶
type ProjectMarkdown struct { ProjectBase ` yaml:",inline"` TechStack []TechStackItemMarkdown `yaml:"techStack,flow"` // Optional. }
type ProjectPageTemplate ¶
type ProjectPageTemplate struct { Meta TemplateMetadata Project ProjectTemplate }
type ProjectProfile ¶
type ProjectProfile struct { Page `yaml:",inline"` Name string `yaml:"name" validate:"required"` TagLine string `yaml:"tagLine" validate:"required"` // Optional if not included in index page. Logo struct { Path string `yaml:"path" validate:"omitempty,filepath"` AltText string `yaml:"altText"` } `yaml:"logo"` IndexPageFallbackIcon template.HTML }
type ProjectTemplate ¶
type ProjectTemplate struct { ProjectBase Description template.HTML TechStack []TechStackItemTemplate }
type TechStackItemMarkdown ¶
type TechStackItemTemplate ¶
type TemplateMetadata ¶
type TemplateMetadata struct { Common CommonPageData Page Page }
Click to show internal directories.
Click to hide internal directories.