Skip to content

Commit

Permalink
document the Page variable in README
Browse files Browse the repository at this point in the history
  • Loading branch information
dannyvankooten committed Jul 1, 2024
1 parent c3d8e1f commit 42262ba
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
29 changes: 28 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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) }}
Expand Down
13 changes: 13 additions & 0 deletions gozer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit 42262ba

Please sign in to comment.