@haverstack/eleventy 0.2.0
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/LICENSE +21 -0
- package/README.md +91 -0
- package/dist/assets.d.ts +52 -0
- package/dist/assets.d.ts.map +1 -0
- package/dist/assets.js +148 -0
- package/dist/assets.js.map +1 -0
- package/dist/check.d.ts +35 -0
- package/dist/check.d.ts.map +1 -0
- package/dist/check.js +141 -0
- package/dist/check.js.map +1 -0
- package/dist/cli.d.ts +15 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +122 -0
- package/dist/cli.js.map +1 -0
- package/dist/emit.d.ts +72 -0
- package/dist/emit.d.ts.map +1 -0
- package/dist/emit.js +147 -0
- package/dist/emit.js.map +1 -0
- package/dist/errors.d.ts +12 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +15 -0
- package/dist/errors.js.map +1 -0
- package/dist/feeds.d.ts +24 -0
- package/dist/feeds.d.ts.map +1 -0
- package/dist/feeds.js +103 -0
- package/dist/feeds.js.map +1 -0
- package/dist/index.d.ts +94 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +73 -0
- package/dist/index.js.map +1 -0
- package/dist/load.d.ts +86 -0
- package/dist/load.d.ts.map +1 -0
- package/dist/load.js +258 -0
- package/dist/load.js.map +1 -0
- package/dist/markdown.d.ts +23 -0
- package/dist/markdown.d.ts.map +1 -0
- package/dist/markdown.js +81 -0
- package/dist/markdown.js.map +1 -0
- package/dist/publish.d.ts +45 -0
- package/dist/publish.d.ts.map +1 -0
- package/dist/publish.js +79 -0
- package/dist/publish.js.map +1 -0
- package/dist/resolve.d.ts +119 -0
- package/dist/resolve.d.ts.map +1 -0
- package/dist/resolve.js +411 -0
- package/dist/resolve.js.map +1 -0
- package/dist/scaffold.d.ts +22 -0
- package/dist/scaffold.d.ts.map +1 -0
- package/dist/scaffold.js +98 -0
- package/dist/scaffold.js.map +1 -0
- package/dist/templates.d.ts +34 -0
- package/dist/templates.d.ts.map +1 -0
- package/dist/templates.js +171 -0
- package/dist/templates.js.map +1 -0
- package/dist/types.d.ts +96 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +123 -0
- package/dist/types.js.map +1 -0
- package/package.json +72 -0
package/dist/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACxE,OAAO,EAAE,mBAAmB,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/D,OAAO,EAAE,iBAAiB,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAG5D,MAAM,KAAK,GAAG;;;;;;;;;;;;;;;;;CAiBb,CAAC;AAEF,KAAK,UAAU,SAAS,CAAC,UAAkB;IACzC,MAAM,GAAG,GAAG,WAAW,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,UAAU,CAAC,CAAC;IACnD,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;QACrB,MAAM,IAAI,KAAK,CACb,qBAAqB,UAAU,IAAI;YACjC,oFAAoF,CACvF,CAAC;IACJ,CAAC;IACD,MAAM,GAAG,GAAG,CAAC,MAAM,MAAM,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAA4B,CAAC;IAC/E,IAAI,KAAK,GAAY,GAAG,CAAC,OAAO,IAAI,GAAG,CAAC,KAAK,IAAI,GAAG,CAAC;IACrD,IAA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AK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAC9E,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
package/dist/emit.d.ts
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @haverstack/eleventy — emit phase
|
|
3
|
+
* -------------------------------------------------------
|
|
4
|
+
* Turn a `ResolvedSite` into Eleventy virtual templates: one per page and
|
|
5
|
+
* per member, plus the feeds and the sitemap. Attachment bytes are staged
|
|
6
|
+
* to disk first and passed through. Global data exposes the resolved
|
|
7
|
+
* structures so a site that brings its own templates can iterate them.
|
|
8
|
+
*
|
|
9
|
+
* See docs/design.md § Emit.
|
|
10
|
+
*/
|
|
11
|
+
import type { StackClient, StackRecord } from '@haverstack/core';
|
|
12
|
+
import { type AssetPlan } from './assets.js';
|
|
13
|
+
import type { StackIndex } from './load.js';
|
|
14
|
+
import type { ResolvedMeta, ResolvedSite } from './resolve.js';
|
|
15
|
+
/**
|
|
16
|
+
* Maps a `template` name to a layout the site provides in its own
|
|
17
|
+
* `_includes`. A mapped page emits its content fragment plus that
|
|
18
|
+
* `layout`; an unmapped one keeps the self-contained built-in render.
|
|
19
|
+
* `base` is the fallback for any name not otherwise listed.
|
|
20
|
+
*/
|
|
21
|
+
export type TemplateOverrides = {
|
|
22
|
+
base?: string;
|
|
23
|
+
} & Record<string, string | undefined>;
|
|
24
|
+
/** Passed to a `pageData` hook so it can compute extra template data per record. */
|
|
25
|
+
export interface PageDataContext {
|
|
26
|
+
kind: 'page' | 'member';
|
|
27
|
+
record: StackRecord;
|
|
28
|
+
meta: ResolvedMeta;
|
|
29
|
+
url: string;
|
|
30
|
+
template: string;
|
|
31
|
+
canonical: string | null;
|
|
32
|
+
unlisted: boolean;
|
|
33
|
+
resolved: ResolvedSite;
|
|
34
|
+
}
|
|
35
|
+
export type PageDataHook = (ctx: PageDataContext) => Record<string, unknown>;
|
|
36
|
+
export interface EmitEleventyConfig {
|
|
37
|
+
addTemplate(virtualPath: string, content: string, data?: Record<string, unknown>): unknown;
|
|
38
|
+
addPassthroughCopy(path: string | Record<string, string>): unknown;
|
|
39
|
+
addGlobalData(name: string, value: unknown): unknown;
|
|
40
|
+
}
|
|
41
|
+
export interface EmitOptions {
|
|
42
|
+
eleventyConfig: EmitEleventyConfig;
|
|
43
|
+
stack: StackClient;
|
|
44
|
+
resolved: ResolvedSite;
|
|
45
|
+
index: StackIndex;
|
|
46
|
+
assetDir: string;
|
|
47
|
+
/** Maximum entries per feed. */
|
|
48
|
+
feedLimit: number;
|
|
49
|
+
/** Directory `assetDir` is resolved against when staging bytes. Default `process.cwd()`. */
|
|
50
|
+
cwd?: string;
|
|
51
|
+
/** Per-template-name layout overrides. Unmapped names use the built-in render. */
|
|
52
|
+
templates?: TemplateOverrides;
|
|
53
|
+
/**
|
|
54
|
+
* `false` keeps the plugin's pages out of Eleventy's `collections` and
|
|
55
|
+
* `eleventyNavigation` entirely. Default `true`.
|
|
56
|
+
*/
|
|
57
|
+
eleventyCollections?: boolean;
|
|
58
|
+
/** Extra data merged into every page/member template, last (so it can override). */
|
|
59
|
+
pageData?: PageDataHook;
|
|
60
|
+
}
|
|
61
|
+
export interface EmitResult {
|
|
62
|
+
pages: number;
|
|
63
|
+
members: number;
|
|
64
|
+
feeds: number;
|
|
65
|
+
assets: {
|
|
66
|
+
written: number;
|
|
67
|
+
skipped: number;
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
export declare function emit(opts: EmitOptions): Promise<EmitResult>;
|
|
71
|
+
export type { AssetPlan };
|
|
72
|
+
//# sourceMappingURL=emit.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"emit.d.ts","sourceRoot":"","sources":["../src/emit.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,KAAK,EAAY,W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nB,QAAQ,EAAE,YAAY,CAAC;IACvB,KAAK,EAAE,UAAU,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,gCAAgC;IAChC,SAAS,EAAE,MAAM,CAAC;IAClB,4FAA4F;IAC5F,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,kFAAkF;IAClF,SAAS,CAAC,EAAE,iBAAiB,CAAC;IAC9B;;;OAGG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,oFAAoF;IACpF,QAAQ,CAAC,EAAE,YAAY,CAAC;CACzB;AAED,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;CAC9C;AAuBD,wBAAsB,IAAI,CAAC,IAAI,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC,CAmKjE;AAED,YAAY,EAAE,SAAS,EAAE,CAAC"}
|
package/dist/emit.js
ADDED
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @haverstack/eleventy — emit phase
|
|
3
|
+
* -------------------------------------------------------
|
|
4
|
+
* Turn a `ResolvedSite` into Eleventy virtual templates: one per page and
|
|
5
|
+
* per member, plus the feeds and the sitemap. Attachment bytes are staged
|
|
6
|
+
* to disk first and passed through. Global data exposes the resolved
|
|
7
|
+
* structures so a site that brings its own templates can iterate them.
|
|
8
|
+
*
|
|
9
|
+
* See docs/design.md § Emit.
|
|
10
|
+
*/
|
|
11
|
+
import { resolve as resolvePath } from 'node:path';
|
|
12
|
+
import { collectAssets, stageAssets } from './assets.js';
|
|
13
|
+
import { atomFeed, feedSpecs, sitemapXml } from './feeds.js';
|
|
14
|
+
import { renderMember, renderMemberFragment, renderPage, renderPageFragment, } from './templates.js';
|
|
15
|
+
import { renderBody, substituteEmbeds } from './markdown.js';
|
|
16
|
+
const flattenWithParent = (pages, parentId) => pages.flatMap((page) => [
|
|
17
|
+
{ page, parentId },
|
|
18
|
+
...flattenWithParent(page.children, page.record.id),
|
|
19
|
+
]);
|
|
20
|
+
/** Content is verbatim (already HTML); layouts and transforms still apply. */
|
|
21
|
+
const CONTENT_VERBATIM = { templateEngineOverride: false };
|
|
22
|
+
/** Feeds and the sitemap are output, never content — keep them out of collections. */
|
|
23
|
+
const OUTPUT_FILE = { ...CONTENT_VERBATIM, eleventyExcludeFromCollections: true };
|
|
24
|
+
const typeSlug = (typeId) => typeId.split('@')[0].split('/').pop() ?? 'record';
|
|
25
|
+
const tagAssociations = (record) => (record.associations ?? []).flatMap((a) => (a.kind === 'tag' ? [a.label] : []));
|
|
26
|
+
export async function emit(opts) {
|
|
27
|
+
const { eleventyConfig, stack, resolved, index, assetDir, feedLimit } = opts;
|
|
28
|
+
const assets = collectAssets(resolved, index, assetDir);
|
|
29
|
+
const staged = await stageAssets(stack, assets, resolvePath(opts.cwd ?? process.cwd(), assets.assetDir));
|
|
30
|
+
eleventyConfig.addPassthroughCopy(assets.assetDir);
|
|
31
|
+
const flatPages = flattenWithParent(resolved.pages);
|
|
32
|
+
const rawBody = (record) => substituteEmbeds(String(record.content.text ?? ''), assets.embedsByRecord.get(record.id) ?? new Map());
|
|
33
|
+
const bodyByRecord = new Map();
|
|
34
|
+
for (const record of [
|
|
35
|
+
...flatPages.map((f) => f.page.record),
|
|
36
|
+
...resolved.members.map((m) => m.record),
|
|
37
|
+
]) {
|
|
38
|
+
bodyByRecord.set(record.id, renderBody(String(record.content.text ?? ''), record.content.format, assets.embedsByRecord.get(record.id)));
|
|
39
|
+
}
|
|
40
|
+
const feeds = feedSpecs(resolved);
|
|
41
|
+
const ctx = { resolved, assets, feeds, bodyByRecord };
|
|
42
|
+
const overrides = opts.templates;
|
|
43
|
+
const layoutFor = (name) => overrides?.[name] ?? overrides?.base;
|
|
44
|
+
const collectionsOn = opts.eleventyCollections !== false;
|
|
45
|
+
/** Collection membership + the exclude flag for one record. */
|
|
46
|
+
const graphData = (record, unlisted) => {
|
|
47
|
+
if (!collectionsOn || unlisted)
|
|
48
|
+
return { eleventyExcludeFromCollections: true };
|
|
49
|
+
return { tags: ['haverstack', typeSlug(record.typeId), ...tagAssociations(record)] };
|
|
50
|
+
};
|
|
51
|
+
for (const { page, parentId } of flatPages) {
|
|
52
|
+
const layout = layoutFor(page.template);
|
|
53
|
+
const collection = resolved.collections.get(String(page.record.content.slug));
|
|
54
|
+
const nav = collectionsOn && !page.unlisted
|
|
55
|
+
? {
|
|
56
|
+
eleventyNavigation: {
|
|
57
|
+
key: page.record.id,
|
|
58
|
+
...(parentId ? { parent: parentId } : {}),
|
|
59
|
+
title: page.record.content.title ?? page.record.content.slug,
|
|
60
|
+
...(typeof page.meta.order === 'number' ? { order: page.meta.order } : {}),
|
|
61
|
+
},
|
|
62
|
+
}
|
|
63
|
+
: {};
|
|
64
|
+
const hookData = opts.pageData?.({
|
|
65
|
+
kind: 'page',
|
|
66
|
+
record: page.record,
|
|
67
|
+
meta: page.meta,
|
|
68
|
+
url: page.url,
|
|
69
|
+
template: page.template,
|
|
70
|
+
canonical: null,
|
|
71
|
+
unlisted: page.unlisted,
|
|
72
|
+
resolved,
|
|
73
|
+
}) ?? {};
|
|
74
|
+
eleventyConfig.addTemplate(`haverstack/page-${page.record.id}.html`, layout ? renderPageFragment(page, ctx) : renderPage(page, ctx), {
|
|
75
|
+
...CONTENT_VERBATIM,
|
|
76
|
+
...graphData(page.record, page.unlisted),
|
|
77
|
+
...nav,
|
|
78
|
+
...(layout ? { layout } : {}),
|
|
79
|
+
permalink: page.url,
|
|
80
|
+
title: page.record.content.title ?? null,
|
|
81
|
+
record: page.record,
|
|
82
|
+
meta: page.meta,
|
|
83
|
+
url: page.url,
|
|
84
|
+
body: bodyByRecord.get(page.record.id) ?? '',
|
|
85
|
+
bodyRaw: rawBody(page.record),
|
|
86
|
+
unlisted: page.unlisted,
|
|
87
|
+
haverstackTemplate: page.template,
|
|
88
|
+
...(collection ? { collection } : {}),
|
|
89
|
+
...hookData,
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
for (const member of resolved.members) {
|
|
93
|
+
const layout = layoutFor(member.template);
|
|
94
|
+
const hookData = opts.pageData?.({
|
|
95
|
+
kind: 'member',
|
|
96
|
+
record: member.record,
|
|
97
|
+
meta: member.meta,
|
|
98
|
+
url: member.url,
|
|
99
|
+
template: member.template,
|
|
100
|
+
canonical: member.canonical,
|
|
101
|
+
unlisted: member.unlisted,
|
|
102
|
+
resolved,
|
|
103
|
+
}) ?? {};
|
|
104
|
+
eleventyConfig.addTemplate(`haverstack/member-${member.record.id}.html`, layout ? renderMemberFragment(member, ctx) : renderMember(member, ctx), {
|
|
105
|
+
...CONTENT_VERBATIM,
|
|
106
|
+
...graphData(member.record, member.unlisted),
|
|
107
|
+
...(layout ? { layout } : {}),
|
|
108
|
+
permalink: member.url,
|
|
109
|
+
title: member.record.content.title ?? member.record.content.caption ?? null,
|
|
110
|
+
record: member.record,
|
|
111
|
+
meta: member.meta,
|
|
112
|
+
url: member.url,
|
|
113
|
+
body: bodyByRecord.get(member.record.id) ?? '',
|
|
114
|
+
bodyRaw: rawBody(member.record),
|
|
115
|
+
canonical: member.canonical,
|
|
116
|
+
unlisted: member.unlisted,
|
|
117
|
+
haverstackTemplate: member.template,
|
|
118
|
+
...hookData,
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
for (const spec of feeds) {
|
|
122
|
+
eleventyConfig.addTemplate(`haverstack/feed-${spec.path.replace(/[^a-z0-9]+/gi, '-')}.html`, atomFeed(spec, resolved, feedLimit), { ...OUTPUT_FILE, permalink: spec.path });
|
|
123
|
+
}
|
|
124
|
+
const sitemap = sitemapXml(resolved);
|
|
125
|
+
if (sitemap) {
|
|
126
|
+
eleventyConfig.addTemplate('haverstack/sitemap.html', sitemap, {
|
|
127
|
+
...OUTPUT_FILE,
|
|
128
|
+
permalink: '/sitemap.xml',
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
eleventyConfig.addGlobalData('haverstack', {
|
|
132
|
+
site: resolved.site,
|
|
133
|
+
sites: Object.fromEntries(resolved.sites),
|
|
134
|
+
owner: resolved.owner,
|
|
135
|
+
pages: resolved.pages,
|
|
136
|
+
menus: Object.fromEntries(resolved.menus),
|
|
137
|
+
collections: Object.fromEntries(resolved.collections),
|
|
138
|
+
assetDir: assets.assetDir,
|
|
139
|
+
});
|
|
140
|
+
return {
|
|
141
|
+
pages: flatPages.length,
|
|
142
|
+
members: resolved.members.length,
|
|
143
|
+
feeds: feeds.length,
|
|
144
|
+
assets: staged,
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
//# sourceMappingURL=emit.js.map
|
package/dist/emit.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"emit.js","sourceRoot":"","sources":["../src/emit.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,WAAW,CAAC;AAEnD,OAAO,EAAE,aAAa,EAAE,WAAW,EAAkB,MAAM,aAAa,CAAC;AACzE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7D,OAAO,EACL,YAAY,EACZ,oBAAoB,EACpB,UAAU,EACV,kBAAkB,GAEnB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAiE7D,MAAM,iBAAiB,GAAG,CAAC,KAAqB,EAAE,QAAmB,EAAc,EAAE,CACnF,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC;IACtB,EAAE,IAAI,EAAE,QAAQ,EAAE;IAClB,GAAG,iBAAiB,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;CACp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.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @haverstack/eleventy — build errors
|
|
3
|
+
* -------------------------------------------------------
|
|
4
|
+
* One error type for every structural fault that fails a build: an
|
|
5
|
+
* unresolvable site, a path collision, conflicting sidecars. The `check`
|
|
6
|
+
* command catches these to report them without emitting; a plain build
|
|
7
|
+
* lets them throw.
|
|
8
|
+
*/
|
|
9
|
+
export declare class HaverstackEleventyError extends Error {
|
|
10
|
+
constructor(message: string);
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,qBAAa,uBAAwB,SAAQ,KAAK;gBACpC,OAAO,EAAE,MAAM;CAI5B"}
|
package/dist/errors.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @haverstack/eleventy — build errors
|
|
3
|
+
* -------------------------------------------------------
|
|
4
|
+
* One error type for every structural fault that fails a build: an
|
|
5
|
+
* unresolvable site, a path collision, conflicting sidecars. The `check`
|
|
6
|
+
* command catches these to report them without emitting; a plain build
|
|
7
|
+
* lets them throw.
|
|
8
|
+
*/
|
|
9
|
+
export class HaverstackEleventyError extends Error {
|
|
10
|
+
constructor(message) {
|
|
11
|
+
super(message);
|
|
12
|
+
this.name = 'HaverstackEleventyError';
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,MAAM,OAAO,uBAAwB,SAAQ,KAAK;IAChD,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,yBAAyB,CAAC;IACxC,CAAC;CACF"}
|
package/dist/feeds.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @haverstack/eleventy — feeds and the sitemap
|
|
3
|
+
* -------------------------------------------------------
|
|
4
|
+
* Output, not records: renderings of the collections the page tree already
|
|
5
|
+
* describes, one set per site. A feed per listing root plus a combined
|
|
6
|
+
* one; the sitemap is every resolved permalink minus the unlisted ones.
|
|
7
|
+
* Absolute URLs come from the site record's `baseUrl`, so these need a
|
|
8
|
+
* site record — a single-site stack with none gets neither.
|
|
9
|
+
*
|
|
10
|
+
* See docs/design.md § Feeds and the sitemap.
|
|
11
|
+
*/
|
|
12
|
+
import type { ResolvedMember, ResolvedSite } from './resolve.js';
|
|
13
|
+
export interface FeedSpec {
|
|
14
|
+
/** Output path, e.g. `/feeds/articles.xml`. */
|
|
15
|
+
path: string;
|
|
16
|
+
/** Feed `<title>`. */
|
|
17
|
+
title: string;
|
|
18
|
+
members: ResolvedMember[];
|
|
19
|
+
}
|
|
20
|
+
/** One Atom feed per listing root, plus a combined `/feeds/all.xml`. */
|
|
21
|
+
export declare function feedSpecs(resolved: ResolvedSite): FeedSpec[];
|
|
22
|
+
export declare function atomFeed(spec: FeedSpec, resolved: ResolvedSite, limit: number): string;
|
|
23
|
+
export declare function sitemapXml(resolved: ResolvedSite): string | null;
|
|
24
|
+
//# sourceMappingURL=feeds.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"feeds.d.ts","sourceRoot":"","sources":["../src/feeds.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,KAAK,EAAsB,cAAc,EAAgB,YAAY,EAAE,MAAM,cAAc,CAAC;AAuBnG,MAAM,WAAW,QAAQ;IACvB,+CAA+C;IAC/C,IAAI,EAAE,MAAM,CAAC;IACb,sBAAsB;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,cAAc,EAAE,CAAC;CAC3B;AAED,wEAAwE;AACxE,wBAAgB,SAAS,CAAC,QAAQ,EAAE,YAAY,GAAG,QAAQ,EAAE,CAyB5D;AAED,wBAAgB,QAAQ,CAAC,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAyCtF;AAED,wBAAgB,UAAU,CAAC,QAAQ,EAAE,YAAY,GAAG,MAAM,GAAG,IAAI,CAoBhE"}
|
package/dist/feeds.js
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @haverstack/eleventy — feeds and the sitemap
|
|
3
|
+
* -------------------------------------------------------
|
|
4
|
+
* Output, not records: renderings of the collections the page tree already
|
|
5
|
+
* describes, one set per site. A feed per listing root plus a combined
|
|
6
|
+
* one; the sitemap is every resolved permalink minus the unlisted ones.
|
|
7
|
+
* Absolute URLs come from the site record's `baseUrl`, so these need a
|
|
8
|
+
* site record — a single-site stack with none gets neither.
|
|
9
|
+
*
|
|
10
|
+
* See docs/design.md § Feeds and the sitemap.
|
|
11
|
+
*/
|
|
12
|
+
const xmlEscape = (s) => s.replace(/[<>&'"]/g, (c) => ({ '<': '<', '>': '>', '&': '&', "'": ''', '"': '"' })[c]);
|
|
13
|
+
const absolute = (baseUrl, path) => `${baseUrl.replace(/\/+$/, '')}${path.startsWith('/') ? path : `/${path}`}`;
|
|
14
|
+
function memberDate(record) {
|
|
15
|
+
const publishedAt = record.content.publishedAt;
|
|
16
|
+
const ms = typeof publishedAt === 'string' ? Date.parse(publishedAt) : NaN;
|
|
17
|
+
return new Date(Number.isNaN(ms) ? record.createdAt.getTime() : ms).toISOString();
|
|
18
|
+
}
|
|
19
|
+
const memberTitle = (record) => String(record.content.title ?? record.content.caption ?? record.content.text ?? record.id).slice(0, 200);
|
|
20
|
+
/** One Atom feed per listing root, plus a combined `/feeds/all.xml`. */
|
|
21
|
+
export function feedSpecs(resolved) {
|
|
22
|
+
if (!resolved.site)
|
|
23
|
+
return [];
|
|
24
|
+
const siteTitle = String(resolved.site.content.title ?? 'Feed');
|
|
25
|
+
const specs = [];
|
|
26
|
+
const seen = new Set();
|
|
27
|
+
const combined = [];
|
|
28
|
+
for (const [slug, collection] of resolved.collections) {
|
|
29
|
+
specs.push({
|
|
30
|
+
path: `/feeds/${slug}.xml`,
|
|
31
|
+
title: `${siteTitle} — ${slug}`,
|
|
32
|
+
members: collection.members,
|
|
33
|
+
});
|
|
34
|
+
for (const member of collection.members) {
|
|
35
|
+
if (seen.has(member.record.id))
|
|
36
|
+
continue;
|
|
37
|
+
seen.add(member.record.id);
|
|
38
|
+
combined.push(member);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
if (specs.length > 1) {
|
|
42
|
+
combined.sort((a, b) => memberDate(b.record).localeCompare(memberDate(a.record)));
|
|
43
|
+
specs.push({ path: '/feeds/all.xml', title: siteTitle, members: combined });
|
|
44
|
+
}
|
|
45
|
+
return specs;
|
|
46
|
+
}
|
|
47
|
+
export function atomFeed(spec, resolved, limit) {
|
|
48
|
+
const site = resolved.site;
|
|
49
|
+
const baseUrl = String(site.content.baseUrl ?? '');
|
|
50
|
+
const self = absolute(baseUrl, spec.path);
|
|
51
|
+
const updated = spec.members.length > 0 ? memberDate(spec.members[0].record) : new Date().toISOString();
|
|
52
|
+
const author = resolved.owner?.content.name;
|
|
53
|
+
const entries = spec.members
|
|
54
|
+
.slice(0, limit)
|
|
55
|
+
.map((member) => {
|
|
56
|
+
const link = member.canonical ?? absolute(baseUrl, member.url);
|
|
57
|
+
const summary = member.record.content.summary;
|
|
58
|
+
return (` <entry>\n` +
|
|
59
|
+
` <title>${xmlEscape(memberTitle(member.record))}</title>\n` +
|
|
60
|
+
` <link href="${xmlEscape(link)}"/>\n` +
|
|
61
|
+
` <id>${xmlEscape(link)}</id>\n` +
|
|
62
|
+
` <updated>${memberDate(member.record)}</updated>\n` +
|
|
63
|
+
(typeof summary === 'string' && summary
|
|
64
|
+
? ` <summary>${xmlEscape(summary)}</summary>\n`
|
|
65
|
+
: '') +
|
|
66
|
+
` </entry>`);
|
|
67
|
+
})
|
|
68
|
+
.join('\n');
|
|
69
|
+
return (`<?xml version="1.0" encoding="UTF-8"?>\n` +
|
|
70
|
+
`<feed xmlns="http://www.w3.org/2005/Atom">\n` +
|
|
71
|
+
` <title>${xmlEscape(spec.title)}</title>\n` +
|
|
72
|
+
` <link href="${xmlEscape(absolute(baseUrl, '/'))}"/>\n` +
|
|
73
|
+
` <link rel="self" href="${xmlEscape(self)}"/>\n` +
|
|
74
|
+
` <id>${xmlEscape(self)}</id>\n` +
|
|
75
|
+
` <updated>${updated}</updated>\n` +
|
|
76
|
+
(typeof author === 'string' && author
|
|
77
|
+
? ` <author><name>${xmlEscape(author)}</name></author>\n`
|
|
78
|
+
: '') +
|
|
79
|
+
`${entries}${entries ? '\n' : ''}` +
|
|
80
|
+
`</feed>\n`);
|
|
81
|
+
}
|
|
82
|
+
export function sitemapXml(resolved) {
|
|
83
|
+
if (!resolved.site)
|
|
84
|
+
return null;
|
|
85
|
+
const baseUrl = String(resolved.site.content.baseUrl ?? '');
|
|
86
|
+
const locs = [];
|
|
87
|
+
const walk = (pages) => {
|
|
88
|
+
for (const page of pages) {
|
|
89
|
+
if (!page.unlisted)
|
|
90
|
+
locs.push(absolute(baseUrl, page.url));
|
|
91
|
+
walk(page.children);
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
walk(resolved.pages);
|
|
95
|
+
for (const member of resolved.members) {
|
|
96
|
+
if (!member.unlisted)
|
|
97
|
+
locs.push(absolute(baseUrl, member.url));
|
|
98
|
+
}
|
|
99
|
+
const body = locs.map((loc) => ` <url><loc>${xmlEscape(loc)}</loc></url>`).join('\n');
|
|
100
|
+
return (`<?xml version="1.0" encoding="UTF-8"?>\n` +
|
|
101
|
+
`<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">\n${body}\n</urlset>\n`);
|
|
102
|
+
}
|
|
103
|
+
//# sour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AI,CAAC,GAAG,CAAC,CAAC,CAAC;YAC3D,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACtB,CAAC;IACH,CAAC,CAAC;IACF,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IACrB,KAAK,MAAM,MAAM,IAAI,QAAQ,CAAC,OAAO,EAAE,CAAC;QACtC,IAAI,CAAC,MAAM,CAAC,QAAQ;YAAE,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;IACjE,CAAC;IAED,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,eAAe,SAAS,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACvF,OAAO,CACL,0CAA0C;QAC1C,iEAAiE,IAAI,eAAe,CACrF,CAAC;AACJ,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @haverstack/eleventy
|
|
3
|
+
* -------------------------------------------------------
|
|
4
|
+
* An Eleventy plugin that builds a static site from a Haverstack stack.
|
|
5
|
+
* Records are the content source; there are no content files on disk.
|
|
6
|
+
*
|
|
7
|
+
* ```js
|
|
8
|
+
* import { haverstack } from '@haverstack/eleventy';
|
|
9
|
+
* import { LocalAdapter } from '@haverstack/adapter-local';
|
|
10
|
+
* import { Stack } from '@haverstack/core';
|
|
11
|
+
*
|
|
12
|
+
* export default async function (eleventyConfig) {
|
|
13
|
+
* const stack = await Stack.create(await LocalAdapter.open({ path: './stack.db' }));
|
|
14
|
+
* eleventyConfig.addPlugin(haverstack, { stack, site: 'personal' });
|
|
15
|
+
* }
|
|
16
|
+
* ```
|
|
17
|
+
*
|
|
18
|
+
* See docs/design.md for the design. Load → resolve → emit run at
|
|
19
|
+
* plugin-init time; the plugin adds one virtual template per page and
|
|
20
|
+
* member, the feeds, the sitemap, and `haverstack` global data.
|
|
21
|
+
*/
|
|
22
|
+
import type { Stack } from '@haverstack/core';
|
|
23
|
+
import { type SlugStrategy } from './resolve.js';
|
|
24
|
+
import { type EmitEleventyConfig, type PageDataHook, type TemplateOverrides } from './emit.js';
|
|
25
|
+
export * from './types.js';
|
|
26
|
+
export * from './errors.js';
|
|
27
|
+
export * from './load.js';
|
|
28
|
+
export * from './resolve.js';
|
|
29
|
+
export * from './assets.js';
|
|
30
|
+
export * from './markdown.js';
|
|
31
|
+
export * from './feeds.js';
|
|
32
|
+
export * from './templates.js';
|
|
33
|
+
export * from './emit.js';
|
|
34
|
+
export * from './check.js';
|
|
35
|
+
export * from './publish.js';
|
|
36
|
+
export * from './scaffold.js';
|
|
37
|
+
export interface HaverstackPluginOptions {
|
|
38
|
+
/**
|
|
39
|
+
* The stack to build from. Backed by any adapter — `APIAdapter` for a
|
|
40
|
+
* remote server, `LocalAdapter` for an offline or CI build, `MemoryAdapter`
|
|
41
|
+
* for tests. The plugin never writes through it; that discipline is a
|
|
42
|
+
* rule, not a guarantee. See docs/design.md § It takes a Stack, not a URL.
|
|
43
|
+
*/
|
|
44
|
+
stack: Stack;
|
|
45
|
+
/**
|
|
46
|
+
* Names the `site@1` record to build, by `handle` or by record ID.
|
|
47
|
+
* Resolving to zero or several records fails the build. Omit on a stack
|
|
48
|
+
* with no `site@1` records — the single-site case.
|
|
49
|
+
*/
|
|
50
|
+
site?: string;
|
|
51
|
+
/** Directory the staged attachment bytes are written to and passed through. Default `_stack-assets`. */
|
|
52
|
+
assetDir?: string;
|
|
53
|
+
/** This site's permalink-derivation policy for listing members. Default `'title'`. */
|
|
54
|
+
slugStrategy?: SlugStrategy;
|
|
55
|
+
/** Maximum entries per Atom feed. Default 20. */
|
|
56
|
+
feedLimit?: number;
|
|
57
|
+
/**
|
|
58
|
+
* Replace the built-in templates with the site's own. Maps a `template`
|
|
59
|
+
* name (`home`, `content`, `listing`, `listing-inline`, `article`,
|
|
60
|
+
* `post`, `photo`, `bookmark`, or a custom name from a sidecar) to a
|
|
61
|
+
* layout the site provides in its `_includes`. A mapped page emits its
|
|
62
|
+
* content fragment plus that `layout`; the layout receives `content`
|
|
63
|
+
* plus `record`, `meta`, `url`, `collection`, and the `haverstack`
|
|
64
|
+
* globals, and may chain to another layout. `base` catches every
|
|
65
|
+
* unmapped name; anything still unmapped uses the built-in render. Run
|
|
66
|
+
* `haverstack-eleventy eject` for a starter `haverstack-base` layout.
|
|
67
|
+
*/
|
|
68
|
+
templates?: TemplateOverrides;
|
|
69
|
+
/**
|
|
70
|
+
* `false` keeps the plugin's pages out of Eleventy's `collections` and
|
|
71
|
+
* `eleventyNavigation` — full isolation from the host's content graph.
|
|
72
|
+
* Default `true`: pages carry `tags` (`haverstack`, the record's type,
|
|
73
|
+
* its tag associations) and root-to-leaf `eleventyNavigation`, so
|
|
74
|
+
* `collections.*`, navigation plugins and anything reading
|
|
75
|
+
* `collections.all` see them. Unlisted records are excluded regardless.
|
|
76
|
+
*/
|
|
77
|
+
eleventyCollections?: boolean;
|
|
78
|
+
/**
|
|
79
|
+
* Extra data merged into every page/member template, computed per
|
|
80
|
+
* record. Merged last, so it can override anything the plugin set —
|
|
81
|
+
* the substitute for directory data files, which virtual templates
|
|
82
|
+
* cannot have.
|
|
83
|
+
*/
|
|
84
|
+
pageData?: PageDataHook;
|
|
85
|
+
}
|
|
86
|
+
/** The subset of Eleventy's config object this plugin uses. */
|
|
87
|
+
export type EleventyConfig = EmitEleventyConfig;
|
|
88
|
+
/**
|
|
89
|
+
* The Eleventy plugin. Registered the ordinary way with
|
|
90
|
+
* `eleventyConfig.addPlugin(haverstack, options)`.
|
|
91
|
+
*/
|
|
92
|
+
export declare function haverstack(eleventyConfig: EleventyConfig, options: HaverstackPluginOptions): Promise<void>;
|
|
93
|
+
export default haverstack;
|
|
94
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.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AAED,eAAe,UAAU,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @haverstack/eleventy
|
|
3
|
+
* -------------------------------------------------------
|
|
4
|
+
* An Eleventy plugin that builds a static site from a Haverstack stack.
|
|
5
|
+
* Records are the content source; there are no content files on disk.
|
|
6
|
+
*
|
|
7
|
+
* ```js
|
|
8
|
+
* import { haverstack } from '@haverstack/eleventy';
|
|
9
|
+
* import { LocalAdapter } from '@haverstack/adapter-local';
|
|
10
|
+
* import { Stack } from '@haverstack/core';
|
|
11
|
+
*
|
|
12
|
+
* export default async function (eleventyConfig) {
|
|
13
|
+
* const stack = await Stack.create(await LocalAdapter.open({ path: './stack.db' }));
|
|
14
|
+
* eleventyConfig.addPlugin(haverstack, { stack, site: 'personal' });
|
|
15
|
+
* }
|
|
16
|
+
* ```
|
|
17
|
+
*
|
|
18
|
+
* See docs/design.md for the design. Load → resolve → emit run at
|
|
19
|
+
* plugin-init time; the plugin adds one virtual template per page and
|
|
20
|
+
* member, the feeds, the sitemap, and `haverstack` global data.
|
|
21
|
+
*/
|
|
22
|
+
import { defineEleventyTypes } from './types.js';
|
|
23
|
+
import { load } from './load.js';
|
|
24
|
+
import { resolve } from './resolve.js';
|
|
25
|
+
import { emit, } from './emit.js';
|
|
26
|
+
export * from './types.js';
|
|
27
|
+
export * from './errors.js';
|
|
28
|
+
export * from './load.js';
|
|
29
|
+
export * from './resolve.js';
|
|
30
|
+
export * from './assets.js';
|
|
31
|
+
export * from './markdown.js';
|
|
32
|
+
export * from './feeds.js';
|
|
33
|
+
export * from './templates.js';
|
|
34
|
+
export * from './emit.js';
|
|
35
|
+
export * from './check.js';
|
|
36
|
+
export * from './publish.js';
|
|
37
|
+
export * from './scaffold.js';
|
|
38
|
+
const DEFAULT_ASSET_DIR = '_stack-assets';
|
|
39
|
+
const DEFAULT_FEED_LIMIT = 20;
|
|
40
|
+
/**
|
|
41
|
+
* The Eleventy plugin. Registered the ordinary way with
|
|
42
|
+
* `eleventyConfig.addPlugin(haverstack, options)`.
|
|
43
|
+
*/
|
|
44
|
+
export async function haverstack(eleventyConfig, options) {
|
|
45
|
+
if (!options || !options.stack) {
|
|
46
|
+
throw new Error('@haverstack/eleventy: the `stack` option is required.');
|
|
47
|
+
}
|
|
48
|
+
await defineEleventyTypes(options.stack);
|
|
49
|
+
const index = await load(options.stack, { site: options.site });
|
|
50
|
+
const resolved = resolve(index, { slugStrategy: options.slugStrategy ?? 'title' });
|
|
51
|
+
const name = resolved.site ? `"${resolved.site.content.title}"` : 'the single site';
|
|
52
|
+
const unlisted = index.unlistedVisible
|
|
53
|
+
? ''
|
|
54
|
+
: ' — unlisted records not visible under this credential';
|
|
55
|
+
for (const w of resolved.warnings)
|
|
56
|
+
console.warn(`[haverstack] ! ${w.message}`);
|
|
57
|
+
const result = await emit({
|
|
58
|
+
eleventyConfig,
|
|
59
|
+
stack: options.stack,
|
|
60
|
+
resolved,
|
|
61
|
+
index,
|
|
62
|
+
assetDir: options.assetDir ?? DEFAULT_ASSET_DIR,
|
|
63
|
+
feedLimit: options.feedLimit ?? DEFAULT_FEED_LIMIT,
|
|
64
|
+
templates: options.templates,
|
|
65
|
+
eleventyCollections: options.eleventyCollections,
|
|
66
|
+
pageData: options.pageData,
|
|
67
|
+
});
|
|
68
|
+
console.info(`[haverstack] ${name}: ${result.pages} pages, ${result.members} members, ` +
|
|
69
|
+
`${result.feeds} feeds, assets ${result.assets.written} written / ${result.assets.skipped} cached` +
|
|
70
|
+
`${resolved.warnings.length ? `, ${resolved.warnings.length} warning(s)` : ''}${unlisted}`);
|
|
71
|
+
}
|
|
72
|
+
export default haverstack;
|
|
73
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAGH,OAAO,EAAE,mBAAmB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