Documentation
¶
Overview ¶
Package identity holds the site's declared author, as the one Person its structured data names.
A selfdoc site has one author, declared in selfdoc.json under "author" and required there. Every emitter that needs an identity -- the per-page article's author and publisher, the front page's standalone entity, the CV page's profile -- reads it through this package, so a site states the same Person everywhere and states it once.
What used to happen instead is why the block is required: with no author declared, the emitters minted {"@type": "Organization", "name": <project_name>}, inventing an organisation out of a directory name and publishing it as fact. That path is gone. A caller that reaches these functions without a declared author gets a refusal naming the config key.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var AuthorKeys = []string{"name", "url", "same_as"}
AuthorKeys is every key an "author" block may carry, mirroring the config schema.
var ErrNoDeclaredAuthor = errors.New(
"structured data needs the declared author, and this build has " +
"none with both 'name' and 'url'. selfdoc.json requires " +
`"author": {"name": ..., "url": ...}; there is no inferred ` +
"author and no organisation is minted from the project name.")
ErrNoDeclaredAuthor is the refusal every entry point returns when the build has no author with both a name and a URL. It names the config key rather than falling back to anything: there is no inferred author.
Functions ¶
This section is empty.
Types ¶
type Entity ¶
type Entity []Property
Entity is a JSON-LD entity as an ordered property list.
The order is part of the output, not an implementation detail: the emitted structured data is rendered by walking the entity, and a Person reads "@context" (when it stands as its own document), then "@type", "name", "url", "sameAs", then whatever the page contributed. A Go map carries no order, so the entity is a slice.
func PersonEntity ¶
PersonEntity returns the declared author as a schema.org Person.
withContext adds "@context" for an entity emitted as its own JSON-LD document rather than nested inside one. extra carries the properties only a particular page knows -- a CV's occupation, languages and schools -- and is merged after the identity properties, each entry skipped when its value is empty. An extra whose key is one of the identity properties replaces that property where it already stands, so the property order does not change.
It returns ErrNoDeclaredAuthor when no author is declared.
func (*Entity) Set ¶
Set assigns key, replacing the value in place when the entity already carries that key and appending it at the end otherwise -- the behavior of assigning into a Python dict, which is what the callers of PersonEntity were written against.