@escape-game-over/atlas 0.1.85 → 0.1.86

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -521,6 +521,12 @@ is what every embed needs and has no taste in:
521
521
  - **Focus moves to the player.** The button that had it has just left the page,
522
522
  which would drop a keyboard reader back at the top of the document.
523
523
 
524
+ Two choices stay with the project. `rel` lets the player suggest videos from
525
+ other channels, and is off by default, so `rel=0` keeps the suggestions to the
526
+ channel's own; YouTube has no setting that removes them altogether. `playsInline`
527
+ keeps the video in the page on an iPhone rather than going full screen on the
528
+ press.
529
+
524
530
  `frame` is called after all of that and before the iframe is in the page, so its
525
531
  word is the last one and nothing is drawn unstyled first.
526
532
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@escape-game-over/atlas",
3
- "version": "0.1.85",
3
+ "version": "0.1.86",
4
4
  "type": "module",
5
5
  "description": "Typed, data-driven machinery for static multi-locale, multi-deployment Astro sites.",
6
6
  "private": false,
@@ -55,6 +55,19 @@ export interface YouTubeEmbedOptions {
55
55
  * player has no way to tell which video it is.
56
56
  */
57
57
  readonly title: string;
58
+ /**
59
+ * Whether the player may suggest videos from other channels. Off unless
60
+ * asked for: with `rel=0` it suggests only the channel's own, so a trailer
61
+ * on a project's page does not end on someone else's video.
62
+ *
63
+ * YouTube has no setting that removes the suggestions altogether.
64
+ */
65
+ readonly rel?: boolean;
66
+ /**
67
+ * Whether an iPhone plays the video in the page rather than taking it
68
+ * full screen on the press.
69
+ */
70
+ readonly playsInline?: boolean;
58
71
  /**
59
72
  * Anything the project wants on the iframe — classes, above all.
60
73
  *
@@ -106,7 +119,7 @@ const ALLOW =
106
119
  "accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share";
107
120
 
108
121
  export function youtubeEmbed(options: YouTubeEmbedOptions): YouTubeEmbed {
109
- const { id, title, frame } = options;
122
+ const { id, title, rel = false, playsInline = false, frame } = options;
110
123
 
111
124
  if (!VIDEO_ID.test(id)) {
112
125
  throw new Error(
@@ -122,7 +135,10 @@ export function youtubeEmbed(options: YouTubeEmbedOptions): YouTubeEmbed {
122
135
  // `youtube-nocookie.com` rather than `youtube.com`: the same player, which
123
136
  // sets no cookie until the video is played — and here it is only ever
124
137
  // loaded to be played, so nothing is lost by it.
125
- const src = `https://www.youtube-nocookie.com/embed/${id}?autoplay=1`;
138
+ const url = new URL(`https://www.youtube-nocookie.com/embed/${id}`);
139
+ url.searchParams.set("autoplay", "1");
140
+ url.searchParams.set("rel", rel ? "1" : "0");
141
+ if (playsInline) url.searchParams.set("playsinline", "1");
126
142
 
127
143
  return {
128
144
  attach(trigger, container) {
@@ -133,7 +149,7 @@ export function youtubeEmbed(options: YouTubeEmbedOptions): YouTubeEmbed {
133
149
  () => {
134
150
  const iframe =
135
151
  container.ownerDocument.createElement("iframe");
136
- iframe.src = src;
152
+ iframe.src = url.href;
137
153
  iframe.title = title;
138
154
  iframe.allow = ALLOW;
139
155
  iframe.allowFullscreen = true;