Documentation
¶
Overview ¶
Package lists keeps short ordered lists such as FAQs, services, features or steps. One module instance is one list (for team members with photos, roles and pages of their own, use the people module):
app.Use(lists.Module("faq", "FAQ"), lists.Module("services", "Services"))
Each entry has a title and a Markdown body per language, and optionally an image and a link. Entries are published one by one and keep the order set in the admin (the move buttons on the list's overview).
When the list is mounted on a page, the website renders lists/list.gohtml with a ListView. To show a list elsewhere, for example the FAQ on the home page, use the entries template function ({{range entries "faq"}}) or Of(app, "faq").Entries(ctx, locale) from Go; both return the same entries.
Every Entry has an ID. The site search links to an entry on the list's page at #<ID>, so give each entry id="{{.ID}}" as the generated starting point does.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type APIEntry ¶
type APIEntry struct {
ID string `json:"id"`
Title string `json:"title"`
BodyHTML string `json:"body_html"`
Image *api.Image `json:"image"`
// Link is the entry's link as a visitor follows it from the list's
// page: a path of the site made absolute, an anchor on the list's
// page, other addresses (https:, mailto:, tel:) as they are; null
// without a link.
Link *string `json:"link"`
// URL is the entry on the list's page (#<id>), null while the list is
// on no page; APIURL the entry in the API.
URL *string `json:"url"`
APIURL string `json:"api_url"`
UpdatedAt time.Time `json:"updated_at"`
}
APIEntry is a published entry in the content API (see package api), at /api/v1/<key>/entries/{id} and in the list of /api/v1/<key>/entries. Entries have no page of their own: the list's page shows them whole, so the list has their text too.
type Entry ¶
type Entry struct {
ID string
Title string
Body template.HTML
// ImageURL is the entry's image as pages show it, at most media.ImageWidth
// wide (see frontend.Frontend.Image); ImageSrcset lists smaller
// copies for a srcset attribute, ImageWidth and ImageHeight are the
// size of ImageURL and ImageOriginalURL is the uploaded file, for
// downloads. All are empty when the entry has no image.
ImageURL string
ImageSrcset string
ImageOriginalURL string
ImageWidth int
ImageHeight int
// Link is empty when not set. It is a template.URL because the store only
// accepts paths, anchors and http(s), mailto: and tel: addresses, so
// templates can use it in href without html/template replacing tel:
// links with #ZgotmplZ.
Link template.URL
}
Entry is a published entry as templates see it.
type ListView ¶
type ListView struct {
// Key is the list's instance key, for example "faq", so one template can
// show several lists differently.
Key string
// Title is the title of the page the list is mounted on.
Title string
Entries []Entry
}
ListView is the data of lists/list.gohtml.