@@ -2,16 +2,218 @@ import React from "react"
22import { withPrefix } from "gatsby-link"
33
44exports . onRenderBody = ( { setHeadComponents } , pluginOptions ) => {
5- setHeadComponents ( [
6- < link
7- key = { `gatsby-plugin-manifest-link` }
8- rel = "manifest"
9- href = { withPrefix ( `/manifest.json` ) }
10- /> ,
11- < meta
12- key = { `gatsby-plugin-manifest-meta` }
13- name = "theme-color"
14- content = { pluginOptions . theme_color }
15- /> ,
16- ] )
17- }
5+ var { injectHTML = true ,
6+ icons : {
7+ android = true ,
8+ appleIcon = true ,
9+ appleStartup = true ,
10+ coast = true ,
11+ favicons = true ,
12+ firefox = true ,
13+ twitter = true ,
14+ yandex = true ,
15+ windows = true ,
16+ } = { }
17+ } = pluginOptions
18+
19+ if ( injectHTML ) {
20+ const HeadComponents = [ ]
21+
22+ if ( android ) {
23+ HeadComponents . push (
24+ < link
25+ key = { `gatsby-plugin-manifest-link` }
26+ rel = "manifest"
27+ href = { withPrefix ( `/favicons/manifest.json` ) }
28+ /> ,
29+ < meta
30+ key = { `gatsby-plugin-manifest-meta` }
31+ name = "theme-color"
32+ content = { pluginOptions . theme_color }
33+ />
34+ )
35+ }
36+
37+ if ( appleIcon ) {
38+ HeadComponents . push (
39+ < link
40+ rel = "apple-touch-icon"
41+ sizes = "57x57"
42+ href = { withPrefix ( `/favicons/apple-touch-icon-57x57.png` ) }
43+ key = { `apple-touch-icon-57x57` }
44+ /> ,
45+ < link
46+ rel = "apple-touch-icon"
47+ sizes = "60x60"
48+ href = { withPrefix ( `/favicons/apple-touch-icon-60x60.png` ) }
49+ key = { `apple-touch-icon-60x60` }
50+ /> ,
51+ < link
52+ rel = "apple-touch-icon"
53+ sizes = "72x72"
54+ href = { withPrefix ( `/favicons/apple-touch-icon-72x72.png` ) }
55+ key = { `apple-touch-icon-72x72` }
56+ /> ,
57+ < link
58+ rel = "apple-touch-icon"
59+ sizes = "76x76"
60+ href = { withPrefix ( `/favicons/apple-touch-icon-76x76.png` ) }
61+ key = { `apple-touch-icon-76x76` }
62+ /> ,
63+ < link
64+ rel = "apple-touch-icon"
65+ sizes = "114x114"
66+ href = { withPrefix ( `/favicons/apple-touch-icon-114x114.png` ) }
67+ key = { `apple-touch-icon-114x114` }
68+ /> ,
69+ < link
70+ rel = "apple-touch-icon"
71+ sizes = "120x120"
72+ href = { withPrefix ( `/favicons/apple-touch-icon-120x120.png` ) }
73+ key = { `apple-touch-icon-120x120` }
74+ /> ,
75+ < link
76+ rel = "apple-touch-icon"
77+ sizes = "144x144"
78+ href = { withPrefix ( `/favicons/apple-touch-icon-144x144.png` ) }
79+ key = { `apple-touch-icon-144x144` }
80+ /> ,
81+ < link
82+ rel = "apple-touch-icon"
83+ sizes = "152x152"
84+ href = { withPrefix ( `/favicons/apple-touch-icon-152x152.png` ) }
85+ key = { `apple-touch-icon-152x152` }
86+ /> ,
87+ < link
88+ rel = "apple-touch-icon"
89+ sizes = "180x180"
90+ href = { withPrefix ( `/favicons/apple-touch-icon-180x180.png` ) }
91+ key = { `apple-touch-icon-180x180` }
92+ />
93+ )
94+ }
95+ if ( appleStartup ) {
96+ HeadComponents . push (
97+ < link
98+ rel = "apple-touch-startup-image"
99+ media = "(device-width: 320px) and (device-height: 480px) and (-webkit-device-pixel-ratio: 1)"
100+ href = { withPrefix ( `/favicons/apple-touch-startup-image-320x460.png` ) }
101+ key = { `apple-touch-startup-image-320x460` }
102+ /> ,
103+ < link
104+ rel = "apple-touch-startup-image"
105+ media = "(device-width: 320px) and (device-height: 480px) and (-webkit-device-pixel-ratio: 2)"
106+ href = { withPrefix ( `/favicons/apple-touch-startup-image-640x920.png` ) }
107+ key = { `apple-touch-startup-image-640x920` }
108+ /> ,
109+ < link
110+ rel = "apple-touch-startup-image"
111+ media = "(device-width: 320px) and (device-height: 568px) and (-webkit-device-pixel-ratio: 2)"
112+ href = { withPrefix ( `/favicons/apple-touch-startup-image-640x1096.png` ) }
113+ key = { `apple-touch-startup-image-640x1096` }
114+ /> ,
115+ < link
116+ rel = "apple-touch-startup-image"
117+ media = "(device-width: 375px) and (device-height: 667px) and (-webkit-device-pixel-ratio: 2)"
118+ href = { withPrefix ( `/favicons/apple-touch-startup-image-750x1294.png` ) }
119+ key = { `apple-touch-startup-image-750x1294` }
120+ /> ,
121+ < link
122+ rel = "apple-touch-startup-image"
123+ media = "(device-width: 414px) and (device-height: 736px) and (orientation: landscape) and (-webkit-device-pixel-ratio: 3)"
124+ href = { withPrefix ( `/favicons/apple-touch-startup-image-1182x2208.png` ) }
125+ key = { `apple-touch-startup-image-1182x2208` }
126+ /> ,
127+ < link
128+ rel = "apple-touch-startup-image"
129+ media = "(device-width: 414px) and (device-height: 736px) and (orientation: portrait) and (-webkit-device-pixel-ratio: 3)"
130+ href = { withPrefix ( `/favicons/apple-touch-startup-image-1242x2148.png` ) }
131+ key = { `apple-touch-startup-image-1242x2148` }
132+ /> ,
133+ < link
134+ rel = "apple-touch-startup-image"
135+ media = "(device-width: 768px) and (device-height: 1024px) and (orientation: landscape) and (-webkit-device-pixel-ratio: 1)"
136+ href = { withPrefix ( `/favicons/apple-touch-startup-image-748x1024.png` ) }
137+ key = { `apple-touch-startup-image-748x1024` }
138+ /> ,
139+ < link
140+ rel = "apple-touch-startup-image"
141+ media = "(device-width: 768px) and (device-height: 1024px) and (orientation: portrait) and (-webkit-device-pixel-ratio: 1)"
142+ href = { withPrefix ( `/favicons/apple-touch-startup-image-768x1004.png` ) }
143+ key = { `apple-touch-startup-image-768x1004` }
144+ /> ,
145+ < link
146+ rel = "apple-touch-startup-image"
147+ media = "(device-width: 768px) and (device-height: 1024px) and (orientation: landscape) and (-webkit-device-pixel-ratio: 2)"
148+ href = { withPrefix ( `/favicons/apple-touch-startup-image-1496x2048.png` ) }
149+ key = { `apple-touch-startup-image-1496x2048` }
150+ /> ,
151+ < link
152+ rel = "apple-touch-startup-image"
153+ media = "(device-width: 768px) and (device-height: 1024px) and (orientation: portrait) and (-webkit-device-pixel-ratio: 2)"
154+ href = { withPrefix ( `/favicons/apple-touch-startup-image-1536x2008.png` ) }
155+ key = { `apple-touch-startup-image-1536x2008` }
156+ />
157+ )
158+ }
159+ if ( favicons ) {
160+ HeadComponents . push (
161+ < link
162+ rel = "icon"
163+ type = "image/png"
164+ sizes = "32x32"
165+ href = { withPrefix ( `/favicons/favicon-32x32.png` ) }
166+ key = { `favicon-32x32` }
167+ /> ,
168+ < link
169+ rel = "icon"
170+ type = "image/png"
171+ sizes = "16x16"
172+ href = { withPrefix ( `/favicons/favicon-16x16.png` ) }
173+ key = { `favicon-16x16` }
174+ /> ,
175+ < link
176+ rel = "shortcut icon"
177+ href = { withPrefix ( `/favicons/favicon.ico` ) }
178+ key = { `favicon` }
179+ />
180+ )
181+ }
182+ if ( coast ) {
183+ HeadComponents . push (
184+ < link
185+ rel = "icon"
186+ type = "image/png"
187+ sizes = "228x228"
188+ href = { withPrefix ( `/favicons/coast-228x228.png` ) }
189+ key = { `coast-228x228` }
190+ />
191+ )
192+ }
193+ if ( windows ) {
194+ HeadComponents . push (
195+ < meta
196+ name = "msapplication-TileImage"
197+ content = { withPrefix ( `/favicons/mstile-144x144.png` ) }
198+ key = { `mstile-144x144` }
199+ /> ,
200+ < meta
201+ name = "msapplication-config"
202+ content = { withPrefix ( `/favicons/browserconfig.xml` ) }
203+ key = { `browserconfig-xml` }
204+ />
205+ )
206+ }
207+ if ( yandex ) {
208+ HeadComponents . push (
209+ < link
210+ rel = "yandex-tableau-widget"
211+ href = { withPrefix ( `/favicons/yandex-browser-manifest.json` ) }
212+ key = { `yandex-manifest` }
213+ />
214+ )
215+ }
216+
217+ setHeadComponents ( HeadComponents )
218+ }
219+ }
0 commit comments