Skip to content

Articles · Modules

2 modules · 7 exports · 0 repositories · 9 e2e tests · 2 routes

Who imports who · hover a node
Depends onArticles modulesUsed byArticle5 exportsArticles.server2 exportsRoutes1 fileLoaders2 filesFeedItems.serverfeed

Article

app/features/articles/core/Article.ts

An 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

interface

ArticleAuthor

:24

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

function

normalizeAuthors

:33

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)
function

authorHref

:49

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)
Routes/a/:slug
function

bodyWithoutLeadingTitle

:71

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)
Routes/a/:slug
function

description

:104

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
Unit tests (5)

Articles

serverapp/features/articles/core/Articles.server.ts

Articles are the markdown files of content/articles: the file name is the article's slug and the front matter gives its title, date and authors. The list of articles is read once and kept in memory, an article's body on every request to it. A development build reads everything again on every call, so new and edited files show without a restart.

Imports
Article
Used by
2 loaders1 module

Functions & values

function

findBySlug

:36

The article of the slug with its markdown body and link preview description (the front matter's description, else {@link Article.description} of the body), null when there is no such article or its front matter is invalid. Only slugs of the files in the articles folder are read, so a slug can't lead outside of it.

export function findBySlug(slug: string):
	| (Omit<ArticleListing, "slug"> & {
			content: string;
			description: string | null;
	  })
	| null
Unit tests (4)
Loaders/a/:slug
function

mostRecent

:72

The count newest articles, newest first. Throws if any article's front matter is invalid.

export async function mostRecent(count: number)
Unit tests (4)