Skip to content

Commit

Permalink
fix(gatsby-plugin-manifest): favicon path respects hybrid mode (#8315)
Browse files Browse the repository at this point in the history
  • Loading branch information
zauni authored and pieh committed Sep 24, 2018
1 parent 9b1a2e7 commit 05e7ccd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/gatsby-plugin-manifest/src/gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ exports.onPostBootstrap = (args, pluginOptions) =>
// Determine destination path for icons.
const iconPath = path.join(
`public`,
manifest.icons[0].src.substring(0, manifest.icons[0].src.lastIndexOf(`/`))
path.dirname(manifest.icons[0].src)
)

//create destination directory if it doesn't exist
Expand Down
10 changes: 9 additions & 1 deletion packages/gatsby-plugin-manifest/src/gatsby-ssr.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,19 @@ import { withPrefix } from "gatsby"
exports.onRenderBody = ({ setHeadComponents }, pluginOptions) => {
// If icons were generated, also add a favicon link.
if (pluginOptions.icon) {
let favicon = `/icons/icon-48x48.png`

// The icon path could be different in hybrid mode
// this takes the first one of the possible icons
if (pluginOptions.icons && pluginOptions.icons.length) {
favicon = pluginOptions.icons[0].src
}

setHeadComponents([
<link
key={`gatsby-plugin-manifest-icon-link`}
rel="shortcut icon"
href={withPrefix(`/icons/icon-48x48.png`)}
href={withPrefix(favicon)}
/>,
])
}
Expand Down

0 comments on commit 05e7ccd

Please sign in to comment.