Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(gatsby-plugin-manifest): add icon_options as an option to support the purpose property #12794

Merged
merged 4 commits into from
Mar 27, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions packages/gatsby-plugin-manifest/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,36 @@ module.exports = {
}
```

## Custom icon options

In order to specify manifest options merged with each item of the `icons` array, `icon_options` may be used as follows:

```js
// in gatsby-config.js
module.exports = {
plugins: [
{
resolve: `gatsby-plugin-manifest`,
options: {
name: `GatsbyJS`,
short_name: `GatsbyJS`,
start_url: `/`,
background_color: `#f7f0eb`,
theme_color: `#a2466c`,
display: `standalone`,
icon: `src/images/icon.png`, // This path is relative to the root of the site.
icon_options: {
sidharthachatterjee marked this conversation as resolved.
Show resolved Hide resolved
// For all the options available, please see:
// https://developer.mozilla.org/en-US/docs/Web/Manifest
wardpeet marked this conversation as resolved.
Show resolved Hide resolved
// https://w3c.github.io/manifest/#purpose-member
purpose: `maskable`,
},
},
},
],
}
```

## Legacy option

iOS 11.3 added support for service workers but not the complete webmanifest spec. Therefore iOS won't recognize the icons defined in the webmanifest and the creation of `apple-touch-icon` links in `<head>` is needed. This plugin creates them by default. If you don't want those icons to be generated you can set the `legacy` option to `false` in plugin configuration:
Expand Down
5 changes: 5 additions & 0 deletions packages/gatsby-plugin-manifest/src/gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ exports.onPostBootstrap = async (args, pluginOptions) => {
manifest.icons = defaultIcons
}

// Specify extra options for each icon (if requested).
manifest.icons.forEach(icon => {
sidharthachatterjee marked this conversation as resolved.
Show resolved Hide resolved
Object.assign(icon, pluginOptions.icon_options)
})

// Determine destination path for icons.
const iconPath = path.join(`public`, path.dirname(manifest.icons[0].src))

Expand Down