Skip to content

Commit 05e7ccd

Browse files
zaunipieh
authored andcommitted
fix(gatsby-plugin-manifest): favicon path respects hybrid mode (#8315)
1 parent 9b1a2e7 commit 05e7ccd

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

packages/gatsby-plugin-manifest/src/gatsby-node.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ exports.onPostBootstrap = (args, pluginOptions) =>
3535
// Determine destination path for icons.
3636
const iconPath = path.join(
3737
`public`,
38-
manifest.icons[0].src.substring(0, manifest.icons[0].src.lastIndexOf(`/`))
38+
path.dirname(manifest.icons[0].src)
3939
)
4040

4141
//create destination directory if it doesn't exist

packages/gatsby-plugin-manifest/src/gatsby-ssr.js

+9-1
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,19 @@ import { withPrefix } from "gatsby"
44
exports.onRenderBody = ({ setHeadComponents }, pluginOptions) => {
55
// If icons were generated, also add a favicon link.
66
if (pluginOptions.icon) {
7+
let favicon = `/icons/icon-48x48.png`
8+
9+
// The icon path could be different in hybrid mode
10+
// this takes the first one of the possible icons
11+
if (pluginOptions.icons && pluginOptions.icons.length) {
12+
favicon = pluginOptions.icons[0].src
13+
}
14+
715
setHeadComponents([
816
<link
917
key={`gatsby-plugin-manifest-icon-link`}
1018
rel="shortcut icon"
11-
href={withPrefix(`/icons/icon-48x48.png`)}
19+
href={withPrefix(favicon)}
1220
/>,
1321
])
1422
}

0 commit comments

Comments
 (0)