Article
app/features/articles/core/Article.tsAn article as its page shows it: the authors it is credited to, where their names link to, the body without a title line repeating the page's heading and the description of its link previews.
- Imports
- no other modules
- Used by
- 1 route1 module
Types
An author an article is credited to, link leading to their sendou.ink user page or elsewhere.
export interface ArticleAuthor { name: string; link: string | null; }
Functions & values
The authors of an article, from the front matter's author in any of its forms.
export function normalizeAuthors( frontMatterAuthor: FrontMatterAuthor, ): ArticleAuthor[]
Unit tests (1)
- reads $why× 3
Where an author's name links to, null for an author without a link. A sendou.ink link becomes a path within the app (isInternal), anything else is kept as is.
export function authorHref( author: ArticleAuthor, ): { href: string; isInternal: boolean } | null
Unit tests (1)
- $why× 3
The body of an article without a heading of its title, as the page shows the title above the body already. The heading is looked for among the first few non-empty lines, so lines before it (a source notice of an article ported from elsewhere, a banner image) are kept. Only the first heading counts and it can be of any level. Letter case, markdown emphasis and escapes, … written as ... and curly quotes don't keep the two from matching.
export function bodyWithoutLeadingTitle(content: string, title: string)
Unit tests (4)
The description of an article for link previews and search results: the plain text of the body's first line of actual text, cut to fit {@link DESCRIPTION_MAX_LENGTH} characters. Skips the source notice of ported articles ("Article originally posted at: …"), lines of only HTML or images (a banner <img>), a line repeating the title and headings (the title, section names) other than an italic subtitle (#### *…*). Returns null when the body has no such line.
export function description(content: string, title: string): string | null