@nakedcreativity/cee-ms-node 2.0.0-beta.4 → 2.0.0-beta.7
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 +106 -18
- package/lib/draft.js +8 -3
- package/lib/draft.js.map +1 -1
- package/lib/index.d.ts +23 -4
- package/lib/index.js +72 -15
- package/lib/index.js.map +1 -1
- package/lib/interfaces.d.ts +141 -14
- package/lib/interfaces.js +1 -0
- package/lib/interfaces.js.map +1 -1
- package/lib/links.d.ts +67 -2
- package/lib/links.js +201 -7
- package/lib/links.js.map +1 -1
- package/lib/social-meta.d.ts +15 -0
- package/lib/social-meta.js +73 -0
- package/lib/social-meta.js.map +1 -0
- package/lib/structured-data.d.ts +22 -7
- package/lib/structured-data.js +283 -53
- package/lib/structured-data.js.map +1 -1
- package/lib/tags/blog.d.ts +3 -2
- package/lib/tags/blog.js +14 -5
- package/lib/tags/blog.js.map +1 -1
- package/lib/tags/index.d.ts +1 -0
- package/lib/tags/index.js +1 -0
- package/lib/tags/index.js.map +1 -1
- package/lib/tags/social-meta.d.ts +6 -0
- package/lib/tags/social-meta.js +19 -0
- package/lib/tags/social-meta.js.map +1 -0
- package/lib/tags/structured-data.d.ts +4 -3
- package/lib/tags/structured-data.js +6 -5
- package/lib/tags/structured-data.js.map +1 -1
- package/package.json +8 -1
package/lib/interfaces.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import type express from 'express';
|
|
|
3
3
|
import type { Context, FilterImplOptions } from 'liquidjs';
|
|
4
4
|
export declare enum CacheSource {
|
|
5
5
|
Local = 0,
|
|
6
|
+
/** The bucket, read with the host's own AWS credentials (`cacheBucket`, `cacheRegion`). */
|
|
6
7
|
S3 = 1
|
|
7
8
|
}
|
|
8
9
|
export interface CeemsConfig {
|
|
@@ -18,9 +19,11 @@ export interface CeemsConfig {
|
|
|
18
19
|
cacheRegion?: string;
|
|
19
20
|
cacheFolder?: string;
|
|
20
21
|
/**
|
|
21
|
-
*
|
|
22
|
-
*
|
|
22
|
+
* The environment this renderer serves: published files are read from `<environment>/` in the bucket or
|
|
23
|
+
* folder. Defaults to the `CEEMS_ENVIRONMENT` environment variable, then `development`.
|
|
23
24
|
*/
|
|
25
|
+
environment?: string;
|
|
26
|
+
/** Where published files are read from in the bucket or folder: `<environment>/` unless set. */
|
|
24
27
|
cachePrefix?: string;
|
|
25
28
|
whitelistedCookies?: Array<string>;
|
|
26
29
|
tags?: Array<LiquidTag>;
|
|
@@ -76,6 +79,83 @@ export interface CeemsSite {
|
|
|
76
79
|
*/
|
|
77
80
|
settings?: Record<string, any>;
|
|
78
81
|
collections?: any;
|
|
82
|
+
/**
|
|
83
|
+
* Every published page by id (absent for sites last published before it): page links read their address from here when the page
|
|
84
|
+
* renders, so a renamed or moved page is right everywhere once it is published. A link to a page that
|
|
85
|
+
* isn't here is broken.
|
|
86
|
+
*/
|
|
87
|
+
pageIndex?: Record<string, CeemsPageIndexEntry>;
|
|
88
|
+
/** The documents published content uses, by id, read by document links and values as the page renders. */
|
|
89
|
+
documents?: Record<string, CeemsPublishedDocument>;
|
|
90
|
+
/** The site's People by row id, for bylines, profile pages and row fields. */
|
|
91
|
+
people?: Record<string, CeemsPerson>;
|
|
92
|
+
}
|
|
93
|
+
/** A person from the site's People, in `site.json` `people`. Sites may add columns of their own. */
|
|
94
|
+
export interface CeemsPerson {
|
|
95
|
+
name: string;
|
|
96
|
+
jobTitle?: string;
|
|
97
|
+
photo?: CeemsImage;
|
|
98
|
+
/** Rich text. */
|
|
99
|
+
bio?: string;
|
|
100
|
+
links?: {
|
|
101
|
+
url: string;
|
|
102
|
+
}[];
|
|
103
|
+
/** `links` as addresses, for structured data. */
|
|
104
|
+
sameAs: string[];
|
|
105
|
+
email?: string;
|
|
106
|
+
telephone?: string;
|
|
107
|
+
/** Their profile page, if they have one. */
|
|
108
|
+
profile?: {
|
|
109
|
+
kind: 'page';
|
|
110
|
+
pageId: string;
|
|
111
|
+
url: string;
|
|
112
|
+
};
|
|
113
|
+
[column: string]: unknown;
|
|
114
|
+
}
|
|
115
|
+
/** A byline author, as published: a person from People, someone typed in, or the organisation. */
|
|
116
|
+
export type CeemsBylineAuthor = {
|
|
117
|
+
kind: 'person';
|
|
118
|
+
collectionId: string;
|
|
119
|
+
rowId: string;
|
|
120
|
+
} | {
|
|
121
|
+
kind: 'guest';
|
|
122
|
+
name: string;
|
|
123
|
+
url?: string;
|
|
124
|
+
jobTitle?: string;
|
|
125
|
+
} | {
|
|
126
|
+
kind: 'organisation';
|
|
127
|
+
};
|
|
128
|
+
/** A published page, in `site.json` `pageIndex`. */
|
|
129
|
+
export interface CeemsPageIndexEntry {
|
|
130
|
+
/** Its address, e.g. `/about/team`, or `/` for the home page. */
|
|
131
|
+
path: string;
|
|
132
|
+
name: string;
|
|
133
|
+
}
|
|
134
|
+
export interface CeemsDocumentInfo {
|
|
135
|
+
numpages?: number;
|
|
136
|
+
dimensions?: {
|
|
137
|
+
width: number;
|
|
138
|
+
height: number;
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
/** A library document, in `site.json` `documents`. */
|
|
142
|
+
export interface CeemsPublishedDocument {
|
|
143
|
+
url: string;
|
|
144
|
+
thumbnail?: string;
|
|
145
|
+
info?: CeemsDocumentInfo;
|
|
146
|
+
}
|
|
147
|
+
/** A published `data/<id>.json`. */
|
|
148
|
+
export interface CeemsDataFile {
|
|
149
|
+
_id: string;
|
|
150
|
+
name: string;
|
|
151
|
+
slug: string;
|
|
152
|
+
columns: any[];
|
|
153
|
+
/** Each row's values, in order: as Cee.ms 1 published them. */
|
|
154
|
+
data: Record<string, any>[];
|
|
155
|
+
/** The same rows with their ids, for row references. Absent for data last published before it. */
|
|
156
|
+
rows?: ({
|
|
157
|
+
_id: string;
|
|
158
|
+
} & Record<string, any>)[];
|
|
79
159
|
}
|
|
80
160
|
/** The published `site.json` `site`. */
|
|
81
161
|
export interface CeemsSiteInfo {
|
|
@@ -88,13 +168,26 @@ export interface CeemsSiteInfo {
|
|
|
88
168
|
defaults?: StructuredDataDefaults;
|
|
89
169
|
/** For module types holding questions and answers: where they are, by module config type. */
|
|
90
170
|
faqModules?: Record<string, FaqModuleMapping>;
|
|
171
|
+
/** For module types holding reviews, which attach to a product or event page. */
|
|
172
|
+
reviewModules?: Record<string, ReviewsModuleMapping>;
|
|
173
|
+
/** For module types featuring people: their row field to People, by module config type. */
|
|
174
|
+
peopleModules?: Record<string, {
|
|
175
|
+
field: string;
|
|
176
|
+
}>;
|
|
91
177
|
};
|
|
92
178
|
[key: string]: any;
|
|
93
179
|
}
|
|
94
|
-
/** A schema.org type the `{% structureddata %}
|
|
95
|
-
export type StructuredDataType = 'WEBSITE' | 'WEBPAGE' | 'BREADCRUMB' | 'ORGANISATION' | 'ARTICLE' | 'FAQ'
|
|
180
|
+
/** A schema.org type a page or the site's defaults can switch on for `{% structureddata %}`. */
|
|
181
|
+
export type StructuredDataType = 'WEBSITE' | 'WEBPAGE' | 'BREADCRUMB' | 'ORGANISATION' | 'ARTICLE' | 'FAQ';
|
|
182
|
+
/**
|
|
183
|
+
* What a page is about. Products, events, people and services output their own node when they have the data;
|
|
184
|
+
* `HOME` is the site's front page, which by default carries the site and organisation. Templates and modules
|
|
185
|
+
* can read it, e.g. `{% if page.entity == 'PRODUCT' %}`.
|
|
186
|
+
*/
|
|
187
|
+
export type PageEntity = 'HOME' | 'PAGE' | 'ARTICLE' | 'PRODUCT' | 'EVENT' | 'PERSON' | 'SERVICE';
|
|
96
188
|
/** The types each kind of page outputs unless it chooses its own. */
|
|
97
189
|
export interface StructuredDataDefaults {
|
|
190
|
+
home: StructuredDataType[];
|
|
98
191
|
page: StructuredDataType[];
|
|
99
192
|
blog: StructuredDataType[];
|
|
100
193
|
article: StructuredDataType[];
|
|
@@ -105,6 +198,17 @@ export interface FaqModuleMapping {
|
|
|
105
198
|
questionField: string;
|
|
106
199
|
answerField: string;
|
|
107
200
|
}
|
|
201
|
+
/** `itemsField` is a contributor field of the module; the others are fields of its items. */
|
|
202
|
+
export interface ReviewsModuleMapping {
|
|
203
|
+
itemsField: string;
|
|
204
|
+
authorField: string;
|
|
205
|
+
/** A select of numbers, or text holding one. */
|
|
206
|
+
ratingField: string;
|
|
207
|
+
bodyField?: string;
|
|
208
|
+
dateField?: string;
|
|
209
|
+
bestRating: number;
|
|
210
|
+
worstRating: number;
|
|
211
|
+
}
|
|
108
212
|
/** An image value as published. */
|
|
109
213
|
export interface CeemsImage {
|
|
110
214
|
src: string;
|
|
@@ -121,7 +225,7 @@ export interface CeemsPostalAddress {
|
|
|
121
225
|
country?: string;
|
|
122
226
|
}
|
|
123
227
|
export interface CeemsOrganisation {
|
|
124
|
-
/** The schema.org type: `Organization
|
|
228
|
+
/** The schema.org type, from Cee.ms's business types: `Organization`, or one such as `RealEstateAgent`. */
|
|
125
229
|
type: string;
|
|
126
230
|
name: string;
|
|
127
231
|
legalName?: string;
|
|
@@ -139,7 +243,13 @@ export interface CeemsOrganisation {
|
|
|
139
243
|
priceRange?: string;
|
|
140
244
|
}
|
|
141
245
|
export type CeemsAvailability = 'IN_STOCK' | 'OUT_OF_STOCK' | 'PRE_ORDER' | 'SOLD_OUT' | 'DISCONTINUED';
|
|
142
|
-
|
|
246
|
+
export interface CeemsOffer {
|
|
247
|
+
price: number;
|
|
248
|
+
currency: string;
|
|
249
|
+
url?: string;
|
|
250
|
+
availability?: CeemsAvailability;
|
|
251
|
+
}
|
|
252
|
+
/** A page's structured data choices, and the details of its entity. */
|
|
143
253
|
export interface CeemsPageStructuredData {
|
|
144
254
|
/** Absent: the site's defaults for the page's kind. */
|
|
145
255
|
types?: StructuredDataType[];
|
|
@@ -156,12 +266,7 @@ export interface CeemsPageStructuredData {
|
|
|
156
266
|
url?: string;
|
|
157
267
|
};
|
|
158
268
|
image?: CeemsImage;
|
|
159
|
-
offers?:
|
|
160
|
-
price: number;
|
|
161
|
-
currency: string;
|
|
162
|
-
url?: string;
|
|
163
|
-
availability?: CeemsAvailability;
|
|
164
|
-
};
|
|
269
|
+
offers?: CeemsOffer;
|
|
165
270
|
};
|
|
166
271
|
product?: {
|
|
167
272
|
name?: string;
|
|
@@ -169,8 +274,9 @@ export interface CeemsPageStructuredData {
|
|
|
169
274
|
brand?: string;
|
|
170
275
|
sku?: string;
|
|
171
276
|
image?: CeemsImage;
|
|
172
|
-
price
|
|
173
|
-
|
|
277
|
+
/** With `currency`; a product needs a price or reviews. */
|
|
278
|
+
price?: number;
|
|
279
|
+
currency?: string;
|
|
174
280
|
availability?: CeemsAvailability;
|
|
175
281
|
};
|
|
176
282
|
person?: {
|
|
@@ -180,6 +286,14 @@ export interface CeemsPageStructuredData {
|
|
|
180
286
|
image?: CeemsImage;
|
|
181
287
|
sameAs?: string[];
|
|
182
288
|
};
|
|
289
|
+
service?: {
|
|
290
|
+
name?: string;
|
|
291
|
+
description?: string;
|
|
292
|
+
serviceType?: string;
|
|
293
|
+
areaServed?: string;
|
|
294
|
+
image?: CeemsImage;
|
|
295
|
+
offers?: CeemsOffer;
|
|
296
|
+
};
|
|
183
297
|
}
|
|
184
298
|
export interface CeemsRequest extends express.Request {
|
|
185
299
|
page: CeemsPage;
|
|
@@ -212,12 +326,25 @@ export interface CeemsPage {
|
|
|
212
326
|
/** Social sharing image. */
|
|
213
327
|
social?: CeemsImage;
|
|
214
328
|
type?: 'blog' | 'article';
|
|
329
|
+
/** Published from Cee.ms with the default resolved: `HOME` for the home page, else `PAGE`. */
|
|
330
|
+
entity?: PageEntity;
|
|
331
|
+
/** The site's own page type, such as `property`, by key. Its `entity` is the type's base. */
|
|
332
|
+
pageType?: string;
|
|
215
333
|
tags?: string[];
|
|
216
334
|
/** An article's date. */
|
|
217
335
|
date?: string;
|
|
218
336
|
publishedAt?: string;
|
|
219
337
|
updatedAt?: string;
|
|
220
338
|
structuredData?: CeemsPageStructuredData;
|
|
339
|
+
/** An article's byline, as published. Templates read `page.authors`. */
|
|
340
|
+
byline?: {
|
|
341
|
+
authors: CeemsBylineAuthor[];
|
|
342
|
+
reviewedBy?: unknown;
|
|
343
|
+
};
|
|
344
|
+
/** For entity `PERSON`: the person whose profile page it is, as a `RowDrop` once loaded. */
|
|
345
|
+
person?: unknown;
|
|
346
|
+
/** The byline, resolved (see `bylineAuthors`): people, guests and the organisation, in order. */
|
|
347
|
+
authors?: Record<string, unknown>[];
|
|
221
348
|
[key: string]: any;
|
|
222
349
|
}
|
|
223
350
|
export interface CeemsRegion {
|
package/lib/interfaces.js
CHANGED
|
@@ -4,6 +4,7 @@ exports.CacheSource = void 0;
|
|
|
4
4
|
var CacheSource;
|
|
5
5
|
(function (CacheSource) {
|
|
6
6
|
CacheSource[CacheSource["Local"] = 0] = "Local";
|
|
7
|
+
/** The bucket, read with the host's own AWS credentials (`cacheBucket`, `cacheRegion`). */
|
|
7
8
|
CacheSource[CacheSource["S3"] = 1] = "S3";
|
|
8
9
|
})(CacheSource || (exports.CacheSource = CacheSource = {}));
|
|
9
10
|
//# sourceMappingURL=interfaces.js.map
|
package/lib/interfaces.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":";;;AAIA,IAAY,
|
|
1
|
+
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":";;;AAIA,IAAY,WAIX;AAJD,WAAY,WAAW;IACnB,+CAAK,CAAA;IACL,2FAA2F;IAC3F,yCAAE,CAAA;AACN,CAAC,EAJW,WAAW,2BAAX,WAAW,QAItB"}
|
package/lib/links.d.ts
CHANGED
|
@@ -1,9 +1,24 @@
|
|
|
1
1
|
import { Drop } from 'liquidjs';
|
|
2
|
+
import type { CeemsDataFile, CeemsDocumentInfo, CeemsPageIndexEntry, CeemsPublishedDocument, CeemsSite } from './interfaces';
|
|
3
|
+
/**
|
|
4
|
+
* What references resolve against when a page renders: the published pages and documents from `site.json`,
|
|
5
|
+
* and the rows of the data collections the page points at. Each is published once, so a renamed page or an
|
|
6
|
+
* edited row is right everywhere as soon as that one change is published. A site published before Cee.ms
|
|
7
|
+
* sent these has none of them, and links read their stored address as before.
|
|
8
|
+
*/
|
|
9
|
+
export interface LinkContext {
|
|
10
|
+
pageIndex?: Record<string, CeemsPageIndexEntry>;
|
|
11
|
+
documents?: Record<string, CeemsPublishedDocument>;
|
|
12
|
+
/** A row by collection and row id, or undefined if it isn't published (or was deleted). */
|
|
13
|
+
row?: (collectionId: string, rowId: string) => Record<string, unknown> | undefined;
|
|
14
|
+
}
|
|
2
15
|
/**
|
|
3
16
|
* A stored link value in templates. It reads as its address, so a field that held a URL string and became a
|
|
4
17
|
* link field still works where templates print it (`{{ item.url }}`), filter it (`| escape`, `| append`),
|
|
5
18
|
* compare it (`== '/about'`, `!= blank`) or measure it (`| size`); and its parts are there too
|
|
6
19
|
* (`{{ item.url.kind }}`, `.pageId`, `.anchor`). `| json` shows the whole link.
|
|
20
|
+
*
|
|
21
|
+
* A page link whose page isn't published reads as `''`, with `broken` true, so `{% if link %}` leaves it out.
|
|
7
22
|
*/
|
|
8
23
|
export declare class LinkDrop extends Drop {
|
|
9
24
|
kind: string;
|
|
@@ -12,6 +27,7 @@ export declare class LinkDrop extends Drop {
|
|
|
12
27
|
documentId?: string;
|
|
13
28
|
anchor?: string;
|
|
14
29
|
email?: string;
|
|
30
|
+
broken?: boolean;
|
|
15
31
|
constructor(link: Record<string, unknown>);
|
|
16
32
|
valueOf(): string;
|
|
17
33
|
toString(): string;
|
|
@@ -21,5 +37,54 @@ export declare class LinkDrop extends Drop {
|
|
|
21
37
|
get size(): number;
|
|
22
38
|
toJSON(): Record<string, unknown>;
|
|
23
39
|
}
|
|
24
|
-
/**
|
|
25
|
-
|
|
40
|
+
/**
|
|
41
|
+
* A document value (`{ documentId, url, thumbnail, info }`) in templates, read from the published documents
|
|
42
|
+
* so a replaced file is right everywhere. It prints as its address, so `{{ download }}` and
|
|
43
|
+
* `{{ download.url }}` both work.
|
|
44
|
+
*/
|
|
45
|
+
export declare class DocumentDrop extends Drop {
|
|
46
|
+
documentId?: string;
|
|
47
|
+
url: string;
|
|
48
|
+
thumbnail?: string;
|
|
49
|
+
info?: CeemsDocumentInfo;
|
|
50
|
+
constructor(value: Record<string, unknown>);
|
|
51
|
+
valueOf(): string;
|
|
52
|
+
toString(): string;
|
|
53
|
+
toJSON(): Record<string, unknown>;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* A row of a data collection, from a `row` field: its columns by key (`{{ author.name }}`,
|
|
57
|
+
* `{% image person.photo 'square' %}`), plus `_id`. It prints as its `name`, else its first text value.
|
|
58
|
+
*/
|
|
59
|
+
export declare class RowDrop extends Drop {
|
|
60
|
+
_id: string;
|
|
61
|
+
[column: string]: unknown;
|
|
62
|
+
constructor(row: Record<string, unknown>);
|
|
63
|
+
toString(): string;
|
|
64
|
+
valueOf(): string;
|
|
65
|
+
toJSON(): Record<string, unknown>;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Rich text links carry the page they point at (`data-page-id`); their `href` comes from the published page,
|
|
69
|
+
* keeping any `#anchor`, and is dropped when that page isn't published. Documents' come from `documents`.
|
|
70
|
+
*/
|
|
71
|
+
export declare function resolveRichText(html: string, context: LinkContext): string;
|
|
72
|
+
/**
|
|
73
|
+
* Wraps every stored link in a published page, data file or draft in a `LinkDrop`, every document value in a
|
|
74
|
+
* `DocumentDrop` and every row reference in a `RowDrop`, in place, resolving each against `context`. A row
|
|
75
|
+
* that isn't published reads as nothing, and is left out of lists.
|
|
76
|
+
*/
|
|
77
|
+
export declare function wrapLinks<T>(value: T, context?: LinkContext, depth?: number): T;
|
|
78
|
+
/** The rows a page's row references and byline authors point at, by collection id. */
|
|
79
|
+
export declare function referencedRows(value: unknown, found?: Map<string, Set<string>>): Map<string, Set<string>>;
|
|
80
|
+
/**
|
|
81
|
+
* The context for a site and the data files its page points at. People come from `site.json` `people` (with
|
|
82
|
+
* `sameAs`), so a person reads the same wherever they are referenced.
|
|
83
|
+
*/
|
|
84
|
+
export declare function linkContextFor(site: CeemsSite | undefined, files?: Iterable<CeemsDataFile | null>): LinkContext;
|
|
85
|
+
/**
|
|
86
|
+
* An article's byline as templates and structured data read it, in order: `page.authors`. A person is their
|
|
87
|
+
* People row (`{{ author.name }}`, `{{ author.profile }}`); a guest is what was typed; the organisation is the
|
|
88
|
+
* site's. Each has `kind`, `name` and `url` (a person's profile page, else their first profile link).
|
|
89
|
+
*/
|
|
90
|
+
export declare function bylineAuthors(page: Record<string, any>, site: CeemsSite | undefined, context: LinkContext): Record<string, unknown>[];
|
package/lib/links.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.LinkDrop = void 0;
|
|
3
|
+
exports.RowDrop = exports.DocumentDrop = exports.LinkDrop = void 0;
|
|
4
|
+
exports.resolveRichText = resolveRichText;
|
|
4
5
|
exports.wrapLinks = wrapLinks;
|
|
6
|
+
exports.referencedRows = referencedRows;
|
|
7
|
+
exports.linkContextFor = linkContextFor;
|
|
8
|
+
exports.bylineAuthors = bylineAuthors;
|
|
5
9
|
const liquidjs_1 = require("liquidjs");
|
|
6
10
|
/** The kinds of link Cee.ms stores: `{ kind, url, pageId?, documentId?, anchor?, email? }`. */
|
|
7
11
|
const LINK_KINDS = ['url', 'page', 'document', 'anchor', 'email'];
|
|
@@ -10,6 +14,8 @@ const LINK_KINDS = ['url', 'page', 'document', 'anchor', 'email'];
|
|
|
10
14
|
* link field still works where templates print it (`{{ item.url }}`), filter it (`| escape`, `| append`),
|
|
11
15
|
* compare it (`== '/about'`, `!= blank`) or measure it (`| size`); and its parts are there too
|
|
12
16
|
* (`{{ item.url.kind }}`, `.pageId`, `.anchor`). `| json` shows the whole link.
|
|
17
|
+
*
|
|
18
|
+
* A page link whose page isn't published reads as `''`, with `broken` true, so `{% if link %}` leaves it out.
|
|
13
19
|
*/
|
|
14
20
|
class LinkDrop extends liquidjs_1.Drop {
|
|
15
21
|
kind;
|
|
@@ -18,6 +24,7 @@ class LinkDrop extends liquidjs_1.Drop {
|
|
|
18
24
|
documentId;
|
|
19
25
|
anchor;
|
|
20
26
|
email;
|
|
27
|
+
broken;
|
|
21
28
|
constructor(link) {
|
|
22
29
|
super();
|
|
23
30
|
Object.assign(this, link);
|
|
@@ -41,21 +48,208 @@ class LinkDrop extends liquidjs_1.Drop {
|
|
|
41
48
|
}
|
|
42
49
|
}
|
|
43
50
|
exports.LinkDrop = LinkDrop;
|
|
51
|
+
/**
|
|
52
|
+
* A document value (`{ documentId, url, thumbnail, info }`) in templates, read from the published documents
|
|
53
|
+
* so a replaced file is right everywhere. It prints as its address, so `{{ download }}` and
|
|
54
|
+
* `{{ download.url }}` both work.
|
|
55
|
+
*/
|
|
56
|
+
class DocumentDrop extends liquidjs_1.Drop {
|
|
57
|
+
documentId;
|
|
58
|
+
url;
|
|
59
|
+
thumbnail;
|
|
60
|
+
info;
|
|
61
|
+
constructor(value) {
|
|
62
|
+
super();
|
|
63
|
+
Object.assign(this, value);
|
|
64
|
+
}
|
|
65
|
+
valueOf() {
|
|
66
|
+
return this.url;
|
|
67
|
+
}
|
|
68
|
+
toString() {
|
|
69
|
+
return this.url;
|
|
70
|
+
}
|
|
71
|
+
toJSON() {
|
|
72
|
+
return { ...this };
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
exports.DocumentDrop = DocumentDrop;
|
|
76
|
+
/**
|
|
77
|
+
* A row of a data collection, from a `row` field: its columns by key (`{{ author.name }}`,
|
|
78
|
+
* `{% image person.photo 'square' %}`), plus `_id`. It prints as its `name`, else its first text value.
|
|
79
|
+
*/
|
|
80
|
+
class RowDrop extends liquidjs_1.Drop {
|
|
81
|
+
_id;
|
|
82
|
+
constructor(row) {
|
|
83
|
+
super();
|
|
84
|
+
Object.assign(this, row);
|
|
85
|
+
}
|
|
86
|
+
toString() {
|
|
87
|
+
if (typeof this.name === 'string')
|
|
88
|
+
return this.name;
|
|
89
|
+
const first = Object.entries(this).find(([key, v]) => key !== '_id' && typeof v === 'string');
|
|
90
|
+
return first ? String(first[1]) : '';
|
|
91
|
+
}
|
|
92
|
+
valueOf() {
|
|
93
|
+
return this.toString();
|
|
94
|
+
}
|
|
95
|
+
toJSON() {
|
|
96
|
+
return { ...this };
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
exports.RowDrop = RowDrop;
|
|
44
100
|
const isLink = (value) => typeof value.kind === 'string' && LINK_KINDS.includes(value.kind) && typeof value.url === 'string';
|
|
45
|
-
|
|
46
|
-
|
|
101
|
+
const isRowRef = (value) => value.kind === 'row' && value.rowId !== undefined && value.collectionId !== undefined;
|
|
102
|
+
const isDocumentValue = (value) => value.documentId !== undefined && typeof value.url === 'string' && value.kind === undefined;
|
|
103
|
+
const RICH_LINK = /<a\b([^>]*)>/gi;
|
|
104
|
+
/**
|
|
105
|
+
* Rich text links carry the page they point at (`data-page-id`); their `href` comes from the published page,
|
|
106
|
+
* keeping any `#anchor`, and is dropped when that page isn't published. Documents' come from `documents`.
|
|
107
|
+
*/
|
|
108
|
+
function resolveRichText(html, context) {
|
|
109
|
+
if (!context.pageIndex && !context.documents)
|
|
110
|
+
return html;
|
|
111
|
+
return html.replace(RICH_LINK, (tag, attrs) => {
|
|
112
|
+
const pageId = /\bdata-page-id="([0-9a-f]{24})"/i.exec(attrs)?.[1];
|
|
113
|
+
const documentId = /\bdata-document-id="([0-9a-f]{24})"/i.exec(attrs)?.[1];
|
|
114
|
+
let href;
|
|
115
|
+
if (pageId && context.pageIndex) {
|
|
116
|
+
const anchor = /\bhref="[^"#]*#([^"]*)"/i.exec(attrs)?.[1];
|
|
117
|
+
const entry = context.pageIndex[pageId];
|
|
118
|
+
href = entry ? entry.path + (anchor ? `#${anchor}` : '') : null;
|
|
119
|
+
}
|
|
120
|
+
else if (documentId && context.documents) {
|
|
121
|
+
href = context.documents[documentId]?.url;
|
|
122
|
+
}
|
|
123
|
+
if (href === undefined)
|
|
124
|
+
return tag;
|
|
125
|
+
if (href === null)
|
|
126
|
+
return tag.replace(/\s*\bhref="[^"]*"/i, '');
|
|
127
|
+
const value = `href="${href.replace(/&/g, '&').replace(/"/g, '"')}"`;
|
|
128
|
+
return /\bhref="[^"]*"/i.test(attrs) ? tag.replace(/\bhref="[^"]*"/i, value) : `<a ${value}${attrs}>`;
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
function linkDrop(record, context) {
|
|
132
|
+
if (record.kind === 'page' && record.pageId && context.pageIndex) {
|
|
133
|
+
const entry = context.pageIndex[String(record.pageId)];
|
|
134
|
+
const anchor = record.anchor ? `#${record.anchor}` : '';
|
|
135
|
+
return new LinkDrop(entry ? { ...record, url: entry.path + anchor, broken: false } : { ...record, url: '', broken: true });
|
|
136
|
+
}
|
|
137
|
+
if (record.kind === 'document' && record.documentId && context.documents) {
|
|
138
|
+
const document = context.documents[String(record.documentId)];
|
|
139
|
+
if (document)
|
|
140
|
+
return new LinkDrop({ ...record, url: document.url });
|
|
141
|
+
}
|
|
142
|
+
return new LinkDrop(record);
|
|
143
|
+
}
|
|
144
|
+
/** Rows inside rows resolve this deep, so rows that point at each other can't loop. */
|
|
145
|
+
const ROW_DEPTH = 2;
|
|
146
|
+
/**
|
|
147
|
+
* Wraps every stored link in a published page, data file or draft in a `LinkDrop`, every document value in a
|
|
148
|
+
* `DocumentDrop` and every row reference in a `RowDrop`, in place, resolving each against `context`. A row
|
|
149
|
+
* that isn't published reads as nothing, and is left out of lists.
|
|
150
|
+
*/
|
|
151
|
+
function wrapLinks(value, context = {}, depth = 0) {
|
|
47
152
|
if (Array.isArray(value)) {
|
|
48
|
-
|
|
49
|
-
|
|
153
|
+
const wrapped = value.map((item) => wrapLinks(item, context, depth));
|
|
154
|
+
// a list of rows skips the ones that are gone
|
|
155
|
+
const kept = wrapped.filter((item, i) => item !== undefined || !isRowLike(value[i]));
|
|
156
|
+
value.splice(0, value.length, ...kept);
|
|
50
157
|
return value;
|
|
51
158
|
}
|
|
159
|
+
if (typeof value === 'string')
|
|
160
|
+
return (value.includes('<a') ? resolveRichText(value, context) : value);
|
|
52
161
|
if (!value || typeof value !== 'object' || value instanceof liquidjs_1.Drop)
|
|
53
162
|
return value;
|
|
54
163
|
const record = value;
|
|
55
164
|
if (isLink(record))
|
|
56
|
-
return
|
|
165
|
+
return linkDrop(record, context);
|
|
166
|
+
if (isRowRef(record)) {
|
|
167
|
+
if (!context.row || depth >= ROW_DEPTH)
|
|
168
|
+
return (context.row ? undefined : value);
|
|
169
|
+
const row = context.row(String(record.collectionId), String(record.rowId));
|
|
170
|
+
// a copy: rows come from data files cached across renders
|
|
171
|
+
return (row ? new RowDrop(wrapLinks(structuredClone(row), context, depth + 1)) : undefined);
|
|
172
|
+
}
|
|
173
|
+
if (isDocumentValue(record) && context.documents) {
|
|
174
|
+
const document = context.documents[String(record.documentId)];
|
|
175
|
+
return new DocumentDrop(document ? { ...record, ...document } : record);
|
|
176
|
+
}
|
|
57
177
|
for (const key of Object.keys(record))
|
|
58
|
-
record[key] = wrapLinks(record[key]);
|
|
178
|
+
record[key] = wrapLinks(record[key], context, depth);
|
|
59
179
|
return value;
|
|
60
180
|
}
|
|
181
|
+
const isRowLike = (value) => !!value && typeof value === 'object' && isRowRef(value);
|
|
182
|
+
/** The rows a page's row references and byline authors point at, by collection id. */
|
|
183
|
+
function referencedRows(value, found = new Map()) {
|
|
184
|
+
if (Array.isArray(value)) {
|
|
185
|
+
for (const item of value)
|
|
186
|
+
referencedRows(item, found);
|
|
187
|
+
}
|
|
188
|
+
else if (value && typeof value === 'object' && !(value instanceof liquidjs_1.Drop)) {
|
|
189
|
+
const record = value;
|
|
190
|
+
if (isRowRef(record) || (record.kind === 'person' && record.rowId !== undefined)) {
|
|
191
|
+
const collection = String(record.collectionId);
|
|
192
|
+
found.set(collection, (found.get(collection) ?? new Set()).add(String(record.rowId)));
|
|
193
|
+
}
|
|
194
|
+
else
|
|
195
|
+
for (const child of Object.values(record))
|
|
196
|
+
referencedRows(child, found);
|
|
197
|
+
}
|
|
198
|
+
return found;
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* The context for a site and the data files its page points at. People come from `site.json` `people` (with
|
|
202
|
+
* `sameAs`), so a person reads the same wherever they are referenced.
|
|
203
|
+
*/
|
|
204
|
+
function linkContextFor(site, files = []) {
|
|
205
|
+
const rows = new Map();
|
|
206
|
+
for (const file of files) {
|
|
207
|
+
if (!file?.rows)
|
|
208
|
+
continue;
|
|
209
|
+
rows.set(String(file._id), new Map(file.rows.map((row) => [String(row._id), row])));
|
|
210
|
+
}
|
|
211
|
+
return {
|
|
212
|
+
pageIndex: site?.pageIndex,
|
|
213
|
+
documents: site?.documents,
|
|
214
|
+
row: (collectionId, rowId) => {
|
|
215
|
+
const person = site?.people?.[rowId];
|
|
216
|
+
return person ? { _id: rowId, ...person } : rows.get(collectionId)?.get(rowId);
|
|
217
|
+
},
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* An article's byline as templates and structured data read it, in order: `page.authors`. A person is their
|
|
222
|
+
* People row (`{{ author.name }}`, `{{ author.profile }}`); a guest is what was typed; the organisation is the
|
|
223
|
+
* site's. Each has `kind`, `name` and `url` (a person's profile page, else their first profile link).
|
|
224
|
+
*/
|
|
225
|
+
function bylineAuthors(page, site, context) {
|
|
226
|
+
const authors = [];
|
|
227
|
+
for (const author of page.byline?.authors ?? []) {
|
|
228
|
+
if (author?.kind === 'person') {
|
|
229
|
+
const row = context.row?.(String(author.collectionId), String(author.rowId));
|
|
230
|
+
if (!row)
|
|
231
|
+
continue;
|
|
232
|
+
const person = new RowDrop(wrapLinks(structuredClone(row), context, 1));
|
|
233
|
+
const profile = person.profile;
|
|
234
|
+
const sameAs = Array.isArray(person.sameAs) ? person.sameAs : [];
|
|
235
|
+
person.kind = 'person';
|
|
236
|
+
person.url = profile && String(profile) ? String(profile) : sameAs[0];
|
|
237
|
+
authors.push(person);
|
|
238
|
+
}
|
|
239
|
+
else if (author?.kind === 'guest') {
|
|
240
|
+
authors.push({ kind: 'guest', name: author.name, url: author.url, jobTitle: author.jobTitle });
|
|
241
|
+
}
|
|
242
|
+
else if (author?.kind === 'organisation') {
|
|
243
|
+
const org = site?.site?.organisation;
|
|
244
|
+
if (org?.name)
|
|
245
|
+
authors.push({
|
|
246
|
+
kind: 'organisation',
|
|
247
|
+
name: org.name,
|
|
248
|
+
url: org.url || site?.site?.url,
|
|
249
|
+
photo: org.logo,
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
return authors;
|
|
254
|
+
}
|
|
61
255
|
//# sourceMappingURL=links.js.map
|
package/lib/links.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"links.js","sourceRoot":"","sources":["../src/links.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"links.js","sourceRoot":"","sources":["../src/links.ts"],"names":[],"mappings":";;;AA8IA,0CAkBC;AAyBD,8BAwBC;AAMD,wCAWC;AAMD,wCAcC;AAOD,sCA0BC;AAvRD,uCAAgC;AAShC,+FAA+F;AAC/F,MAAM,UAAU,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;AAelE;;;;;;;GAOG;AACH,MAAa,QAAS,SAAQ,eAAI;IAC9B,IAAI,CAAU;IACd,GAAG,CAAU;IACb,MAAM,CAAU;IAChB,UAAU,CAAU;IACpB,MAAM,CAAU;IAChB,KAAK,CAAU;IACf,MAAM,CAAW;IAEjB,YAAY,IAA6B;QACrC,KAAK,EAAE,CAAC;QACR,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAC9B,CAAC;IAED,OAAO;QACH,OAAO,IAAI,CAAC,GAAG,CAAC;IACpB,CAAC;IAED,QAAQ;QACJ,OAAO,IAAI,CAAC,GAAG,CAAC;IACpB,CAAC;IAED,2CAA2C;IAC3C,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AC,QAAQ,EAAE,CAAC,CAAC;QACnG,CAAC;aAAM,IAAI,MAAM,EAAE,IAAI,KAAK,cAAc,EAAE,CAAC;YACzC,MAAM,GAAG,GAAG,IAAI,EAAE,IAAI,EAAE,YAAY,CAAC;YACrC,IAAI,GAAG,EAAE,IAAI;gBACT,OAAO,CAAC,IAAI,CAAC;oBACT,IAAI,EAAE,cAAc;oBACpB,IAAI,EAAE,GAAG,CAAC,IAAI;oBACd,GAAG,EAAE,GAAG,CAAC,GAAG,IAAI,IAAI,EAAE,IAAI,EAAE,GAAG;oBAC/B,KAAK,EAAE,GAAG,CAAC,IAAI;iBAClB,CAAC,CAAC;QACX,CAAC;IACL,CAAC;IACD,OAAO,OAAO,CAAC;AACnB,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { CeemsPage, CeemsSite } from './interfaces';
|
|
2
|
+
/** One `<meta>`: Open Graph tags take `property`, X's take `name`. */
|
|
3
|
+
export interface SocialMetaTag {
|
|
4
|
+
attribute: 'property' | 'name';
|
|
5
|
+
key: string;
|
|
6
|
+
content: string;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* The page's link-preview tags: Open Graph, read by Facebook, LinkedIn, WhatsApp, Slack and others, and X's
|
|
10
|
+
* card. Built from what the page already publishes for search (title, description, social image, dates), so
|
|
11
|
+
* a template needs no more than `{% socialmeta %}`. X reads the title, description and image from Open Graph.
|
|
12
|
+
*/
|
|
13
|
+
export declare function socialMeta(site: CeemsSite, page: CeemsPage): SocialMetaTag[];
|
|
14
|
+
/** The tags as HTML, their content escaped for an attribute. */
|
|
15
|
+
export declare function renderSocialMeta(tags: SocialMetaTag[]): string;
|