commit | 9f4cce61e852241d324674d07d018531d0b5f6d9 | [log] [tgz] |
---|---|---|
author | Russ Cox <rsc@google.com> | Mon May 17 12:11:28 2021 -0400 |
committer | Russ Cox <rsc@google.com> | Mon May 24 23:12:15 2021 -0400 |
tree | d5ef9ba272e96dff07b961a7b02679bcb6108027 | |
parent | 06809778bfb27c6b860af6bad916fd9949033d8e [diff] |
[x/go.dev] all: simplify page↔template API Overall, this CL changes Pages from an object with behaviors to just plain old data operated on by templates. All the necessary behaviors, like loading information about related pages, become registered functions. This CL simplifies the mental model: a page is literally nothing more than data rendered by a template. For example, instead of Parent and CurrentSection returning *Page objects, they now return just the path (/foo) of the page, which can be passed to the "page" function to load that page if needed. Section now returns that path form too, instead of omitting the leading slash. So "page .Section" is the section's landing page. CurrentSection is actually gone entirely, but if needed it would be "page .Dir". This CL merges the Page.Params and other fields into a single map, so that templates don't have to say .Params all over the place just to get at per-page in what is already the per-page data object. In that map, the convention is that uppercase keys are the ones supplied by the site package itself, and the lowercase keys are the ones from the page's YAML data. But that's just a convention. ".Params.foo" is now just ".foo". A few YAML fields known to Hugo seem to have been available in multiple casings: in particular, series and Series, title and Title. Fix the templates to use the form from the YAML: lowercase. Similarly, replace where and sort, which required a custom expression evaluator separate from the template engine, with more limited functions "pages" (which loads pages from a given set of files) and "newest" (which sorts them by date and then title). These are less to understand, and the rest can be done with plain templates (with the help of a new "add" function). Unexport Page since nothing needs it to be exported. Change-Id: I8a927515c45880f52dcc3cea38ac3252fe1bff15 X-GoDev-Commit: 7b0e82257a7b492fae378ea9ee51cf7c924d98a1
This repository holds the Go Website server code and content.
The easiest way to install is to run go get -u golang.org/x/website
. You can also manually git clone the repository to $GOPATH/src/golang.org/x/website
.
This repository uses Gerrit for code changes. To learn how to submit changes to this repository, see https://golang.org/doc/contribute.html.
The main issue tracker for the time repository is located at https://github.com/golang/go/issues. Prefix your issue with “x/website:” in the subject line, so it is easy to find.