render

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 28, 2026 License: MIT Imports: 26 Imported by: 0

Documentation

Overview

Package render is a placeholder for Obsite rendering.

Index

Constants

This section is empty.

Variables

View Source
var RequiredHTMLTemplateNames = []string{
	"base.html",
	"note.html",
	"index.html",
	"tag.html",
	"folder.html",
	"timeline.html",
	"404.html",
}

RequiredHTMLTemplateNames lists the HTML template files every external theme must provide.

Functions

func CountWords

func CountWords(htmlContent string) (latinWords, cjkChars int)

CountWords approximates reading units from visible rendered HTML content. Latin text is counted by whitespace-delimited words and CJK text by characters.

func EmbeddedTemplateAssetNames

func EmbeddedTemplateAssetNames() []string

EmbeddedTemplateAssetNames returns the embedded template asset inventory in stable order.

func EmitRuntimeAssets

func EmitRuntimeAssets(outputRoot string) error

EmitRuntimeAssets writes the embedded offline math and Mermaid runtime files into the output root.

func EmitStyleCSS

func EmitStyleCSS(outputRoot string, site model.SiteConfig) (bool, error)

EmitStyleCSS writes the configured stylesheet into the output root. It returns whether style.css was actually written.

func EmitThemeStaticAssets

func EmitThemeStaticAssets(outputRoot string, assets []ThemeStaticAsset) error

EmitThemeStaticAssets copies the provided theme-owned files into the output root.

func FormatReadingTime

func FormatReadingTime(latinWords, cjkChars int) string

FormatReadingTime renders a human-readable reading-time label.

func ReadEmbeddedTemplateAsset

func ReadEmbeddedTemplateAsset(name string) ([]byte, error)

ReadEmbeddedTemplateAsset returns an embedded default template asset.

func RuntimeAssetOutputPaths

func RuntimeAssetOutputPaths() []string

RuntimeAssetOutputPaths returns the output paths reserved for the embedded offline runtime assets.

func VisibleSummary

func VisibleSummary(note *model.Note) string

VisibleSummary derives a fallback summary from a note's normalized visible HTML content.

Types

type FolderPageInput

type FolderPageInput struct {
	Site         model.SiteConfig
	FolderPath   string
	Children     []model.NoteSummary
	Breadcrumbs  []model.Breadcrumb
	LastModified time.Time
	RelPath      string
	Pagination   *model.PaginationData
	SidebarTree  []model.SidebarNode
	HasSearch    bool
}

FolderPageInput supplies the data needed to render a folder listing page.

type IndexPageInput

type IndexPageInput struct {
	Site         model.SiteConfig
	RecentNotes  []model.NoteSummary
	LastModified time.Time
	RelPath      string
	Pagination   *model.PaginationData
	SidebarTree  []model.SidebarNode
	HasSearch    bool
}

IndexPageInput supplies the data needed to render the index page.

type NotFoundPageInput

type NotFoundPageInput struct {
	Site         model.SiteConfig
	RecentNotes  []model.NoteSummary
	LastModified time.Time
	SidebarTree  []model.SidebarNode
	HasSearch    bool
}

NotFoundPageInput supplies the data needed to render the 404 page.

type NotePageInput

type NotePageInput struct {
	Site            model.SiteConfig
	Note            *model.Note
	Tags            []model.TagLink
	Backlinks       []model.BacklinkEntry
	RelatedArticles []model.RelatedArticle
	Breadcrumbs     []model.Breadcrumb
	SidebarTree     []model.SidebarNode
	HasSearch       bool
}

NotePageInput supplies the data needed to render a note page.

type RenderedPage

type RenderedPage struct {
	Page        model.PageData
	HTML        []byte
	Diagnostics []diag.Diagnostic
}

RenderedPage is the rendered HTML plus the PageData used to execute it.

func Render404

func Render404(input NotFoundPageInput) (RenderedPage, error)

Render404 renders the default 404 page to HTML using the embedded default templates.

func RenderFolderPage

func RenderFolderPage(input FolderPageInput) (RenderedPage, error)

RenderFolderPage renders a folder listing page to HTML using the embedded default templates.

func RenderIndex

func RenderIndex(input IndexPageInput) (RenderedPage, error)

RenderIndex renders the site index page to HTML using the embedded default templates.

func RenderNote

func RenderNote(input NotePageInput) (RenderedPage, error)

RenderNote renders a note page to HTML using the embedded default templates.

func RenderTagPage

func RenderTagPage(input TagPageInput) (RenderedPage, error)

RenderTagPage renders a tag archive page to HTML using the embedded default templates.

func RenderTimelinePage

func RenderTimelinePage(input TimelinePageInput) (RenderedPage, error)

RenderTimelinePage renders the recent-notes timeline page to HTML using the embedded default templates.

type TagPageInput

type TagPageInput struct {
	Site         model.SiteConfig
	Tag          *model.Tag
	ChildTags    []model.TagLink
	Notes        []model.NoteSummary
	Breadcrumbs  []model.Breadcrumb
	LastModified time.Time
	RelPath      string
	Pagination   *model.PaginationData
	SidebarTree  []model.SidebarNode
	HasSearch    bool
}

TagPageInput supplies the data needed to render a tag archive page.

type ThemeStaticAsset

type ThemeStaticAsset struct {
	SourcePath        string
	ThemeRelativePath string
	OutputPath        string
}

ThemeStaticAsset describes one regular file owned by the selected theme root.

func ListThemeStaticAssets

func ListThemeStaticAssets(themeRoot string) ([]ThemeStaticAsset, error)

ListThemeStaticAssets returns the stable inventory of regular, non-HTML files owned by the selected theme root. Theme-owned HTML is always treated as template input and is never emitted as a static asset.

type TimelinePageInput

type TimelinePageInput struct {
	Site         model.SiteConfig
	TimelinePath string
	Notes        []model.NoteSummary
	LastModified time.Time
	AsHomepage   bool
	RelPath      string
	Pagination   *model.PaginationData
	SidebarTree  []model.SidebarNode
	HasSearch    bool
}

TimelinePageInput supplies the data needed to render a recent-notes timeline page.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL