API โ€บ @builder.io/qwik-city/static

generate

Use this function when SSG should be generated from another module, such as a Vite plugin. This function's should be passed the paths of the entry module and Qwik City Plan.

export declare function generate(
  opts: StaticGenerateOptions
): Promise<StaticGenerateResult>;
ParameterTypeDescription
optsStaticGenerateOptions

Returns:

Promise<StaticGenerateResult>

Edit this section

StaticGenerateOptions

export interface StaticGenerateOptions extends StaticGenerateRenderOptions

Extends: StaticGenerateRenderOptions

PropertyModifiersTypeDescription
basePathname?string(Optional) Defaults to /
qwikCityPlanModulePathstringPath to the Qwik City Plan module exporting the default @qwik-city-plan.
renderModulePathstringPath to the SSR module exporting the default render function. In most cases it'll be ./src/entry.ssr.tsx.
rootDir?string(Optional)

Edit this section

StaticGenerateRenderOptions

export interface StaticGenerateRenderOptions extends RenderOptions

Extends: RenderOptions

PropertyModifiersTypeDescription
emit404Pages?boolean(Optional) Set to false if the static build should not write custom or default 404.html pages. Defaults to true.
emitData?boolean(Optional) Set to false if the generated q-data.json data files should not be written to disk. Defaults to true.
emitHtml?boolean(Optional) Set to false if the generated static HTML files should not be written to disk. Setting to false is useful if the SSG should only write the q-data.json files to disk. Defaults to true.
exclude?string[](Optional) Defines file system routes relative to the source routes directory that should not be static generated. Accepts wildcard behavior. This should not include the "base" pathname. exclude always takes priority over include.
include?string[](Optional) Defines file system routes relative to the source routes directory that should be static generated. Accepts wildcard behavior. This should not include the "base" pathname. If not provided, all routes will be static generated. exclude always takes priority over include.
log?'debug'(Optional) Log level.
maxTasksPerWorker?number(Optional) Maximum number of tasks to be running at one time per worker. Defaults to 20.
maxWorkers?number(Optional) Maximum number of workers to use while generating the static pages. Defaults to the number of CPUs available.
originstringThe URL origin, which is a combination of the scheme (protocol) and hostname (domain). For example, https://qwik.builder.io has the protocol https:// and domain qwik.builder.io. However, the origin does not include a pathname.The origin is used to provide a full URL during Static Site Generation (SSG), and to simulate a complete URL rather than just the pathname. For example, in order to render a correct canonical tag URL or URLs within the sitemap.xml, the origin must be provided too.If the site also starts with a pathname other than /, please use the basePathname option in the Qwik City config options.
outDirstringFile system directory where the static files should be written.
sitemapOutFile?string | null(Optional) File system path to write the sitemap.xml to. Defaults to sitemap.xml and written to the root of the outDir. Setting to null will prevent the sitemap from being created.

Edit this section

StaticGenerateResult

export interface StaticGenerateResult
PropertyModifiersTypeDescription
durationnumber
errorsnumber
renderednumber
staticPathsstring[]

Edit this section