Skip to content

Commit

Permalink
chore(gatsby-plugin-manifest): add pluginOptionsSchema (gatsbyjs#27421)
Browse files Browse the repository at this point in the history
* chore(gatsby-plugin-manifest): add pluginOptionsSchema

* Add documentation for localize option
  • Loading branch information
mxstbr authored Oct 16, 2020
1 parent 1496bf1 commit 6ba5d63
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions packages/gatsby-plugin-manifest/src/gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,49 @@ async function checkCache(cache, icon, srcIcon, srcIconDigest, callback) {
}
}

if (process.env.GATSBY_EXPERIMENTAL_PLUGIN_OPTION_VALIDATION) {
exports.pluginOptionsSchema = ({ Joi }) => {
Joi.object({
name: Joi.string(),
short_name: Joi.string(),
description: Joi.string(),
lang: Joi.string(),
localize: Joi.array().items(
Joi.object({
start_url: Joi.string(),
name: Joi.string(),
short_name: Joi.string(),
description: Joi.string(),
lang: Joi.string(),
})
),
start_url: Joi.string(),
background_color: Joi.string(),
theme_color: Joi.string(),
display: Joi.string(),
legacy: Joi.boolean(),
include_favicon: Joi.boolean(),
icon: Joi.string(),
theme_color_in_head: Joi.boolean(),
crossOrigin: Joi.string().valid(`use-credentials`, `anonymous`),
cache_busting_mode: Joi.string().valid(`query`, `name`, `none`),
icons: Joi.array().items(
Joi.object({
src: Joi.string(),
sizes: Joi.string(),
type: Joi.string(),
})
),
icon_options: Joi.object({
purpose: Joi.string(),
}),
})
}
}

/**
* Setup pluginOption defaults
* TODO: Remove once pluginOptionsSchema is stable
*/
exports.onPreInit = (_, pluginOptions) => {
pluginOptions.cache_busting_mode = pluginOptions.cache_busting_mode ?? `query`
Expand Down

0 comments on commit 6ba5d63

Please sign in to comment.