90 lines
1.7 KiB
TypeScript
90 lines
1.7 KiB
TypeScript
import type { Request } from 'express'
|
|
|
|
// Throughout our codebase we "extend" the Request object by attaching
|
|
// things to it. For example `req.context = { currentCategory: 'foo' }`.
|
|
// This type aims to match all the custom things we do to requests
|
|
// througout the codebase.
|
|
export type ExtendedRequest = Request & {
|
|
pagePath?: string
|
|
context?: {
|
|
currentCategory?: string
|
|
error?: Error
|
|
}
|
|
language?: string
|
|
userLanguage?: string
|
|
// Add more properties here as needed
|
|
}
|
|
|
|
type Language = {
|
|
name: string
|
|
code: string
|
|
hreflang: string
|
|
dir: string
|
|
wip: boolean
|
|
}
|
|
|
|
export type Languages = {
|
|
[key: string]: Language
|
|
}
|
|
|
|
type Permalink = {
|
|
languageCode: string
|
|
pageVersion: string
|
|
title: string
|
|
href: string
|
|
}
|
|
|
|
type Versions = {
|
|
feature?: string
|
|
fpt?: string
|
|
ghec?: string
|
|
ghes?: string
|
|
}
|
|
|
|
export type Page = {
|
|
mtime: number
|
|
permalinks: Permalink[]
|
|
fullPath: string
|
|
title: string
|
|
shortTitle?: string
|
|
intro: string
|
|
languageCode: string
|
|
documentType: string
|
|
renderProp: (prop: string, context: any, opts: any) => Promise<string>
|
|
markdown: string
|
|
versions: Versions
|
|
}
|
|
|
|
export type Tree = {
|
|
page: Page
|
|
children: string[] | undefined
|
|
href: string
|
|
childPages?: Tree[]
|
|
}
|
|
export type VersionedTree = {
|
|
[version: string]: Tree
|
|
}
|
|
|
|
export type SiteTree = {
|
|
[languageCode: string]: VersionedTree
|
|
}
|
|
|
|
export type UnversionedTree = {
|
|
page: Page
|
|
children: string[]
|
|
childPages: UnversionedTree[]
|
|
}
|
|
|
|
export type UnversionLanguageTree = {
|
|
[languageCode: string]: UnversionedTree
|
|
}
|
|
|
|
export type Site = {
|
|
pages: Record<string, Page>
|
|
redirects: Record<string, string>
|
|
unversionedTree: UnversionLanguageTree
|
|
siteTree: SiteTree
|
|
pageList: Page[]
|
|
pageMap: Record<string, Page>
|
|
}
|