From 42262ba11537850d9b94f7a2b76f3880b19f4c85 Mon Sep 17 00:00:00 2001 From: Danny van Kooten Date: Mon, 1 Jul 2024 16:55:15 +0200 Subject: [PATCH] document the Page variable in README --- README.md | 29 ++++++++++++++++++++++++++++- gozer.go | 13 +++++++++++++ 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index ee15816..327f919 100644 --- a/README.md +++ b/README.md @@ -99,7 +99,34 @@ Title # The current page title, shorthand for Page.Title Content # The current page's HTML content. ``` -For example, to show a list of the 5 most recent posts: +The `Page` variable is an instance of the object below: + +``` +type Page struct { + // Title of this page + Title string + + // Template this page uses for rendering. Defaults to "default.html". + Template string + + // Time this page was published (parsed from file name). + DatePublished time.Time + + // Time this page was last modified on the filesystem. + DateModified time.Time + + // The full URL to this page, including the site URL. + Permalink string + + // URL path for this page, relative to site URL + UrlPath string + + // Path to source file for this page, relative to content root + Filepath string +} +``` + +To show a list of the 5 most recent posts: ```gotemplate {{ range (slice .Posts 0 5) }} diff --git a/gozer.go b/gozer.go index 9e671fd..1efe07b 100644 --- a/gozer.go +++ b/gozer.go @@ -45,12 +45,25 @@ type Site struct { } type Page struct { + // Title of this page Title string + + // Template this page uses for rendering. Defaults to "default.html". Template string + + // Time this page was published (parsed from file name). DatePublished time.Time + + // Time this page was last modified (from filesystem). DateModified time.Time + + // The full URL to this page (incl. site URL) Permalink string + + // URL path for this page, relative to site URL UrlPath string + + // Path to source file for this page, relative to content root Filepath string }