@escape-game-over/atlas 0.1.95 → 0.1.96
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/docs/rich-text.md +1 -1
- package/package.json +1 -1
- package/src/astro/Phone.astro +2 -2
- package/src/astro/RichText.astro +1 -1
- package/src/jsonld/business.ts +11 -2
- package/src/jsonld/ids.ts +17 -5
package/docs/rich-text.md
CHANGED
|
@@ -253,7 +253,7 @@ per `[v:name]` and one for links — usually in a small wrapper
|
|
|
253
253
|
```
|
|
254
254
|
|
|
255
255
|
A `[tel]` link renders with `dir="ltr"`: a number has no letters to set its
|
|
256
|
-
direction, and on a right-to-left page it would otherwise read "
|
|
256
|
+
direction, and on a right-to-left page it would otherwise read "0100 555 202 1+".
|
|
257
257
|
A number on its own, outside copy, is `@escape-game-over/atlas/astro/phone`.
|
|
258
258
|
|
|
259
259
|
`attrs` puts attributes on a variant's run, so a script can find it and rewrite
|
package/package.json
CHANGED
package/src/astro/Phone.astro
CHANGED
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
* <a href={telHref(phone)}><Phone phone={phone} /></a>
|
|
7
7
|
* ```
|
|
8
8
|
*
|
|
9
|
-
* "+
|
|
10
|
-
* the browser would lay it out right to left and show "
|
|
9
|
+
* "+1 202 555 0100" has no letters to set its direction, so on an Arabic page
|
|
10
|
+
* the browser would lay it out right to left and show "0100 555 202 1+". Its own
|
|
11
11
|
* element with `dir="ltr"` keeps it whole, the way the page expects a number
|
|
12
12
|
* to read, and copies as just the number. An email needs none of this: its
|
|
13
13
|
* letters already make it read left to right.
|
package/src/astro/RichText.astro
CHANGED
|
@@ -82,7 +82,7 @@ const variantAttrs = (variant: string) =>
|
|
|
82
82
|
</a>
|
|
83
83
|
);
|
|
84
84
|
// A number has no letters to set its direction; on a right-to-left
|
|
85
|
-
// page it would read "
|
|
85
|
+
// page it would read "0100 555 202 1+". See `Phone.astro`.
|
|
86
86
|
case "tel":
|
|
87
87
|
return (
|
|
88
88
|
<a
|
package/src/jsonld/business.ts
CHANGED
|
@@ -15,8 +15,17 @@ import { geoCoordinates, openingHours, postalAddress } from "./place.ts";
|
|
|
15
15
|
|
|
16
16
|
export interface LocalBusinessInput {
|
|
17
17
|
readonly name: string;
|
|
18
|
-
/**
|
|
18
|
+
/**
|
|
19
|
+
* The page about it: the site, or one location's page on a site with
|
|
20
|
+
* several. Its origin carries the node's identity, see `@id` below.
|
|
21
|
+
*/
|
|
19
22
|
readonly url: HttpsUrl;
|
|
23
|
+
/**
|
|
24
|
+
* Which of the site's businesses this is, on a site with several: `north`
|
|
25
|
+
* makes the `@id` `<origin>#business-north`. Point at it with
|
|
26
|
+
* `businessId(url, location)`.
|
|
27
|
+
*/
|
|
28
|
+
readonly location?: string;
|
|
20
29
|
readonly address: PostalAddress;
|
|
21
30
|
/**
|
|
22
31
|
* Another name this venue actually goes by.
|
|
@@ -162,7 +171,7 @@ export interface LocalBusinessInput {
|
|
|
162
171
|
export function localBusiness(business: LocalBusinessInput): JsonLdNode {
|
|
163
172
|
return {
|
|
164
173
|
"@type": schemaType(business.type ?? "LocalBusiness"),
|
|
165
|
-
"@id": businessId(business.url),
|
|
174
|
+
"@id": businessId(business.url, business.location),
|
|
166
175
|
name: business.name,
|
|
167
176
|
...alternateName(business.name, business.alternateName),
|
|
168
177
|
url: business.url,
|
package/src/jsonld/ids.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type HttpsUrl, normalizeOrigin } from "../url.ts";
|
|
1
|
+
import { type HttpsUrl, isHttpsUrl, normalizeOrigin } from "../url.ts";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* The `@id` each addressable node takes, and the types that keep them apart.
|
|
@@ -43,7 +43,9 @@ import { type HttpsUrl, normalizeOrigin } from "../url.ts";
|
|
|
43
43
|
* -checks, while the mistake this exists to stop — passing a bare URL where a
|
|
44
44
|
* reference belongs — does not.
|
|
45
45
|
*/
|
|
46
|
-
export type BusinessId =
|
|
46
|
+
export type BusinessId =
|
|
47
|
+
| `${HttpsUrl}#business`
|
|
48
|
+
| `${HttpsUrl}#business-${string}`;
|
|
47
49
|
|
|
48
50
|
/** The identity of a brand node. See `BusinessId`. */
|
|
49
51
|
export type OrganizationId = `${HttpsUrl}#organization`;
|
|
@@ -68,15 +70,25 @@ export type WebsiteId = `${HttpsUrl}#website`;
|
|
|
68
70
|
export type ServiceId = `${HttpsUrl}#service`;
|
|
69
71
|
|
|
70
72
|
/**
|
|
71
|
-
* The `@id` a business node takes
|
|
73
|
+
* The `@id` a business node takes: on the origin of `url`, whichever page of
|
|
74
|
+
* the site that is.
|
|
72
75
|
*
|
|
73
76
|
* Exported because a reference has to be built by whoever points at it, and the
|
|
74
77
|
* fragment must match exactly — a node linking to `#local-business` when the
|
|
75
78
|
* business calls itself `#business` is a dangling reference that no validator
|
|
76
79
|
* reports and no crawler resolves. One definition, used by both ends.
|
|
80
|
+
*
|
|
81
|
+
* A site with several businesses — one per location — names each:
|
|
82
|
+
* `businessId(origin, "north")` is `<origin>#business-north`.
|
|
83
|
+
* Without a name they would all be `#business`, and a crawler merges nodes
|
|
84
|
+
* that share an id, so the locations would read as one place.
|
|
77
85
|
*/
|
|
78
|
-
export function businessId(url: HttpsUrl): BusinessId {
|
|
79
|
-
|
|
86
|
+
export function businessId(url: HttpsUrl, location?: string): BusinessId {
|
|
87
|
+
const origin = new URL(url).origin;
|
|
88
|
+
if (!isHttpsUrl(origin)) throw new Error(`"${url}" has no https origin.`);
|
|
89
|
+
return location === undefined
|
|
90
|
+
? `${origin}#business`
|
|
91
|
+
: `${origin}#business-${location}`;
|
|
80
92
|
}
|
|
81
93
|
|
|
82
94
|
/** The `@id` a brand node takes. See `businessId`. */
|