redirects.ts#
13 documented symbols. Read the signatures first, then expand each item for parameters, return types, and examples.
Reference#
fngenerateRedirectHtml(dest: string): stringStatic HTML redirect body. dest is escaped.
Static HTML redirect body. dest is escaped.
Signature
export function generateRedirectHtml(dest: string): stringParameters
-
deststring
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): booleanParameters
-
fromstring
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): booleanParameters
-
valuestring
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 | nullParameters
-
valuestring
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): RedirectPlanParameters
-
inputRedirectPlanInput
Returns
interfaceRedirectFilePlanOne planned static HTML redirect.
One planned static HTML redirect.
Signature
export interface RedirectFilePlanMembers
Properties
| Name | Type | Description |
|---|---|---|
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 RedirectPageInputMembers
Properties
| Name | Type | Description |
|---|---|---|
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 RedirectPlanMembers
Properties
| Name | Type | Description |
|---|---|---|
files |
RedirectFilePlan[] |
|
headersoptional |
string |
|
jsonoptional |
string |
|
netlifyoptional |
string |
interfaceRedirectPlanInputInputs for planning redirect files.
Inputs for planning redirect files.
Signature
export interface RedirectPlanInputMembers
Properties
| Name | Type | Description |
|---|---|---|
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.
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): ResolvedRedirectsOptionsParameters
-
valueboolean | RedirectsOptions | Record<string, string> | undefined -
envNodeJS.ProcessEnvoptional · default: process.env
Returns
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[] }>Parameters
-
inputWriteRedirectFilesInput
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 WriteRedirectFilesInputMembers
Properties
| Name | Type | Description |
|---|---|---|
baseoptional |
string |
|
optionsoptional |
ResolvedRedirectsOptions |
|
outDir |
string |
|
pages |
readonly RedirectPageInput[] |