Documentation
¶
Index ¶
- func IsContentAsset(urlPath string) bool
- func ReadFile(fs http.FileSystem, path string) ([]byte, error)
- func WalkFileSystem(fs http.FileSystem, filterFn func(path string) bool, ...) error
- type ContentPage
- type PageData
- type Site
- func (s *Site) AllContentPages(ctx context.Context, contentVersion string) ([]*ContentPage, error)
- func (s *Site) Check(ctx context.Context, contentVersion string) (problems []string, err error)
- func (s *Site) GetResources(dir, version string) (http.FileSystem, error)
- func (s *Site) Handler() http.Handler
- func (s *Site) RenderContentPage(page *PageData) ([]byte, error)
- func (s *Site) ResolveContentPage(ctx context.Context, contentVersion, path string) (*ContentPage, error)
- func (s *Site) Search(ctx context.Context, contentVersion string, queryStr string) (*search.Result, error)
- type VersionedFileSystem
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsContentAsset ¶
IsContentAsset reports whether the file in the site contents file system is a content asset (i.e., not a Markdown file). It typically matches .png, .gif, and .svg files.
func WalkFileSystem ¶
func WalkFileSystem(fs http.FileSystem, filterFn func(path string) bool, walkFn func(path string) error) error
WalkFileSystem walks a file system and calls walkFn for each file that passes filterFn.
Types ¶
type ContentPage ¶
type ContentPage struct {
Path string // the canonical URL path (without ".md" or "/index.md")
FilePath string // the filename on disk
Data []byte // the page's file contents
Doc markdown.Document // the Markdown doc
Breadcrumbs []breadcrumbEntry // ancestor breadcrumb for this page
}
ContentPage represents a Markdown-formatted documentation page. To create a ContentPage, use one of the Site methods.
type PageData ¶
type PageData struct {
ContentVersion string // content version string requested
ContentPagePath string // content page path requested
ContentVersionNotFoundError bool // whether the requested version was not found
ContentPageNotFoundError bool // whether the requested content page was not found
// Content is the content page, when it is found.
Content *ContentPage
}
PageData is the data available to the HTML template used to render a page.
type Site ¶
type Site struct {
// Content is the versioned file system containing the Markdown files and assets (e.g., images)
// embedded in them.
Content VersionedFileSystem
// ContentExcludePattern is a regexp matching file paths to exclude in the content file system.
ContentExcludePattern *regexp.Regexp
// Base is the base URL (typically including only the path, such as "/" or "/help/") where the
// site is available.
Base *url.URL
// Root is the root URL that is only used for specific cases where an absolute URL is mandatory,
// such as for opengraph tags in the headers for example. It must include both the scheme and
// host.
Root *url.URL
// AssetsBase is the base URL (sometimes only including the path, such as "/assets/") where the
// assets are available.
AssetsBase *url.URL
// Redirects contains a mapping from URL path to redirect destination URL.
Redirects map[string]*url.URL
// CheckIgnoreURLPattern is a regexp matching URLs to ignore in the Check method.
CheckIgnoreURLPattern *regexp.Regexp
// SkipIndexURLPattern is a regexp matching URLs to ignore when searching. Any files that have a URL that match this
// pattern will be ignored from the search index.
SkipIndexURLPattern *regexp.Regexp
}
Site represents a documentation site, including all of its templates, assets, and content.
func (*Site) AllContentPages ¶
AllContentPages returns a list of all content pages in the site.
func (*Site) GetResources ¶ added in v1.9.3
func (s *Site) GetResources(dir, version string) (http.FileSystem, error)
func (*Site) RenderContentPage ¶
RenderContentPage renders a content page using the template.
func (*Site) ResolveContentPage ¶
func (s *Site) ResolveContentPage(ctx context.Context, contentVersion, path string) (*ContentPage, error)
ResolveContentPage looks up the content page at the given version and path (which generally comes from a URL). The path may omit the ".md" file extension and the "/index" or "/index.md" suffix.
If the resulting ContentPage differs from the path argument, the caller should (if possible) communicate a redirect.
type VersionedFileSystem ¶
type VersionedFileSystem interface {
OpenVersion(ctx context.Context, version string) (http.FileSystem, error)
}
VersionedFileSystem represents multiple versions of an http.FileSystem.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
docsite
command
|
|
|
internal
|
|
|
search
Package search implements site search.
|
Package search implements site search. |
|
search/index
Package index implements a search index.
|
Package index implements a search index. |
|
search/query
Package query implements search query parsing and matching.
|
Package query implements search query parsing and matching. |
|
Package markdown parses and HTML-renders Markdown documents.
|
Package markdown parses and HTML-renders Markdown documents. |