Sitemap
Generate a site map for the web crawlers to collect.
Installation
npm i @gracile/sitemap
π /vite.config.ts
import { defineConfigfunction defineConfig(config: UserConfig): UserConfig (+3 overloads)
Type helper to make it easier to use vite.config.ts
accepts a direct
{@link
UserConfig
}
object, or a function that returns it.
The function receives a
{@link
ConfigEnv
}
object.
} from 'vite';
import { viteSitemapPluginfunction viteSitemapPlugin(options: {
siteUrl: string;
robotsTxt?: [string, string][] | false;
}): any[]
} from '@gracile/sitemap/vite';
const SITE_URLconst SITE_URL: "https://example.com/"
= 'https://example.com/';
export default defineConfigfunction defineConfig(config: UserConfig): UserConfig (+3 overloads)
Type helper to make it easier to use vite.config.ts
accepts a direct
{@link
UserConfig
}
object, or a function that returns it.
The function receives a
{@link
ConfigEnv
}
object.
({
// ...
pluginsUserConfig.plugins?: PluginOption[] | undefined
Array of vite plugins to use.
: [
viteSitemapPluginfunction viteSitemapPlugin(options: {
siteUrl: string;
robotsTxt?: [string, string][] | false;
}): any[]
({
This is mandatory.
siteUrlsiteUrl: string
: SITE_URLconst SITE_URL: "https://example.com/"
,
This is the default robots.txt that you can override if needed.
robotsTxtrobotsTxt?: false | [string, string][] | undefined
Default value:
[['User-agent', '*'], ['Allow', '/'], ['Sitemap', `${hostname}sitemap.xml`]]
: [
['User-agent', '*'],
['Allow', '/'],
['Sitemap', `${SITE_URLconst SITE_URL: "https://example.com/"
}sitemap.xml`],
],
}),
// ...
],
});
Based on sitemap.