@duffcloudservices/cms 0.5.1 → 0.7.1

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.
@@ -0,0 +1,248 @@
1
+ import { S as SeoConfiguration, z as BreadcrumbCrumb, F as ReviewSource, H as FaqSource, E as BlogMeta, W as ResolvedPageSeo, O as SeoSchemaConfig, G as GlobalSeoConfig, M as SeoOpenGraphConfig, N as SeoTwitterConfig } from '../vitepressTransform-y8Ru9elj.js';
2
+ export { A as AI_BOTS, x as BuildLlmsParams, w as BuildRobotsParams, B as BuildSitemapParams, C as ContentConfig, a as CreateSeoTransformPageDataOptions, D as DcsRobotsOptions, a5 as NormalisedFaq, a4 as NormalisedReview, P as PageRouteEntry, R as ResolvedPageOverrides, a6 as ReviewSchemaParts, y as SchemaObject, e as SeoPageContext, f as SeoPageTypeRule, g as VitePressHeadConfig, V as VitePressPageData, u as absolutizeUrl, n as breadcrumbTrailFromRoute, o as buildBlogPosting, m as buildBreadcrumbList, p as buildFaqPage, l as buildGlobalGraph, j as buildLlmsTxt, q as buildReviewSchemaParts, i as buildRobotsTxt, h as buildSitemapXml, b as buildVitePressSeoHead, c as createSeoTransformPageData, d as defaultRelativePathToRoute, a1 as deriveSameAs, s as filterRealFaq, r as filterRealReviews, $ as findLocalBusinessSchema, t as findReviewItemsForPage, a0 as graphAbsorbs, a2 as graphIds, a3 as isLocalBusinessType, k as isRouteIndexable, Z as loadPagesManifest, _ as parsePagesManifest, v as slugToTitle } from '../vitepressTransform-y8Ru9elj.js';
3
+ import 'vue';
4
+
5
+ /**
6
+ * Framework-agnostic SEO head-tag resolution.
7
+ *
8
+ * This module is the single source of truth for turning a
9
+ * (`pageSlug`, `pagePath`, `SeoConfiguration`) triple into a plain,
10
+ * serialisable description of the `<head>` tags a page should carry:
11
+ * resolved title, meta[], link[], and JSON-LD script[].
12
+ *
13
+ * It is consumed by:
14
+ * - `useSEO` (runtime, via `@unhead/vue`) — see `../composables/useSEO.ts`
15
+ * - `dcsSeoPlugin`'s build-time static-HTML emitter — see
16
+ * `../plugins/dcsSeoPlugin.ts`
17
+ *
18
+ * Keeping the resolution here (rather than inside the Vue composable) means
19
+ * the runtime and the build-time emitter produce byte-identical tags from the
20
+ * same `seo.yaml`, with no Vue/unhead dependency required at build time.
21
+ *
22
+ * Runtime behaviour is intentionally identical to the previous in-composable
23
+ * logic **except** for one corrected bug: `og:title` now falls back to the
24
+ * fully-resolved (template-applied) page title instead of the raw, untemplated
25
+ * `page.title`. Previously `og:title` could diverge from the `<title>` element
26
+ * (e.g. `<title>Iron Oak Contractors | Our Services</title>` but
27
+ * `og:title = "Our Services"`).
28
+ */
29
+
30
+ /** A `<meta>` tag — either a `name=`/`content=` or `property=`/`content=` pair. */
31
+ interface HeadMetaTag {
32
+ name?: string;
33
+ property?: string;
34
+ content: string;
35
+ }
36
+ /** A `<link>` tag (canonical, alternate, etc.). */
37
+ interface HeadLinkTag {
38
+ rel: string;
39
+ href: string;
40
+ hreflang?: string;
41
+ }
42
+ /** A `<script type="application/ld+json">` tag carrying serialised JSON-LD. */
43
+ interface HeadScriptTag {
44
+ type: string;
45
+ /** Pre-serialised JSON-LD string (already `JSON.stringify`-ed). */
46
+ children: string;
47
+ }
48
+ /**
49
+ * The complete, framework-agnostic set of resolved `<head>` tags for a page.
50
+ *
51
+ * - `title` is the final, template-applied title (what goes in `<title>`).
52
+ * - `meta` covers description, keywords, robots, verification, OG, Twitter.
53
+ * - `link` covers canonical + hreflang alternates.
54
+ * - `script` covers JSON-LD (global + page schemas).
55
+ * - `jsonLd` is the same JSON-LD as parsed objects, for callers that want the
56
+ * structured form (e.g. `useSEO().getSchema()`).
57
+ */
58
+ interface ResolvedHeadTags {
59
+ title: string;
60
+ meta: HeadMetaTag[];
61
+ link: HeadLinkTag[];
62
+ script: HeadScriptTag[];
63
+ jsonLd: object[];
64
+ /** The fully-resolved page SEO (merged global + page) used to build tags. */
65
+ resolved: ResolvedPageSeo;
66
+ }
67
+ /** Optional overrides applied on top of the resolved config when building tags. */
68
+ interface HeadTagOverrides {
69
+ /** Override the resolved `<title>`. */
70
+ title?: string;
71
+ /**
72
+ * Page-specific title fallback used when `seo.yaml` has no `title` for this
73
+ * page (e.g. the route `title` from `pages.yaml`). Unlike `global.defaultTitle`
74
+ * this IS run through `titleTemplate`, so un-configured routes (blog posts,
75
+ * etc.) get unique titles rather than the global default.
76
+ */
77
+ fallbackTitle?: string;
78
+ /** Override the resolved meta description. */
79
+ description?: string;
80
+ /** Override the meta keywords value. */
81
+ keywords?: string;
82
+ /**
83
+ * Force the robots directive (e.g. `'noindex, nofollow'`). When supplied this
84
+ * wins over both page- and global-level robots.
85
+ */
86
+ robots?: string;
87
+ /** Replace the JSON-LD schema objects entirely (already-built objects). */
88
+ schemas?: object[];
89
+ /** Extra meta tags appended after the generated ones. */
90
+ meta?: HeadMetaTag[];
91
+ /**
92
+ * Emit a `<meta name="keywords">` tag from the page's `keywords` field.
93
+ *
94
+ * Defaults to `false` so the `useSEO` runtime path stays byte-identical to
95
+ * its historical output (which never emitted keywords). The static-HTML
96
+ * emitter opts in (`true`) to surface page keywords in the baked `<head>`.
97
+ */
98
+ includeKeywords?: boolean;
99
+ /**
100
+ * Emit the global `@graph` spine (Organization + WebSite + the promoted
101
+ * LocalBusiness node, cross-linked by `@id`) PREPENDED before the per-schema
102
+ * JSON-LD. When true, the LocalBusiness subtype already present in
103
+ * `global.schemas` is ABSORBED into the graph (not emitted a second time).
104
+ * Default `false`.
105
+ */
106
+ emitGraph?: boolean;
107
+ /**
108
+ * Ordered Home → … → current breadcrumb trail (absolute item URLs). When it
109
+ * has more than one hop a `BreadcrumbList` is emitted; the home page (≤ 1 hop)
110
+ * emits none.
111
+ */
112
+ breadcrumbTrail?: BreadcrumbCrumb[];
113
+ /**
114
+ * REAL review items (from `.dcs/content.yaml`) for the LocalBusiness node.
115
+ * Honest Review[] + aggregateRating are emitted ONLY for items with a numeric
116
+ * rating + non-empty text + authorName; empty/missing ⇒ nothing.
117
+ */
118
+ reviews?: ReviewSource[];
119
+ /**
120
+ * Structured FAQ pairs (frontmatter `faq:` / `.dcs/faq.yaml`). A `FAQPage` is
121
+ * emitted ONLY when at least one entry has a non-empty question AND answer.
122
+ */
123
+ faq?: FaqSource[];
124
+ /**
125
+ * Blog-post metadata. When `headline` is present a `BlogPosting` is emitted —
126
+ * UNLESS the page's own schemas already hand-author a `BlogPosting` (then the
127
+ * builder defers to the authored copy to avoid duplication).
128
+ */
129
+ blogMeta?: BlogMeta;
130
+ }
131
+ /**
132
+ * Generate Open Graph meta tags from config.
133
+ *
134
+ * @param resolvedTitle - the final, template-applied page title. Used as the
135
+ * `og:title` fallback so OG stays consistent with `<title>`.
136
+ */
137
+ declare function generateOpenGraphMeta(og: SeoOpenGraphConfig, global: GlobalSeoConfig, resolvedTitle: string, pageDescription: string, canonical: string): Array<{
138
+ property: string;
139
+ content: string;
140
+ }>;
141
+ /**
142
+ * Generate Twitter Card meta tags from config.
143
+ *
144
+ * @param resolvedTitle - the final, template-applied page title (Twitter title
145
+ * fallback), mirroring the OG behaviour.
146
+ */
147
+ declare function generateTwitterMeta(twitter: SeoTwitterConfig, global: GlobalSeoConfig, resolvedTitle: string, pageDescription: string): Array<{
148
+ name: string;
149
+ content: string;
150
+ }>;
151
+ /**
152
+ * Generate JSON-LD schema objects from schema configs, auto-populating common
153
+ * WebSite properties from global config.
154
+ */
155
+ declare function generateJsonLd(schemas: SeoSchemaConfig[], global: GlobalSeoConfig): object[];
156
+ /**
157
+ * Resolve page SEO by merging global defaults with page-specific config.
158
+ *
159
+ * Behavioural changes from the historical in-composable version (both bug
160
+ * fixes):
161
+ * 1. `openGraph.title` falls back to the **template-applied** page title, not
162
+ * the raw `page.title`, so `og:title` matches `<title>`.
163
+ * 2. The `titleTemplate` is applied **only** to a page-specific title
164
+ * (`page.title`, or the `fallbackTitle` arg). It is no longer applied to
165
+ * `global.defaultTitle`, which is already the complete brand title —
166
+ * templating it produced `"Brand | Default Title | Brand"` doubling on any
167
+ * page without its own `seo.yaml` entry.
168
+ *
169
+ * @param fallbackTitle - a page-specific title to use when `seo.yaml` has no
170
+ * `title` for this page (e.g. the route `title` from `pages.yaml`). It IS run
171
+ * through `titleTemplate`; `global.defaultTitle` is the last resort and is not.
172
+ */
173
+ declare function resolvePageSeo(pageSlug: string, pagePath: string | undefined, seoConfig: SeoConfiguration | undefined, fallbackTitle?: string): ResolvedPageSeo;
174
+ /**
175
+ * Build the complete, framework-agnostic set of `<head>` tags for a page.
176
+ *
177
+ * This is the function both the `useSEO` runtime and the build-time emitter
178
+ * call, guaranteeing identical output. Pass `overrides` to mirror the
179
+ * composable's `applyHead(overrides)` behaviour, or to force `robots` (used by
180
+ * the emitter's `noindex` option).
181
+ */
182
+ declare function buildHeadTags(pageSlug: string, pagePath: string | undefined, seoConfig: SeoConfiguration | undefined, overrides?: HeadTagOverrides): ResolvedHeadTags;
183
+
184
+ /**
185
+ * Pure, framework-free `<head>` splicing for the build-time SEO emitter.
186
+ *
187
+ * Given a built `index.html` shell and a set of resolved head tags (from
188
+ * `buildHeadTags`), this produces a new HTML string where the SEO-managed
189
+ * tags — `<title>`, `description`, `keywords`, `robots`, `canonical`,
190
+ * verification, all `og:*` / `article:*` properties, all `twitter:*` names,
191
+ * and `application/ld+json` scripts — have been **replaced** (not duplicated)
192
+ * with the resolved set.
193
+ *
194
+ * Design goals:
195
+ * - **Idempotent**: running it twice yields the same output (it strips the
196
+ * managed tags first, then re-inserts the canonical set).
197
+ * - **Deterministic**: tag order is fixed by `renderHeadTags`.
198
+ * - **Conservative**: only tags we own are touched. Charset, viewport, CSP,
199
+ * theme-color, favicons, stylesheets, and the app script are left intact.
200
+ *
201
+ * This is intentionally regex-based (no DOM dependency) to mirror the existing
202
+ * `dcsCdnImagePlugin` post-build HTML rewriting and to keep the emitter free of
203
+ * heavy parser deps at build time.
204
+ */
205
+
206
+ /**
207
+ * Escape a JSON-LD string for safe inclusion inside an HTML `<script>` element.
208
+ *
209
+ * A `<script type="application/ld+json">` is a DATA block, but the HTML parser
210
+ * still scans its raw text for `</script` (and `<!--`) — so untrusted CMS free
211
+ * text (review bodies, FAQ Q&A, blog descriptions) carrying `</script>` could
212
+ * break out of the script and inject markup (stored XSS).
213
+ *
214
+ * Per OWASP "JSON in an HTML context", we escape the three HTML-significant
215
+ * characters as their `\uXXXX` JSON escapes. Because these characters only ever
216
+ * appear INSIDE JSON string literals (never as JSON structure), the result is
217
+ * still byte-for-byte valid JSON that `JSON.parse` round-trips:
218
+ * `<` → `<` (defeats `</script>` and `<!--` breakout)
219
+ * `>` → `>`
220
+ * `&` → `&`
221
+ *
222
+ * Exported so BOTH static-SEO sinks (the SPA `spliceHeadHtml` path AND the
223
+ * VitePress `transformPageData` head emit) share one guard.
224
+ */
225
+ declare function escapeJsonLd(json: string): string;
226
+ /**
227
+ * Render the resolved head tags to a deterministic HTML fragment.
228
+ * Order: title, meta (in the order produced by buildHeadTags), link, script.
229
+ */
230
+ declare function renderHeadTags(tags: ResolvedHeadTags, indent?: string): string;
231
+ /**
232
+ * Strip the SEO-managed tags from a `<head>` block so they can be re-inserted
233
+ * without duplication. Operates only within `<head>...</head>` to avoid
234
+ * touching body content.
235
+ */
236
+ declare function stripManagedHeadTags(html: string): string;
237
+ /**
238
+ * Splice resolved SEO head tags into an HTML document.
239
+ *
240
+ * Strips the existing managed tags, then inserts the rendered canonical set
241
+ * immediately before `</head>`. If no `<head>` is present the HTML is returned
242
+ * unchanged (defensive — the emitter logs and no-ops in that case).
243
+ *
244
+ * Idempotent: applying twice produces identical output.
245
+ */
246
+ declare function spliceHeadHtml(html: string, tags: ResolvedHeadTags): string;
247
+
248
+ export { BlogMeta, BreadcrumbCrumb, FaqSource, type HeadLinkTag, type HeadMetaTag, type HeadScriptTag, type HeadTagOverrides, type ResolvedHeadTags, ReviewSource, buildHeadTags, escapeJsonLd, generateJsonLd, generateOpenGraphMeta, generateTwitterMeta, renderHeadTags, resolvePageSeo, spliceHeadHtml, stripManagedHeadTags };
@@ -0,0 +1,4 @@
1
+ import '../chunk-KCWMS7P4.js';
2
+ export { AI_BOTS, absolutizeUrl, breadcrumbTrailFromRoute, buildBlogPosting, buildBreadcrumbList, buildFaqPage, buildGlobalGraph, buildHeadTags, buildLlmsTxt, buildReviewSchemaParts, buildRobotsTxt, buildSitemapXml, buildVitePressSeoHead, createSeoTransformPageData, defaultRelativePathToRoute, deriveSameAs, escapeJsonLd, filterRealFaq, filterRealReviews, findLocalBusinessSchema, findReviewItemsForPage, generateJsonLd, generateOpenGraphMeta, generateTwitterMeta, graphAbsorbs, graphIds, isLocalBusinessType, isRouteIndexable, loadPagesManifest, parsePagesManifest, renderHeadTags, resolvePageSeo, slugToTitle, spliceHeadHtml, stripManagedHeadTags } from '../chunk-FUNIALH6.js';
3
+ //# sourceMappingURL=index.js.map
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}