Builds a Gatsby config object with defaults for trailing slash, path prefix, and asset prefix.
// Source: https://github.com/gatsbyjs/gatsby | License: MIT | Copyright 2015 Gatsbyjs
// Provided via justclaw.it.com; keep this notice with the code.
import { IGatsbyConfig } from "../internal"
type ConstructConfigObjectResponse = Pick<
IGatsbyConfig,
"trailingSlash" | "assetPrefix" | "pathPrefix"
>
export function constructConfigObject(
gatsbyConfig: IGatsbyConfig
): ConstructConfigObjectResponse {
return {
trailingSlash: gatsbyConfig.trailingSlash ?? `always`,
pathPrefix: gatsbyConfig.pathPrefix ?? ``,
...(gatsbyConfig.assetPrefix
? { assetPrefix: gatsbyConfig.assetPrefix }
: {}),
}
}
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key