server

package
v0.0.0-...-91ddf87 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2025 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidLayoutType = errors.New("layout must be a string")

ErrInvalidLayoutType is returned when the layout metadata is not a string

View Source
var (
	LayoutFile = "layout.md"
)

Functions

func GetMeta

func GetMeta(content []byte) (map[string]any, error)

func PathToUrl

func PathToUrl(path string, ext string) string

PathToUrl converts a staticFile path to a URL. Ex.: "foo/bar/index.html" -> "/foo/bar" Ex.: "foo/bar/blog.html" -> "/foo/bar/blog"

func StripExt

func StripExt(fileName string) string

StripExt removes the extension from a file name. "index.html" -> "index" "bar.md" -> "bar"

Types

type ErrLayoutNotFound

type ErrLayoutNotFound struct {
	Layout           string
	AvailableLayouts []string
}

ErrLayoutNotFound is returned when a specified layout cannot be found in the registry

func (ErrLayoutNotFound) Error

func (e ErrLayoutNotFound) Error() string

type ErrMissingLayout

type ErrMissingLayout struct {
	AvailableLayouts []string
}

ErrMissingLayout is returned when no layout is specified in the metadata

func (ErrMissingLayout) Error

func (e ErrMissingLayout) Error() string

type FsItem

type FsItem struct {
	IsStatic bool
	Path     string
	Layout   string
	URL      string
}

func IndexDirectory

func IndexDirectory(fsys fs.FS, dir string) ([]*FsItem, error)

type MarkdownLoader

type MarkdownLoader struct {
	// contains filtered or unexported fields
}

func NewLoader

func NewLoader(fsys fs.FS) *MarkdownLoader

func (*MarkdownLoader) GetMeta

func (m *MarkdownLoader) GetMeta(path string) (map[string]any, error)

func (*MarkdownLoader) Load

func (m *MarkdownLoader) Load(item *FsItem, reg registry.Registry) (Page, error)

type Page

type Page interface {
	templ.Component
	// Name returns the name of the page. Ex.: "introduction"
	Name() string

	// Path returns the relative path of the page.
	// Ex.: "docs/introduction.md"
	Path() string

	// URL returns the page url mapped from the filesystem.
	// Ex.: "docs/introduction.md" -> "/docs/introduction"
	// Ex.: "docs/index.md" -> "/docs"
	URL() string

	// Meta returns the metadata of the page.
	// ---
	// Title: goldmark-meta
	// Summary: Add YAML metadata to the document
	// ---
	// tuns into
	// map[string]any{
	// 	"Title": "goldmark-meta",
	// 	"Summary": "Add YAML metadata to the document",
	// }
	Meta() map[string]any
}

Jump to

Keyboard shortcuts

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