pages

package
v0.3.5 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2024 License: BSD-3-Clause Imports: 29 Imported by: 0

Documentation

Overview

Package pages provides an easy way to make content-focused sites consisting of Markdown, HTML, and Cogent Core.

Index

Constants

This section is empty.

Variables

View Source
var Examples = map[string]func(b core.Widget){}

Examples are the different core examples that exist as compiled Go code that can be run in pages. The map is keyed by ID. Generated pagegen.go files add to this by finding all code blocks with language Go (must be uppercase, as that indicates that is an "exported" example).

View Source
var NumExamples = map[string]int{}

NumExamples has the number of examples per page URL.

Functions

func ExampleHandler

func ExampleHandler(ctx *htmlcore.Context) bool

ExampleHandler is the htmlcore handler for <pages-example> HTML elements that handles examples.

Types

type Page

type Page struct {
	core.Frame

	// Source is the filesystem in which the content is located.
	Source fs.FS

	// Context is the page's [htmlcore.Context].
	Context *htmlcore.Context `set:"-"`
	// contains filtered or unexported fields
}

Page represents a content page with support for navigating to other pages within the same source content.

func NewPage

func NewPage(parent ...tree.Node) *Page

NewPage returns a new Page with the given optional parent: Page represents a content page with support for navigating to other pages within the same source content.

func (*Page) Init added in v0.2.0

func (pg *Page) Init()

func (*Page) MakeToolbar added in v0.2.0

func (pg *Page) MakeToolbar(p *tree.Plan)

func (*Page) MenuSearch added in v0.3.3

func (pg *Page) MenuSearch(items *[]core.ChooserItem)

func (*Page) OpenURL

func (pg *Page) OpenURL(rawURL string, addToHistory bool)

OpenURL sets the content of the page from the given url. If the given URL has no scheme (eg: "/about"), then it sets the content of the page to the file specified by the URL. This is either the "index.md" file in the corresponding directory (eg: "/about/index.md") or the corresponding md file (eg: "/about.md"). If it has a scheme, (eg: "https://example.com"), then it opens it in the user's default browser.

func (*Page) SetContent added in v0.2.2

func (pg *Page) SetContent(content fs.FS) *Page

SetContent is a helper function that calls Page.SetSource with the "content" subdirectory of the given filesystem.

func (*Page) SetSource

func (t *Page) SetSource(v fs.FS) *Page

SetSource sets the [Page.Source]: Source is the filesystem in which the content is located.

Directories

Path Synopsis
examples
Package ppath handles pages paths.
Package ppath handles pages paths.

Jump to

Keyboard shortcuts

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