File: /var/www/quadcode.com/node_modules/super-sitemap/dist/sitemap.d.ts
export type ParamValues = Record<string, never | string[] | string[][]>;
export type SitemapConfig = {
additionalPaths?: [] | string[];
changefreq?: 'always' | 'daily' | 'hourly' | 'monthly' | 'never' | 'weekly' | 'yearly' | false;
excludePatterns?: [] | string[];
headers?: Record<string, string>;
lang?: {
default: string;
alternates: string[];
};
maxPerPage?: number;
origin: string;
page?: string;
paramValues?: Record<string, never | string[] | string[][]>;
priority?: 0.0 | 0.1 | 0.2 | 0.3 | 0.4 | 0.5 | 0.6 | 0.7 | 0.8 | 0.9 | 1.0 | false;
processPaths?: (paths: PathObj[]) => PathObj[];
sort?: 'alpha' | false;
};
export type LangConfig = {
default: string;
alternates: string[];
};
export type Alternate = {
lang: string;
path: string;
};
export type PathObj = {
path: string;
alternates?: Alternate[];
};
/**
* Generates an HTTP response containing an XML sitemap.
*
* @public
* @remarks Default headers set 1h CDN cache & no browser cache.
*
* @param config - Config object.
* @param config.origin - Required. Origin URL. E.g. `https://example.com`. No trailing slash
* @param config.excludePatterns - Optional. Array of regex patterns for paths to exclude.
* @param config.paramValues - Optional. Object of parameter values. See format in example below.
* @param config.additionalPaths - Optional. Array of paths to include manually. E.g. `/foo.pdf` in your `static` directory.
* @param config.headers - Optional. Custom headers. Case insensitive.
* @param config.changefreq - Optional. `changefreq` value to use for all paths. Default is `false` to exclude this property from each sitemap entry.
* @param config.priority - Optional. `priority` value to use for all paths. Default is `false` to exclude this property from each sitemap entry.
* @param config.processPaths - Optional. Callback function to arbitrarily process path objects.
* @param config.sort - Optional. Default is `false` and groups paths as static paths (sorted), dynamic paths (unsorted), and then additional paths (unsorted). `alpha` sorts all paths alphabetically.
* @param config.maxPerPage - Optional. Default is `50_000`, as specified in https://www.sitemaps.org/protocol.html If you have more than this, a sitemap index will be created automatically.
* @param config.page - Optional, but when using a route like `sitemap[[page]].xml to support automatic sitemap indexes. The `page` URL param.
* @returns An HTTP response containing the generated XML sitemap.
*
* @example
*
* ```js
* return await sitemap.response({
* origin: 'https://example.com',
* excludePatterns: [
* '^/dashboard.*',
* `.*\\[page=integer\\].*`
* ],
* paramValues: {
* '/blog/[slug]': ['hello-world', 'another-post']
* '/campsites/[country]/[state]': [
* ['usa', 'new-york'],
* ['usa', 'california'],
* ['canada', 'toronto']
* ]
* },
* additionalPaths: ['/foo.pdf'],
* headers: {
* 'Custom-Header': 'blazing-fast'
* },
* changefreq: 'daily',
* priority: 0.7,
* sort: 'alpha'
* });
* ```
*/
export declare function response({ additionalPaths, changefreq, excludePatterns, headers, lang, maxPerPage, origin, page, paramValues, priority, processPaths, sort, }: SitemapConfig): Promise<Response>;
/**
* Generates an XML response body based on the provided paths, using sitemap
* structure from https://kit.svelte.dev/docs/seo#manual-setup-sitemaps.
*
* @private
* @remarks
* - Based on https://kit.svelte.dev/docs/seo#manual-setup-sitemaps
* - Google ignores changefreq and priority, but we support these optionally.
* - TODO We could consider adding `<lastmod>` with an ISO 8601 datetime, but
* not worrying about this for now.
* https://developers.google.com/search/blog/2014/10/best-practices-for-xml-sitemaps-rssatom
*
* @param origin - The origin URL. E.g. `https://example.com`. No trailing slash
* because "/" is the index page.
* @param paths - Array of string paths to include in the sitemap. Each should
* start with '/'; but if not, it will be added.
* @returns The generated XML sitemap.
*/
export declare function generateBody(origin: string, paths: PathObj[], changefreq?: SitemapConfig['changefreq'], priority?: SitemapConfig['priority']): string;
/**
* Generates a sitemap index XML string.
*
* @private
* @param origin - The origin URL. E.g. `https://example.com`. No trailing slash.
* @param pages - The number of sitemap pages to include in the index.
* @returns The generated XML sitemap index.
*/
export declare function generateSitemapIndex(origin: string, pages: number): string;
/**
* Generates an array of paths, based on `src/routes`, to be included in a
* sitemap.
*
* @public
*
* @param excludePatterns - Optional. An array of patterns for routes to be
* excluded.
* @param paramValues - Optional. An object mapping each parameterized route to
* an array of param values for that route.
* @param lang - Optional. The language configuration.
* @returns An array of strings, each representing a path for the sitemap.
*/
export declare function generatePaths(excludePatterns?: string[], paramValues?: ParamValues, lang?: LangConfig): PathObj[];
/**
* Filters and normalizes an array of route paths.
*
* @public
*
* @param routes - An array of route strings from Vite's `import.meta.blog`.
* E.g. ['src/routes/blog/[slug]/+page.svelte', ...]
* @param excludePatterns - An array of regular expression patterns to match
* routes to exclude.
* @returns A sorted array of cleaned-up route strings.
* E.g. ['/blog/[slug]', ...]
*
* @remarks
* - Removes trailing slashes from routes, except for the homepage route. If
* SvelteKit specified this option in a config, rather than layouts, we could
* read the user's preference, but it doesn't, we use SvelteKit's default no
* trailing slash https://kit.svelte.dev/docs/page-options#trailingslash
*/
export declare function filterRoutes(routes: string[], excludePatterns: string[]): string[];
/**
* Builds parameterized paths using paramValues provided (e.g.
* `/blog/hello-world`) and then removes the respective tokenized route (e.g.
* `/blog/[slug]`) from the routes array.
*
* @public
*
* @param routes - An array of route strings, including parameterized routes
* E.g. ['/', '/about', '/blog/[slug]', /blog/tags/[tag]']
* @param paramValues - An object mapping parameterized routes to a 1D or 2D
* array of their parameter's values. E.g.
* {
* '/blog/[slug]': ['hello-world', 'another-post']
* '/campsites/[country]/[state]': [
* ['usa','miami'],
* ['usa','new-york'],
* ['canada','toronto']
* ]
* }
*
* @returns A tuple where the first element is an array of routes and the second
* element is an array of generated parameterized paths.
*
* @throws Will throw an error if a `paramValues` key doesn't correspond to an
* existing route, for visibility to the developer.
* @throws Will throw an error if a parameterized route does not have data
* within paramValues, for visibility to the developer.
*/
export declare function generatePathsWithParamValues(routes: string[], paramValues: ParamValues): {
pathsWithLang: string[];
pathsWithoutLang: string[];
};
/**
* Given all routes, return a new array of routes that includes all versions of
* any route that contains one or more optional params. Only process routes that
* contain an optional param _other than_ [[lang]].
*
* @private
* @param routes - Array of routes to process.
* @returns Array of routes containing all version for those with optional
* params.
*/
export declare function processRoutesForOptionalParams(routes: string[]): string[];
/**
* Processes a route containing >=1 optional parameters, represented by double
* square brackets. It generates all possible versions of this route that
* SvelteKit considers valid. Notice we add `+/page.svelte`, that is so these
* routes have a consistent pattern as others so that `filterRoutes()` will
* apply consistently when called later.
*
* @private
* @param route - Route to process. E.g. `/foo/[[paramA]]`
* @returns An array of routes. E.g. [`/foo`, `/foo/[[paramA]]`]
*/
export declare function processOptionalParams(route: string): string[];
/**
* Generate path objects with language variations.
* @param paths - An array of paths.
* @param langConfig - The language configuration.
* @returns An array of path objects.
*/
export declare function generatePathsWithLang(paths: string[], langConfig: LangConfig): PathObj[];
/**
* Removes duplicate paths from an array of PathObj, keeping the last occurrence
* of any duplicates.
*
* Duplicate pathObjs could occur due to a developer using additionalPaths or
* processPaths() and not properly excluding a pre-existing path.
*
* @param pathObjs - An array of PathObj to deduplicate.
* @returns A new array of PathObj with duplicates removed, retaining the last
* occurrence of any duplicates.
*/
export declare function deduplicatePaths(pathObjs: PathObj[]): PathObj[];
/**
* Normalizes the user-provided `additionalPaths` to ensure each starts with a
* forward slash and then returns a `PathObj[]` type.
*
* Note: `additionalPaths` are never translated based on the lang config because
* they could be something like a PDF within the user's static dir.
*
* @param additionalPaths - An array of string paths to be normalized
* @returns An array of PathObj
*/
export declare function normalizeAdditionalPaths(additionalPaths: string[]): PathObj[];