Documentation
¶
Overview ¶
Package people presents the people behind an organisation: staff, a team, a board or volunteers. Each person has a name, photo, contact details and links, and per language a group (such as "Board" or "Staff"), a role and a Markdown biography. People are kept in a manually ordered list and published one by one. Add an instance with:
app.Use(people.Module("team", "Team"))
When the module is mounted on a page it serves the list at "/" and one person at "/{slug}". The slug is made from the name when the editor leaves it empty and is unique per instance. The website renders:
people/list.gohtml ListView: everyone, also grouped by Group people/person.gohtml Person: one person
Templates anywhere on the site can show people without Go code:
{{range people "team"}}<a href="{{.URL}}">{{.Name}}</a>{{end}}
{{range peopleIn "team" "Board"}}{{.Name}}, {{.Role}}{{end}}
{{with person "team" "jane-doe"}}<img src="{{.PhotoURL}}" alt="{{.Name}}">{{end}}
The site search finds published people by name, role, group and biography once the module is on a page. Group names compare case-insensitively in the current language. Person.URL is empty while the module is not mounted on a page. Use Person.PhoneURL for tel: links, because html/template blocks the tel: scheme in plain strings.
Index ¶
- func Module(key, title string) webthings.Module
- type APIPerson
- type Fields
- type Group
- type Item
- type ListView
- type Person
- type Service
- func (s *Service) BySlug(ctx context.Context, locale, slug string) (Person, error)
- func (s *Service) InGroup(ctx context.Context, locale, group string) ([]Person, error)
- func (s *Service) List(ctx context.Context, locale string) ([]Person, error)
- func (s *Service) Store() content.Store[Fields, Text]
- type Text
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type APIPerson ¶
type APIPerson struct {
ID string `json:"id"`
Slug string `json:"slug"`
Name string `json:"name"`
Group string `json:"group"`
Role string `json:"role"`
// BioHTML is the biography as HTML (api.HTML); only the person's own
// endpoint has it.
BioHTML string `json:"bio_html,omitempty"`
Photo *api.Image `json:"photo"`
Email *string `json:"email"`
Phone *string `json:"phone"`
Website *string `json:"website"`
LinkedIn *string `json:"linkedin"`
// URL is the person's page, null while the instance is on no page;
// APIURL the person in the API.
URL *string `json:"url"`
APIURL string `json:"api_url"`
UpdatedAt time.Time `json:"updated_at"`
}
APIPerson is a published person in the content API (see package api), at /api/v1/<key>/people/{id} and in the list of /api/v1/<key>/people, which leaves out BioHTML. The contact details are those the person's page shows, also in its structured data; each is null when not given.
type Fields ¶
type Fields struct {
Slug string `db:"slug"`
Name string `db:"name"`
Photo string `db:"photo_id,null"`
Email string `db:"email"`
Phone string `db:"phone"`
Website string `db:"website"`
LinkedIn string `db:"linkedin"`
}
Fields are the language-independent parts of a person.
type ListView ¶
type ListView struct {
// Title is the title of the page the module is mounted on.
Title string
// People are all published people in their order.
People []Person
// Groups hold the same people grouped by Group, in order of the first
// person of each group. People without a group form a group without name.
Groups []Group
}
ListView is the data of people/list.gohtml.
type Person ¶
type Person struct {
ID string
Slug string
Name string
Group string
Role string
Bio template.HTML
Email string
Phone string
// PhoneURL is a tel: link for Phone, empty without a phone number.
PhoneURL template.URL
Website string
LinkedIn string
// PhotoURL is the photo as pages show it, at most media.ImageWidth
// wide (see frontend.Frontend.Image); PhotoSrcset lists smaller
// copies for a srcset attribute, PhotoWidth and PhotoHeight are the
// size of PhotoURL and PhotoOriginalURL is the uploaded file, for
// downloads. All are empty when the person has no photo.
PhotoURL string
PhotoSrcset string
PhotoOriginalURL string
PhotoWidth int
PhotoHeight int
// URL is the person's page, empty when the module is not mounted.
URL string
}
Person is a published person as templates see it.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service is one People instance, for the website's own code.
func (*Service) BySlug ¶
BySlug returns the published person with slug in locale, or content.ErrNotFound.
func (*Service) InGroup ¶
InGroup returns the published people in locale whose group is group, ignoring case.