Skip to content

redirects.ts#

View Markdown

Source

13 documented symbols. Read the signatures first, then expand each item for parameters, return types, and examples.

13 symbols 7 functions 5 interfaces 1 modules 8 parameters 18 members 7 returns

Reference#

fngenerateRedirectHtml(dest: string): stringStatic HTML redirect body. dest is escaped.

Static HTML redirect body. dest is escaped.

Signature

export function generateRedirectHtml(dest: string): string

View source

Parameters

  • dest string

Returns

string
fnisHostWildcardSource(from: string): boolean* is host-rule syntax (Netlify / Cloudflare), not a URL segment.

* is host-rule syntax (Netlify / Cloudflare), not a URL segment.

Signature

function isHostWildcardSource(from: string): boolean

View source

Parameters

  • from string

Returns

boolean
fnisSafeDest(value: string): booleanSame-origin path: leading /, not //, and no scheme.

Same-origin path: leading /, not //, and no scheme.

Signature

export function isSafeDest(value: string): boolean

View source

Parameters

  • value string

Returns

boolean
fnnormalizePath(value: string): string | nullStrips a trailing slash except for /. Unsafe values become null.

Strips a trailing slash except for /. Unsafe values become null.

Signature

export function normalizePath(value: string): string | null

View source

Parameters

  • value string

Returns

string | null
fnplanRedirectFiles(input: RedirectPlanInput): RedirectPlanPlans redirect HTML files without writing them.

Plans redirect HTML files without writing them.

Signature

export function planRedirectFiles(input: RedirectPlanInput): RedirectPlan

View source

Parameters

Returns

RedirectPlan
interfaceRedirectFilePlanOne planned static HTML redirect.

One planned static HTML redirect.

Signature

export interface RedirectFilePlan

View source

Members

Properties
NameTypeDescription
from string
html string
relativePath string
to string
interfaceRedirectPageInputOne page that may declare aliases or a single redirect source.

One page that may declare aliases or a single redirect source.

Signature

export interface RedirectPageInput

View source

Members

Properties
NameTypeDescription
aliasesoptional unknown
dest string
redirectoptional unknown
interfaceRedirectPlanPlanned redirect files and optional host / JSON bodies.

Planned redirect files and optional host / JSON bodies.

Signature

export interface RedirectPlan

View source

Members

Properties
NameTypeDescription
files RedirectFilePlan[]
headersoptional string
jsonoptional string
netlifyoptional string
interfaceRedirectPlanInputInputs for planning redirect files.

Inputs for planning redirect files.

Signature

export interface RedirectPlanInput

View source

Members

Properties
NameTypeDescription
baseoptional string
optionsoptional ResolvedRedirectsOptions | null
pages readonly RedirectPageInput[]
moduleredirectsOpt-in static redirects / aliases. HTML bodies follow oxcontentssg::generate_redirects. The Vite plugin writes those…

Opt-in static redirects / aliases.

HTML bodies follow ox_content_ssg::generate_redirects. The Vite plugin writes those files during SSG without adding a NAPI surface.

View source

fnresolveRedirectsOptions(value: boolean | RedirectsOptions | Record<string, string> | undefined, env: NodeJS.ProcessEnv = process.env): ResolvedRedirectsOptionsResolves redirects with defaults. false / omitted stays off. true or {} enables…

Resolves redirects with defaults.

false / omitted stays off. true or {} enables empty defaults. A path map ({ "/old": "/new" }) enables the feature with that map. { map, provider, headers, json, html, allowExternal } overrides only set fields. Pass env to inject CI detection without reading the real process.env.

Signature

export function resolveRedirectsOptions(value: boolean | RedirectsOptions | Record<string, string> | undefined, env: NodeJS.ProcessEnv = process.env): ResolvedRedirectsOptions

View source

Parameters

  • value boolean | RedirectsOptions | Record<string, string> | undefined
  • env NodeJS.ProcessEnv

    optional · default: process.env

Returns

ResolvedRedirectsOptions
fnwriteRedirectFiles(input: WriteRedirectFilesInput): Promise<{ files: string[] }>Writes planned redirect HTML (and optional host files) into outDir.

Writes planned redirect HTML (and optional host files) into outDir.

Signature

export async function writeRedirectFiles(input: WriteRedirectFilesInput): Promise<{ files: string[] }>

View source

Parameters

Returns

Promise<{ files: string[] }>
interfaceWriteRedirectFilesInputInputs for writing redirect files next to generated HTML.

Inputs for writing redirect files next to generated HTML.

Signature

export interface WriteRedirectFilesInput

View source

Members

Properties
NameTypeDescription
baseoptional string
optionsoptional ResolvedRedirectsOptions
outDir string
pages readonly RedirectPageInput[]