- the module registers seo-sitemap-<locale> at seo.htmlSitemap.paths (defaults pl /mapa-strony, en /sitemap) and seo-sitemap-group-<locale> at <path>/:group (plus <path>/:group/<segment>/:page in the path form); a path an app page already has stays the app's - SeoHtmlSitemapPage (global, overridable): H1, an H2 per non-empty group, categories nested, a large group's link to its group page, sitemap.empty; group pages with a built trail, page suffix and <SeoPagination>; 404 for an unknown group or a page past the last, 301 for ?page=1, 503 when the sitemap API fails - GET /api/__seo__/sitemap proxies the sitemap plugin's HTML API (only while the CMS has the HTML sitemap on for the locale) - <SeoSitemapLink>: the footer link while the HTML sitemap is on - L3 default styles
144 lines
4.2 KiB
TypeScript
144 lines
4.2 KiB
TypeScript
// Wire types of GET /_seo/api/v1/resolve. Field names mirror the Go
|
|
// serializer (classes.Result in sm-seo-plugin) exactly. Types only, so
|
|
// `node --test` can import any util.
|
|
|
|
/** ok, not_found, redirect or gone. */
|
|
export type SeoAction = 'ok' | 'not_found' | 'redirect' | 'gone'
|
|
|
|
export interface SeoMetaTag {
|
|
name: string
|
|
content: string
|
|
}
|
|
|
|
/** The head metadata of a resolved page. Empty strings mean "no value". */
|
|
export interface SeoHead {
|
|
title: string
|
|
description: string
|
|
canonical: string
|
|
robots: string
|
|
x_robots_tag: string
|
|
og: {
|
|
title: string
|
|
description: string
|
|
image: string
|
|
url: string
|
|
/** og:locale of the page (pl_PL); absent from backends before SEO v0.2.0. */
|
|
locale?: string
|
|
/** og:locale:alternate values, one per other translated locale. */
|
|
locale_alternates?: string[]
|
|
}
|
|
twitter: { card: string; site: string }
|
|
verification: SeoMetaTag[]
|
|
}
|
|
|
|
export interface SeoResolveAnswer {
|
|
action: SeoAction
|
|
/** The HTTP status the frontend should answer with (200, 301, 302, 404, 410). */
|
|
status: number
|
|
/** The absolute target of a redirect answer; absent otherwise. */
|
|
location?: string
|
|
/** The absolute URL of the page on the site URL. */
|
|
url: string
|
|
locale: string
|
|
/** True outside the backend's production environment: noindex everywhere. */
|
|
staging: boolean
|
|
/** Set on ok answers only. */
|
|
seo: SeoHead | null
|
|
// The keys below are additive (SEO plugin v0.2.0); an older backend leaves
|
|
// them out and every consumer treats an absent key as empty.
|
|
/** The <html lang> value (pl, pl-PL), set on ok answers. */
|
|
html_lang?: string
|
|
/** hreflang alternates including the page itself and x-default; absolute URLs. */
|
|
alternates?: SeoAlternate[]
|
|
/** One {"@context", "@graph"} object, or null. */
|
|
jsonld?: SeoJsonLd | null
|
|
breadcrumbs?: SeoBreadcrumb[]
|
|
/** Present only when the request carries a page number. */
|
|
pagination?: SeoPaginationAnswer
|
|
outbound?: SeoOutbound
|
|
autolinks?: Array<{ phrase: string; url: string }>
|
|
autolink_max?: number
|
|
}
|
|
|
|
export interface SeoAlternate {
|
|
hreflang: string
|
|
url: string
|
|
}
|
|
|
|
/** A schema.org node; @id links nodes across the graph. */
|
|
export type SeoSchemaNode = Record<string, unknown> & { '@id'?: string; '@type'?: string | string[] }
|
|
|
|
export interface SeoJsonLd {
|
|
'@context'?: string
|
|
'@graph'?: SeoSchemaNode[]
|
|
}
|
|
|
|
export interface SeoBreadcrumb {
|
|
name: string
|
|
url: string
|
|
path: string
|
|
}
|
|
|
|
export interface SeoPaginationAnswer {
|
|
form?: 'query' | 'path'
|
|
param?: string
|
|
segment?: string
|
|
page?: number
|
|
/** A page value that is not a page number (?page=abc): the layer answers 404. */
|
|
invalid?: boolean
|
|
}
|
|
|
|
export interface SeoOutbound {
|
|
new_tab?: boolean
|
|
nofollow_domains?: string[]
|
|
sponsored_domains?: string[]
|
|
}
|
|
|
|
/** GET /_seo/api/v1/site. Every key may be absent on an older backend. */
|
|
export interface SeoSiteAnswer {
|
|
site_url?: string
|
|
default_locale?: string
|
|
locales?: string[]
|
|
unprefixed_locale?: string
|
|
links?: { new_tab?: boolean }
|
|
html_sitemap?: { enabled?: boolean; paths?: Record<string, string>; page_size?: number }
|
|
routes?: Array<{ type: string; pattern: string }>
|
|
/** Root file names the backend serves (verification files, the IndexNow key file). */
|
|
root_files?: string[]
|
|
llms?: boolean
|
|
pagination?: { form?: 'query' | 'path'; param?: string; segments?: Record<string, string> }
|
|
home_crumb?: { name?: string; url?: string } | null
|
|
}
|
|
|
|
/** One link of the HTML sitemap (GET /_sitemap/api/v1/html); children nest the category tree. */
|
|
export interface SeoSitemapEntry {
|
|
title: string
|
|
url: string
|
|
children?: SeoSitemapEntry[]
|
|
}
|
|
|
|
/** A group of the HTML sitemap overview. */
|
|
export interface SeoSitemapGroup {
|
|
key: string
|
|
slug: string
|
|
title: string
|
|
total: number
|
|
entries: SeoSitemapEntry[]
|
|
/** True when the group has more than the overview lists: link its group page. */
|
|
more: boolean
|
|
}
|
|
|
|
/** The overview (GET /_sitemap/api/v1/html?locale=). */
|
|
export interface SeoSitemapOverview {
|
|
groups: SeoSitemapGroup[]
|
|
}
|
|
|
|
/** One page of a group (GET /_sitemap/api/v1/html/{group}?locale=&page=). */
|
|
export interface SeoSitemapGroupPage {
|
|
group: string
|
|
title: string
|
|
page: number
|
|
pages: number
|
|
entries: SeoSitemapEntry[]
|
|
}
|