Skip to content

Commit 1fe3f9a

Browse files
ascorbicgatsbybot
and
gatsbybot
authored
feat(gatsby-plugin-manifest): Add support for share_target (#28457)
Co-authored-by: gatsbybot <[email protected]>
1 parent 9a77810 commit 1fe3f9a

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

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

+43
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,46 @@ export default function pluginOptionSchema({ Joi }) {
113113
})
114114
.or(`url`, `id`)
115115

116+
/**
117+
* This only includes items in the draft, but allows unknown keys in params
118+
* @see https://w3c.github.io/web-share-target/
119+
*/
120+
const ShareTarget = Joi.object().keys({
121+
action: Joi.string()
122+
.uri({ allowRelative: true })
123+
.required()
124+
.description(`The URL for the web share target.`),
125+
method: Joi.string()
126+
.optional()
127+
.description(`The HTTP request method for the web share target`),
128+
enctype: Joi.string()
129+
.optional()
130+
.description(
131+
`Specifies how the share data is encoded in the body of a POST request. It is ignored when method is "GET"`
132+
),
133+
params: Joi.object()
134+
.required()
135+
.keys({
136+
title: Joi.string()
137+
.optional()
138+
.description(
139+
`The name of the query parameter used for the title of the document being shared`
140+
),
141+
text: Joi.string()
142+
.optional()
143+
.description(
144+
`The name of the query parameter used for the arbitrary text that forms the body of the message being shared`
145+
),
146+
url: Joi.string()
147+
.optional()
148+
.description(
149+
`The name of the query parameter used for the URL string referring to a resource being shared`
150+
),
151+
})
152+
// Allow unknown keys, because the spec is an unofficial draft and Google already seems to have added support for keys that are not in the spec
153+
.unknown(true),
154+
})
155+
116156
const WebAppManifest = Joi.object().keys({
117157
background_color: Joi.string()
118158
.optional()
@@ -190,6 +230,9 @@ export default function pluginOptionSchema({ Joi }) {
190230
.description(
191231
`The related_applications field is an array of objects specifying native applications that are installable by, or accessible to, the underlying platform.`
192232
),
233+
share_target: ShareTarget.optional().description(
234+
`Allows websites to declare themselves as web share targets, which can receive shared content from either the Web Share API, or system events (e.g., shares from native apps).`
235+
),
193236
scope: Joi.string()
194237
.optional()
195238
.description(

0 commit comments

Comments
 (0)