render

package
v0.48.1 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package render renders a page from content held in memory, writing nothing.

The build pipeline turns a post into a page by writing it into the docs tree, building, and deleting it again. That is fine for a build and useless for an editor: previewing an unsaved buffer must not touch the working tree at all -- no injected files, no staleness baselines, no manifest.

This is that path. It hands the same payloads the injector would have written to the build's single-pass entry point as an in-memory overlay, with baseline writing off, and returns the page HTML as the build would have written it. Same directive resolution, same HTML pass, same addressing -- the only difference is that nothing is written.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Post

func Post(opts PostOptions, h *effects.Handle) (string, error)

Post renders one post to its final HTML from an in-memory buffer.

The result is byte-identical to the file a posts-target build writes for the same content saved to disk, and the call writes nothing anywhere.

It is an error when no config is found, when the post is a draft and drafts were not asked for, and when the rendered page is missing from the build result.

Types

type PostOptions

type PostOptions struct {
	// DirPath is the project root.
	DirPath string
	// SourcePath is the post's path relative to the posts directory, e.g.
	// "hello.md". The file need not exist -- an unsaved new post renders
	// the same way.
	SourcePath string
	// Content is the post's Markdown source, frontmatter included, as it
	// would be saved.
	Content string
	// Config is a pre-loaded config. Nil loads selfdoc.json from DirPath.
	Config config.Config
	// IncludeDrafts renders the post even when its frontmatter marks it a
	// draft. It mirrors the build flag of the same name: with it off, a
	// draft has no page and asking for one is an error.
	IncludeDrafts bool
}

PostOptions is what one Post render takes.

Jump to

Keyboard shortcuts

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