@gusnips/vite 0.4.3 → 0.4.4

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.
package/README.md CHANGED
@@ -41,12 +41,14 @@ const html = bakeHead(template, {
41
41
 
42
42
  Four rules in there are load-bearing:
43
43
 
44
- - **`canonical: null` strips the tag, and takes `og:image` and `og:url` with it.** For the 404
45
- shell, which is served for every address that does not exist. Blanking is not stripping: an
46
- empty canonical is a claim about `""`, and an empty `og:url` is a card pointing at your front
47
- page. The image is the half people miss — one codebase set it before it branched on the shell,
48
- so its `404.html` advertised a card at `/og/__not-found__.png`, a file that has never existed.
49
- Every share of a dead link unfurled broken, and nothing in a browser showed it.
44
+ - **`canonical: null` strips the tag, and `og:url` with it.** For the 404 shell, which is served
45
+ for every address that does not exist. Blanking is not stripping: an empty canonical is a claim
46
+ about `""`, and an empty `og:url` is a card pointing at your front page. **Leave `image` out
47
+ there too**, and the shell keeps the card your template already has. The image is the half
48
+ people miss, and `bakeHead` cannot catch it for you — it writes whatever card you name. Three
49
+ codebases named the shell's card after its made-up path, so their `404.html` advertised
50
+ `/og/__not-found__.png`, a file that has never existed. Every share of a dead link unfurled
51
+ broken, and nothing in a browser showed it.
50
52
  - **`og:locale` is not optional on a non-English page.** Leave it out and the spec does not
51
53
  default it to "unknown" — it defaults to `en_US`. A Portuguese page with a Portuguese
52
54
  `og:title` then tells every share crawler the card is English. `ogLocale("pt-BR")` gives you
@@ -1 +1 @@
1
- {"version":3,"file":"head.d.ts","sourceRoot":"","sources":["../src/head.ts"],"names":[],"mappings":"AAiBA,4FAA4F;AAC5F,eAAO,MAAM,UAAU,4BAA0B,CAAC;AA+BlD,uFAAuF;AACvF,MAAM,WAAW,SAAS;IACxB;yBACqB;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,QAAQ;IACvB,wDAAwD;IACxD,KAAK,EAAE,MAAM,CAAC;I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eta(html, selector, value) {
32
32
  /**
33
33
  * The same, for a tag a template is allowed not to carry.
34
34
  *
35
- * Only the `twitter:` pair and `name="title"` get this. X reads the `og:` tags when the
36
- * `twitter:` ones are absent, and no crawler reads `name="title"` at all — so a template that
37
- * omits them is correct, and demanding them would break an app that never had them. A template
38
- * that DOES carry one and gets a stale value is still a bug, which is why they are written
39
- * rather than ignored. Everything a crawler actually depends on goes through `setMeta`.
35
+ * Only the `twitter:` tags, `og:image:alt` and `name="title"` get this. X reads the `og:` tags when
36
+ * the `twitter:` ones are absent, no crawler reads `name="title"` at all, and most templates carry
37
+ * no image alt — so a template that omits them is correct, and demanding them would break an app
38
+ * that never had them. A template that DOES carry one and gets a stale value is still a bug, which
39
+ * is why they are written rather than ignored. Everything a crawler actually depends on goes
40
+ * through `setMeta`.
40
41
  */
41
42
  function setMetaIfPresent(html, selector, value) {
42
43
  const re = metaRe(selector);
@@ -76,6 +77,10 @@ export function bakeHead(template, tags) {
76
77
  if (tags.image !== undefined) {
77
78
  html = setMeta(html, 'property="og:image"', tags.image);
78
79
  html = setMetaIfPresent(html, 'property="twitter:image"', tags.image);
80
+ // A card's description goes with the card. Left alone, every page's own card was described
81
+ // with the front page's title — the stale value this function exists to prevent, on the one
82
+ // tag written for somebody who cannot see the picture.
83
+ html = setMetaIfPresent(html, 'property="og:image:alt"', shareTitle);
79
84
  }
80
85
  if (tags.canonical === null) {
81
86
  // Strip rather than blank: an empty canonical is a claim about "" and an empty og:url is a
package/dist/head.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"head.js","sourceRoot":"","sources":["../src/head.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,yFAAyF;AACzF,8FAA8F;AAC9F,yDAAyD;AACzD,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AACjE,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAEtD,4FAA4F;AAC5F,MAAM,CAAC,MAAM,UA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AAI,CAAC,IAAI,CAAC;QAAE,IAAI,CAAC,gCAAgC,CAAC,CAAC;IAClE,IAAI,sBAAsB,CAAC,IAAI,CAAC,IAAI,CAAC;QACnC,IAAI,CAAC,oFAAoF,CAAC,CAAC;AAC/F,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gusnips/vite",
3
- "version": "0.4.3",
3
+ "version": "0.4.4",
4
4
  "description": "The build-time half of a prerendered Vite SPA: head baking, sitemap, robots, the prerender driver, and a shared vite preset.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -59,7 +59,7 @@
59
59
  "release:major": "bun pm version major && bun publish --access public"
60
60
  },
61
61
  "dependencies": {
62
- "@gusnips/react": "0.4.3"
62
+ "@gusnips/react": "0.4.4"
63
63
  },
64
64
  "peerDependencies": {
65
65
  "@tailwindcss/vite": "^4",
package/src/head.test.ts CHANGED
@@ -119,6 +119,18 @@ describe("bakeHead", () => {
119
119
  expect(html).toContain('<meta property="og:image" content="https://acme.com/og.png" />');
120
120
  });
121
121
 
122
+ // Left alone, every page's card was described as the front page's card.
123
+ it("describes the page's own card, and leaves the brand card's description with it", () => {
124
+ const withAlt = TEMPLATE.replace(
125
+ "</head>",
126
+ ' <meta property="og:image:alt" content="front" />\n </head>',
127
+ );
128
+ const page = bakeHead(withAlt, { ...BASE, image: "https://acme.com/og/pricing.png" });
129
+ expect(page).toContain('<meta property="og:image:alt" content="T" />');
130
+ const shell = bakeHead(withAlt, { ...BASE, canonical: null });
131
+ expect(shell).toContain('<meta property="og:image:alt" content="front" />');
132
+ });
133
+
122
134
  it("lists every alternate, reciprocally, including this page's own", () => {
123
135
  const html = bakeHead(TEMPLATE, {
124
136
  ...BASE,
package/src/head.ts CHANGED
@@ -36,11 +36,12 @@ function setMeta(html: string, selector: string, value: string): string {
36
36
  /**
37
37
  * The same, for a tag a template is allowed not to carry.
38
38
  *
39
- * Only the `twitter:` pair and `name="title"` get this. X reads the `og:` tags when the
40
- * `twitter:` ones are absent, and no crawler reads `name="title"` at all — so a template that
41
- * omits them is correct, and demanding them would break an app that never had them. A template
42
- * that DOES carry one and gets a stale value is still a bug, which is why they are written
43
- * rather than ignored. Everything a crawler actually depends on goes through `setMeta`.
39
+ * Only the `twitter:` tags, `og:image:alt` and `name="title"` get this. X reads the `og:` tags when
40
+ * the `twitter:` ones are absent, no crawler reads `name="title"` at all, and most templates carry
41
+ * no image alt — so a template that omits them is correct, and demanding them would break an app
42
+ * that never had them. A template that DOES carry one and gets a stale value is still a bug, which
43
+ * is why they are written rather than ignored. Everything a crawler actually depends on goes
44
+ * through `setMeta`.
44
45
  */
45
46
  function setMetaIfPresent(html: string, selector: string, value: string): string {
46
47
  const re = metaRe(selector);
@@ -148,6 +149,10 @@ export function bakeHead(template: string, tags: HeadTags): string {
148
149
  if (tags.image !== undefined) {
149
150
  html = setMeta(html, 'property="og:image"', tags.image);
150
151
  html = setMetaIfPresent(html, 'property="twitter:image"', tags.image);
152
+ // A card's description goes with the card. Left alone, every page's own card was described
153
+ // with the front page's title — the stale value this function exists to prevent, on the one
154
+ // tag written for somebody who cannot see the picture.
155
+ html = setMetaIfPresent(html, 'property="og:image:alt"', shareTitle);
151
156
  }
152
157
 
153
158
  if (tags.canonical === null) {