mentionwell 1.2.0 → 1.4.2
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 +13 -14
- package/dist/api-reader.d.ts +59 -5
- package/dist/api-reader.d.ts.map +1 -1
- package/dist/api-reader.js +9 -8
- package/dist/api-reader.js.map +1 -1
- package/dist/html-utils.d.ts +12 -1
- package/dist/html-utils.d.ts.map +1 -1
- package/dist/html-utils.js +15 -2
- package/dist/html-utils.js.map +1 -1
- package/dist/mentionwell-article.css +22 -6
- package/package.json +7 -10
- package/dist/index.d.ts +0 -72
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -104
- package/dist/index.js.map +0 -1
package/README.md
CHANGED
|
@@ -19,7 +19,7 @@ import {
|
|
|
19
19
|
} from 'mentionwell/api'
|
|
20
20
|
|
|
21
21
|
const config = {
|
|
22
|
-
apiUrl: process.env.
|
|
22
|
+
apiUrl: process.env.MENTIONWELL_API_URL!,
|
|
23
23
|
apiKey: process.env.MENTIONWELL_API_KEY!,
|
|
24
24
|
siteSlug: process.env.MENTIONWELL_SITE_SLUG!
|
|
25
25
|
}
|
|
@@ -35,7 +35,8 @@ import 'mentionwell/styles'
|
|
|
35
35
|
import {
|
|
36
36
|
prepareArticleHtml,
|
|
37
37
|
extractTocHtml,
|
|
38
|
-
stripTocFromArticle
|
|
38
|
+
stripTocFromArticle,
|
|
39
|
+
stripPlatformChrome
|
|
39
40
|
} from 'mentionwell/html-utils'
|
|
40
41
|
import { fetchBlogPost } from '@/lib/blogoto-blog'
|
|
41
42
|
|
|
@@ -119,25 +120,23 @@ Returns one published post from the hosted API, or `null`.
|
|
|
119
120
|
|
|
120
121
|
Returns every published slug from the hosted API. Useful for sitemaps.
|
|
121
122
|
|
|
122
|
-
### `
|
|
123
|
+
### `getBlogPostSummariesViaApi(config)`
|
|
123
124
|
|
|
124
|
-
|
|
125
|
+
Returns slug + updated/published timestamps for published posts returned by the hosted API. Useful for sitemap last-modified.
|
|
125
126
|
|
|
126
|
-
### `
|
|
127
|
-
|
|
128
|
-
Returns one published post, or `null`.
|
|
129
|
-
|
|
130
|
-
### `getAllBlogSlugs(config)`
|
|
127
|
+
### `prepareArticleHtml(html)`
|
|
131
128
|
|
|
132
|
-
|
|
129
|
+
Strips duplicate chrome blocks (`<header class="wb-header">`, `<figure class="wb-hero">`) and any leaked `[CTA]` placeholder tokens from the article HTML before injection.
|
|
133
130
|
|
|
134
|
-
|
|
131
|
+
Pass `{ stripPlatformChrome: true }` when your template renders its own TL;DR, TOC, FAQ, CTA, or author blocks from structured API fields:
|
|
135
132
|
|
|
136
|
-
|
|
133
|
+
```ts
|
|
134
|
+
const html = prepareArticleHtml(post.html, { stripPlatformChrome: true })
|
|
135
|
+
```
|
|
137
136
|
|
|
138
|
-
### `
|
|
137
|
+
### `stripPlatformChrome(html)`
|
|
139
138
|
|
|
140
|
-
|
|
139
|
+
Removes the platform-rendered TL;DR, TOC, FAQ, CTA, author, header, and hero blocks while preserving body-only blocks such as callouts, tables, quotes, citations, steps, and embeds.
|
|
141
140
|
|
|
142
141
|
### `extractTocHtml(html)` / `stripTocFromArticle(html)`
|
|
143
142
|
|
package/dist/api-reader.d.ts
CHANGED
|
@@ -13,7 +13,59 @@
|
|
|
13
13
|
* surfaced in the Blogoto dashboard's integration page (deterministically
|
|
14
14
|
* derived from siteId + READER_API_SECRET, prefix `bgo_read_`).
|
|
15
15
|
*/
|
|
16
|
-
|
|
16
|
+
export interface ReaderAuthor {
|
|
17
|
+
id: string;
|
|
18
|
+
name: string;
|
|
19
|
+
title?: string;
|
|
20
|
+
bio?: string;
|
|
21
|
+
avatarUrl?: string;
|
|
22
|
+
url?: string;
|
|
23
|
+
twitter?: string;
|
|
24
|
+
linkedin?: string;
|
|
25
|
+
}
|
|
26
|
+
export interface ReaderFaq {
|
|
27
|
+
question: string;
|
|
28
|
+
answer: string;
|
|
29
|
+
}
|
|
30
|
+
export interface ReaderTocEntry {
|
|
31
|
+
title: string;
|
|
32
|
+
id: string;
|
|
33
|
+
level: 2 | 3;
|
|
34
|
+
}
|
|
35
|
+
export interface ReaderPost {
|
|
36
|
+
id: string;
|
|
37
|
+
slug: string;
|
|
38
|
+
title: string;
|
|
39
|
+
metaTitle?: string;
|
|
40
|
+
metaDescription?: string;
|
|
41
|
+
excerpt: string;
|
|
42
|
+
html: string;
|
|
43
|
+
markdown?: string;
|
|
44
|
+
featuredImage?: string;
|
|
45
|
+
readingTime?: number;
|
|
46
|
+
tags: string[];
|
|
47
|
+
category?: {
|
|
48
|
+
title: string;
|
|
49
|
+
slug: string;
|
|
50
|
+
} | null;
|
|
51
|
+
relatedPosts: Array<{
|
|
52
|
+
id: string;
|
|
53
|
+
title: string;
|
|
54
|
+
slug: string;
|
|
55
|
+
}>;
|
|
56
|
+
publishedAt?: string;
|
|
57
|
+
updatedAt?: string;
|
|
58
|
+
author?: ReaderAuthor;
|
|
59
|
+
tldr?: {
|
|
60
|
+
items: string[];
|
|
61
|
+
};
|
|
62
|
+
toc?: ReaderTocEntry[];
|
|
63
|
+
faqs?: ReaderFaq[];
|
|
64
|
+
schema?: {
|
|
65
|
+
jsonLd: string;
|
|
66
|
+
};
|
|
67
|
+
canonicalUrl?: string;
|
|
68
|
+
}
|
|
17
69
|
export interface BlogotoApiConfig {
|
|
18
70
|
/** Base URL of the Mentionwell instance, e.g. https://app.mentionwell.com */
|
|
19
71
|
apiUrl: string;
|
|
@@ -27,10 +79,12 @@ export interface BlogotoApiConfig {
|
|
|
27
79
|
/**
|
|
28
80
|
* Fetches a paginated list of published posts for the configured site.
|
|
29
81
|
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
82
|
+
* Always fetches the full list (`?limit=100`, the API's own cap) on each
|
|
83
|
+
* call and slices locally. This trades a slightly larger response for
|
|
84
|
+
* correct `total`/`totalPages` numbers — the previous behavior fetched
|
|
85
|
+
* only `perPage * page` rows and reported the slice size as `total`,
|
|
86
|
+
* which silently hid every page past the first. Sites with >100 posts
|
|
87
|
+
* need server-side `?page=` support; bump this package once that lands.
|
|
34
88
|
*/
|
|
35
89
|
export declare function getBlogPostsViaApi(config: BlogotoApiConfig, page?: number, perPage?: number): Promise<{
|
|
36
90
|
posts: ReaderPost[];
|
package/dist/api-reader.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api-reader.d.ts","sourceRoot":"","sources":["../src/api-reader.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"api-reader.d.ts","sourceRoot":"","sources":["../src/api-reader.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,SAAS;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,CAAC,GAAG,CAAC,CAAC;CACd;AAED,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,OAAO,EAAE,MAAM,CAAC;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CAAA;CAAE,CAAC,CAmBrE;AAED,wBAAsB,iBAAiB,CACrC,MAAM,EAAE,gBAAgB,EACxB,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC,CAa5B;AAED,wBAAsB,qBAAqB,CAAC,MAAM,EAAE,gBAAgB,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAOvF;AAED,wBAAsB,0BAA0B,CAC9C,MAAM,EAAE,gBAAgB,GACvB,OAAO,CAAC,KAAK,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC,CAW5E"}
|
package/dist/api-reader.js
CHANGED
|
@@ -71,21 +71,22 @@ async function callApi(config, path, init) {
|
|
|
71
71
|
/**
|
|
72
72
|
* Fetches a paginated list of published posts for the configured site.
|
|
73
73
|
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
*
|
|
74
|
+
* Always fetches the full list (`?limit=100`, the API's own cap) on each
|
|
75
|
+
* call and slices locally. This trades a slightly larger response for
|
|
76
|
+
* correct `total`/`totalPages` numbers — the previous behavior fetched
|
|
77
|
+
* only `perPage * page` rows and reported the slice size as `total`,
|
|
78
|
+
* which silently hid every page past the first. Sites with >100 posts
|
|
79
|
+
* need server-side `?page=` support; bump this package once that lands.
|
|
78
80
|
*/
|
|
79
81
|
export async function getBlogPostsViaApi(config, page = 1, perPage = 12) {
|
|
80
|
-
const
|
|
81
|
-
const data = await callApi(config, `/api/public/${encodeURIComponent(config.siteSlug)}/posts?limit=${limit}`);
|
|
82
|
+
const data = await callApi(config, `/api/public/${encodeURIComponent(config.siteSlug)}/posts?limit=100`);
|
|
82
83
|
if (!data.ok || !data.posts) {
|
|
83
|
-
throw new Error(`
|
|
84
|
+
throw new Error(`Mentionwell API returned not-ok for ${config.siteSlug}: ${data.message ?? "unknown"}`);
|
|
84
85
|
}
|
|
85
86
|
const all = data.posts.map(toReader);
|
|
87
|
+
const total = all.length;
|
|
86
88
|
const from = (page - 1) * perPage;
|
|
87
89
|
const slice = all.slice(from, from + perPage);
|
|
88
|
-
const total = all.length;
|
|
89
90
|
return {
|
|
90
91
|
posts: slice,
|
|
91
92
|
total,
|
package/dist/api-reader.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api-reader.js","sourceRoot":"","sources":["../src/api-reader.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;
|
|
1
|
+
{"version":3,"file":"api-reader.js","sourceRoot":"","sources":["../src/api-reader.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AA8FH,SAAS,OAAO,CAAC,GAAW;IAC1B,OAAO,GAAG,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;AACjC,CAAC;AAED,SAAS,QAAQ,CAAC,IAAa;IAC7B,OAAO;QACL,sEAAsE;QACtE,6DAA6D;QAC7D,EAAE,EAAE,IAAI,CAAC,IAAI;QACb,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,KAAK,EAAE,IAAI,CAAC,KAAK;QACjB,SAAS,EAAE,IAAI,CAAC,SAAS;QACzB,eAAe,EAAE,IAAI,CAAC,eAAe;QACrC,OAAO,EAAE,IAAI,CAAC,OAAO,IAAI,EAAE;QAC3B,IAAI,EAAE,IAAI,CAAC,IAAI,IAAI,EAAE;QACrB,QAAQ,EAAE,IAAI,CAAC,QAAQ;QACvB,aAAa,EAAE,IAAI,CAAC,aAAa,IAAI,SAAS;QAC9C,WAAW,EAAE,IAAI,CAAC,WAAW;QAC7B,IAAI,EAAE,IAAI,CAAC,IAAI,IAAI,EAAE;QACrB,QAAQ,EAAE,IAAI,CAAC,QAAQ,IAAI,IAAI;QAC/B,YAAY,EAAE,EAAE;QAChB,WAAW,EAAE,IAAI,CAAC,WAAW,IAAI,SAAS;QAC1C,SAAS,EAAE,IAAI,CA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WAAW,EAAE,CAAC,CAAC,WAAW,IAAI,SAAS;KACxC,CAAC,CAAC,CAAC;AACN,CAAC"}
|
package/dist/html-utils.d.ts
CHANGED
|
@@ -19,6 +19,17 @@ export declare function stripDuplicateChrome(html: string): string;
|
|
|
19
19
|
export declare function stripLegacyCtaLeaks(html: string): string;
|
|
20
20
|
export declare function extractTocHtml(html: string): string | null;
|
|
21
21
|
export declare function stripTocFromArticle(html: string): string;
|
|
22
|
+
export declare function stripPlatformChrome(html: string): string;
|
|
23
|
+
export interface PrepareArticleHtmlOptions {
|
|
24
|
+
/**
|
|
25
|
+
* Use when the destination template renders TL;DR, TOC, FAQ, CTA, or
|
|
26
|
+
* author blocks from structured API fields. Body-only platform blocks
|
|
27
|
+
* such as callouts, tables, quotes, steps, citations, and embeds remain.
|
|
28
|
+
*/
|
|
29
|
+
stripPlatformChrome?: boolean;
|
|
30
|
+
/** Move the inline platform TOC into a separate sidebar with extractTocHtml. */
|
|
31
|
+
stripToc?: boolean;
|
|
32
|
+
}
|
|
22
33
|
/** Convenience: apply all the safe transforms in one call. */
|
|
23
|
-
export declare function prepareArticleHtml(html: string): string;
|
|
34
|
+
export declare function prepareArticleHtml(html: string, options?: PrepareArticleHtmlOptions): string;
|
|
24
35
|
//# sourceMappingURL=html-utils.d.ts.map
|
package/dist/html-utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"html-utils.d.ts","sourceRoot":"","sources":["../src/html-utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAKzD;AAED,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAKxD;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAG1D;AAED,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAExD;AAED,8DAA8D;AAC9D,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"html-utils.d.ts","sourceRoot":"","sources":["../src/html-utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAKzD;AAED,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAKxD;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAG1D;AAED,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAExD;AAED,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAOxD;AAED,MAAM,WAAW,yBAAyB;IACxC;;;;OAIG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,gFAAgF;IAChF,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,8DAA8D;AAC9D,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,yBAA8B,GAAG,MAAM,CAKhG"}
|
package/dist/html-utils.js
CHANGED
|
@@ -34,8 +34,21 @@ export function extractTocHtml(html) {
|
|
|
34
34
|
export function stripTocFromArticle(html) {
|
|
35
35
|
return html.replace(/<nav class="wb-toc"[\s\S]*?<\/nav>/, "");
|
|
36
36
|
}
|
|
37
|
+
export function stripPlatformChrome(html) {
|
|
38
|
+
return stripDuplicateChrome(html)
|
|
39
|
+
.replace(/<aside\b[^>]*class="[^"]*\bwb-tldr\b[^"]*"[^>]*>[\s\S]*?<\/aside>/gi, "")
|
|
40
|
+
.replace(/<section\b[^>]*class="[^"]*\bwb-faq\b[^"]*"[^>]*>[\s\S]*?<\/section>/gi, "")
|
|
41
|
+
.replace(/<aside\b[^>]*class="[^"]*\bwb-(?:cta|footer-cta)\b[^"]*"[^>]*>[\s\S]*?<\/aside>/gi, "")
|
|
42
|
+
.replace(/<aside\b[^>]*class="[^"]*\bwb-author\b[^"]*"[^>]*>[\s\S]*?<\/aside>/gi, "")
|
|
43
|
+
.replace(/<nav\b[^>]*class="[^"]*\bwb-toc\b[^"]*"[^>]*>[\s\S]*?<\/nav>/gi, "");
|
|
44
|
+
}
|
|
37
45
|
/** Convenience: apply all the safe transforms in one call. */
|
|
38
|
-
export function prepareArticleHtml(html) {
|
|
39
|
-
|
|
46
|
+
export function prepareArticleHtml(html, options = {}) {
|
|
47
|
+
let next = stripLegacyCtaLeaks(stripDuplicateChrome(html));
|
|
48
|
+
if (options.stripPlatformChrome)
|
|
49
|
+
next = stripPlatformChrome(next);
|
|
50
|
+
if (options.stripToc)
|
|
51
|
+
next = stripTocFromArticle(next);
|
|
52
|
+
return next;
|
|
40
53
|
}
|
|
41
54
|
//# sourceMappingURL=html-utils.js.map
|
package/dist/html-utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"html-utils.js","sourceRoot":"","sources":["../src/html-utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,MAAM,UAAU,oBAAoB,CAAC,IAAY;IAC/C,OAAO,IAAI;SACR,OAAO,CAAC,8CAA8C,EAAE,EAAE,CAAC;SAC3D,OAAO,CAAC,4CAA4C,EAAE,EAAE,CAAC;SACzD,OAAO,CAAC,gDAAgD,EAAE,EAAE,CAAC,CAAC;AACnE,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,IAAY;IAC9C,OAAO,IAAI;SACR,OAAO,CAAC,yDAAyD,EAAE,EAAE,CAAC;SACtE,OAAO,CAAC,kCAAkC,EAAE,EAAE,CAAC;SAC/C,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;AAC7B,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,IAAY;IACzC,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,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C9B,OAAO,CAAC,qEAAqE,EAAE,EAAE,CAAC;SAClF,OAAO,CAAC,wEAAwE,EAAE,EAAE,CAAC;SACrF,OAAO,CAAC,mFAAmF,EAAE,EAAE,CAAC;SAChG,OAAO,CAAC,uEAAuE,EAAE,EAAE,CAAC;SACpF,OAAO,CAAC,gEAAgE,EAAE,EAAE,CAAC,CAAC;AACnF,CAAC;AAaD,8DAA8D;AAC9D,MAAM,UAAU,kBAAkB,CAAC,IAAY,EAAE,UAAqC,EAAE;IACtF,IAAI,IAAI,GAAG,mBAAmB,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAAC,CAAC;IAC3D,IAAI,OAAO,CAAC,mBAAmB;QAAE,IAAI,GAAG,mBAAmB,CAAC,IAAI,CAAC,CAAC;IAClE,IAAI,OAAO,CAAC,QAAQ;QAAE,IAAI,GAAG,mBAAmB,CAAC,IAAI,CAAC,CAAC;IACvD,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -472,19 +472,26 @@
|
|
|
472
472
|
under a sticky sidebar CTA). `display: block` is what makes overflow-x
|
|
473
473
|
actually work — `display: table` ignores `overflow` on itself. */
|
|
474
474
|
.wb-article-host table {
|
|
475
|
-
|
|
475
|
+
/* Real table layout so cells stretch to fill the container width.
|
|
476
|
+
`display: block` (the previous attempt at making the table scroll
|
|
477
|
+
horizontally) caused the inner table layout to collapse to its
|
|
478
|
+
content width, leaving a large empty band on the right side of the
|
|
479
|
+
bordered region. We rely on `table-layout: auto` + `width: 100%`
|
|
480
|
+
so columns fill the article column instead. Mobile horizontal
|
|
481
|
+
scroll is handled below by giving the table its own scroll wrapper
|
|
482
|
+
via the `display` switch only at narrow breakpoints. */
|
|
483
|
+
display: table;
|
|
476
484
|
width: 100%;
|
|
477
485
|
max-width: 100%;
|
|
478
|
-
|
|
479
|
-
-webkit-overflow-scrolling: touch;
|
|
486
|
+
table-layout: auto;
|
|
480
487
|
border-collapse: collapse;
|
|
481
488
|
margin: 2rem 0;
|
|
482
489
|
font-size: 0.95rem;
|
|
483
490
|
background: var(--wb-paper);
|
|
484
|
-
/* Stronger border so the table is visible against paper-tone page bgs. */
|
|
485
491
|
border: 1px solid #B7AEA1;
|
|
486
492
|
border-radius: var(--wb-radius-sm);
|
|
487
493
|
box-shadow: 0 1px 0 rgba(0, 0, 0, 0.03);
|
|
494
|
+
overflow: hidden;
|
|
488
495
|
}
|
|
489
496
|
/* Forest-green header with cream text. !important guards defeat host
|
|
490
497
|
themes that set a generic cream/light bg on `.blog-content th` and
|
|
@@ -522,7 +529,14 @@
|
|
|
522
529
|
/* Mobile: tighten table cells. (Horizontal scroll is already enabled at
|
|
523
530
|
all breakpoints in the base table rule above.) */
|
|
524
531
|
@media (max-width: 640px) {
|
|
532
|
+
/* On narrow screens, allow the table to scroll horizontally inside the
|
|
533
|
+
article column rather than overflowing the page. `display: block` here
|
|
534
|
+
lets `overflow-x: auto` actually take effect (which it can't on a
|
|
535
|
+
`display: table` element). */
|
|
525
536
|
.wb-article-host table {
|
|
537
|
+
display: block;
|
|
538
|
+
overflow-x: auto;
|
|
539
|
+
-webkit-overflow-scrolling: touch;
|
|
526
540
|
font-size: 0.88rem;
|
|
527
541
|
}
|
|
528
542
|
.wb-article-host thead th, .wb-article-host tbody td {
|
|
@@ -766,17 +780,19 @@
|
|
|
766
780
|
.wb-breadcrumbs [aria-current="page"] { color: #1A1916; font-weight: 500; }
|
|
767
781
|
|
|
768
782
|
.wb-sticky-toc {
|
|
769
|
-
position: sticky; top: 6rem; align-self: start;
|
|
783
|
+
position: sticky; top: var(--wb-sticky-top, 6rem); align-self: start;
|
|
770
784
|
max-height: calc(100vh - 8rem); overflow-y: auto;
|
|
771
785
|
padding-right: 0.5rem;
|
|
786
|
+
z-index: 1;
|
|
772
787
|
}
|
|
773
788
|
@media (max-width: 1023px) { .wb-sticky-toc { display: none; } }
|
|
774
789
|
|
|
775
790
|
.wb-sticky-cta {
|
|
776
|
-
position: sticky; top: 6rem; align-self: start;
|
|
791
|
+
position: sticky; top: var(--wb-sticky-top, 6rem); align-self: start;
|
|
777
792
|
background: #232820; color: #FAF7F2;
|
|
778
793
|
border-radius: 12px; padding: 1.25rem 1.35rem;
|
|
779
794
|
font-family: var(--wb-font-body);
|
|
795
|
+
z-index: 1;
|
|
780
796
|
}
|
|
781
797
|
.wb-sticky-cta-eyebrow {
|
|
782
798
|
display: block; font-size: 0.7rem; font-weight: 600;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mentionwell",
|
|
3
|
-
"version": "1.2
|
|
3
|
+
"version": "1.4.2",
|
|
4
4
|
"description": "Destination-side API reader + styles for Mentionwell-generated blog posts.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Isaac Horowitz <horowitzisaac@gmail.com>",
|
|
@@ -18,13 +18,13 @@
|
|
|
18
18
|
"mentionwell"
|
|
19
19
|
],
|
|
20
20
|
"type": "module",
|
|
21
|
-
"main": "./dist/
|
|
22
|
-
"module": "./dist/
|
|
23
|
-
"types": "./dist/
|
|
21
|
+
"main": "./dist/api-reader.js",
|
|
22
|
+
"module": "./dist/api-reader.js",
|
|
23
|
+
"types": "./dist/api-reader.d.ts",
|
|
24
24
|
"exports": {
|
|
25
25
|
".": {
|
|
26
|
-
"types": "./dist/
|
|
27
|
-
"import": "./dist/
|
|
26
|
+
"types": "./dist/api-reader.d.ts",
|
|
27
|
+
"import": "./dist/api-reader.js"
|
|
28
28
|
},
|
|
29
29
|
"./html-utils": {
|
|
30
30
|
"types": "./dist/html-utils.d.ts",
|
|
@@ -48,10 +48,7 @@
|
|
|
48
48
|
"publishConfig": {
|
|
49
49
|
"access": "public"
|
|
50
50
|
},
|
|
51
|
-
"dependencies": {
|
|
52
|
-
"@supabase/supabase-js": "^2.49.8"
|
|
53
|
-
},
|
|
54
51
|
"devDependencies": {
|
|
55
|
-
"typescript": "^
|
|
52
|
+
"typescript": "^6.0.3"
|
|
56
53
|
}
|
|
57
54
|
}
|
package/dist/index.d.ts
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
export interface BlogReaderConfig {
|
|
2
|
-
supabaseUrl: string;
|
|
3
|
-
supabaseAnonKey: string;
|
|
4
|
-
siteSlug: string;
|
|
5
|
-
table?: string;
|
|
6
|
-
}
|
|
7
|
-
export interface ReaderAuthor {
|
|
8
|
-
id: string;
|
|
9
|
-
name: string;
|
|
10
|
-
title?: string;
|
|
11
|
-
bio?: string;
|
|
12
|
-
avatarUrl?: string;
|
|
13
|
-
url?: string;
|
|
14
|
-
twitter?: string;
|
|
15
|
-
linkedin?: string;
|
|
16
|
-
}
|
|
17
|
-
export interface ReaderFaq {
|
|
18
|
-
question: string;
|
|
19
|
-
answer: string;
|
|
20
|
-
}
|
|
21
|
-
export interface ReaderTocEntry {
|
|
22
|
-
title: string;
|
|
23
|
-
id: string;
|
|
24
|
-
level: 2 | 3;
|
|
25
|
-
}
|
|
26
|
-
export interface ReaderPost {
|
|
27
|
-
id: string;
|
|
28
|
-
slug: string;
|
|
29
|
-
title: string;
|
|
30
|
-
metaTitle?: string;
|
|
31
|
-
metaDescription?: string;
|
|
32
|
-
excerpt: string;
|
|
33
|
-
html: string;
|
|
34
|
-
markdown?: string;
|
|
35
|
-
featuredImage?: string;
|
|
36
|
-
readingTime?: number;
|
|
37
|
-
tags: string[];
|
|
38
|
-
category?: {
|
|
39
|
-
title: string;
|
|
40
|
-
slug: string;
|
|
41
|
-
} | null;
|
|
42
|
-
relatedPosts: Array<{
|
|
43
|
-
id: string;
|
|
44
|
-
title: string;
|
|
45
|
-
slug: string;
|
|
46
|
-
}>;
|
|
47
|
-
publishedAt?: string;
|
|
48
|
-
updatedAt?: string;
|
|
49
|
-
author?: ReaderAuthor;
|
|
50
|
-
tldr?: {
|
|
51
|
-
items: string[];
|
|
52
|
-
};
|
|
53
|
-
toc?: ReaderTocEntry[];
|
|
54
|
-
faqs?: ReaderFaq[];
|
|
55
|
-
schema?: {
|
|
56
|
-
jsonLd: string;
|
|
57
|
-
};
|
|
58
|
-
canonicalUrl?: string;
|
|
59
|
-
}
|
|
60
|
-
export declare function getBlogPosts(config: BlogReaderConfig, page?: number, perPage?: number): Promise<{
|
|
61
|
-
posts: ReaderPost[];
|
|
62
|
-
total: number;
|
|
63
|
-
totalPages: number;
|
|
64
|
-
}>;
|
|
65
|
-
export declare function getBlogPost(config: BlogReaderConfig, slug: string): Promise<ReaderPost | null>;
|
|
66
|
-
export declare function getAllBlogSlugs(config: BlogReaderConfig): Promise<string[]>;
|
|
67
|
-
export declare function getBlogPostSummaries(config: BlogReaderConfig): Promise<Array<{
|
|
68
|
-
slug: string;
|
|
69
|
-
updatedAt?: string;
|
|
70
|
-
publishedAt?: string;
|
|
71
|
-
}>>;
|
|
72
|
-
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,gBAAgB;IAC/B,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,EAAE,MAAM,CAAC;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,SAAS;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,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MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,CAAC,CAuBrE;AAED,wBAAsB,WAAW,CAC/B,MAAM,EAAE,gBAAgB,EACxB,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC,CAiB5B;AAED,wBAAsB,eAAe,CAAC,MAAM,EAAE,gBAAgB,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAejF;AAED,wBAAsB,oBAAoB,CACxC,MAAM,EAAE,gBAAgB,GACvB,OAAO,CAAC,KAAK,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC,CAsB5E"}
|
package/dist/index.js
DELETED
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
import { createClient } from "@supabase/supabase-js";
|
|
2
|
-
function getClient(config) {
|
|
3
|
-
return createClient(config.supabaseUrl, config.supabaseAnonKey);
|
|
4
|
-
}
|
|
5
|
-
const SELECT_COLUMNS = "id, slug, title, meta_title, meta_description, excerpt, html, markdown, featured_image, reading_time, tags, category, related_posts, published_at, updated_at, author, tldr, toc, faqs, schema, canonical_url";
|
|
6
|
-
function toReaderPost(row) {
|
|
7
|
-
return {
|
|
8
|
-
id: String(row.id),
|
|
9
|
-
slug: String(row.slug),
|
|
10
|
-
title: String(row.title),
|
|
11
|
-
metaTitle: (row.meta_title ?? row.metaTitle),
|
|
12
|
-
metaDescription: (row.meta_description ?? row.metaDescription),
|
|
13
|
-
excerpt: String(row.excerpt ?? ""),
|
|
14
|
-
html: String(row.html ?? ""),
|
|
15
|
-
markdown: (row.markdown ?? ""),
|
|
16
|
-
featuredImage: (row.featured_image ?? row.featuredImage),
|
|
17
|
-
readingTime: (row.reading_time ?? row.readingTime),
|
|
18
|
-
tags: row.tags ?? [],
|
|
19
|
-
category: row.category ?? null,
|
|
20
|
-
relatedPosts: (row.related_posts ?? row.relatedPosts) ?? [],
|
|
21
|
-
publishedAt: (row.published_at ?? row.publishedAt),
|
|
22
|
-
updatedAt: (row.updated_at ?? row.updatedAt),
|
|
23
|
-
author: row.author ?? undefined,
|
|
24
|
-
tldr: row.tldr ?? undefined,
|
|
25
|
-
toc: row.toc ?? undefined,
|
|
26
|
-
faqs: row.faqs ?? undefined,
|
|
27
|
-
schema: row.schema ?? undefined,
|
|
28
|
-
canonicalUrl: (row.canonical_url ?? row.canonicalUrl)
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
export async function getBlogPosts(config, page = 1, perPage = 12) {
|
|
32
|
-
const client = getClient(config);
|
|
33
|
-
const from = (page - 1) * perPage;
|
|
34
|
-
const to = from + perPage - 1;
|
|
35
|
-
const table = config.table ?? "blog_posts";
|
|
36
|
-
const { data, count, error } = await client
|
|
37
|
-
.from(table)
|
|
38
|
-
.select(SELECT_COLUMNS, { count: "exact" })
|
|
39
|
-
.eq("published", true)
|
|
40
|
-
.eq("site_slug", config.siteSlug)
|
|
41
|
-
.order("published_at", { ascending: false })
|
|
42
|
-
.range(from, to);
|
|
43
|
-
if (error) {
|
|
44
|
-
throw new Error(`Failed to fetch posts for ${config.siteSlug}: ${error.message}`);
|
|
45
|
-
}
|
|
46
|
-
return {
|
|
47
|
-
posts: (data ?? []).map(toReaderPost),
|
|
48
|
-
total: count ?? 0,
|
|
49
|
-
totalPages: Math.max(1, Math.ceil((count ?? 0) / perPage))
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
export async function getBlogPost(config, slug) {
|
|
53
|
-
const client = getClient(config);
|
|
54
|
-
const table = config.table ?? "blog_posts";
|
|
55
|
-
const { data, error } = await client
|
|
56
|
-
.from(table)
|
|
57
|
-
.select(SELECT_COLUMNS)
|
|
58
|
-
.eq("published", true)
|
|
59
|
-
.eq("site_slug", config.siteSlug)
|
|
60
|
-
.eq("slug", slug)
|
|
61
|
-
.maybeSingle();
|
|
62
|
-
if (error) {
|
|
63
|
-
throw new Error(`Failed to fetch slug ${slug}: ${error.message}`);
|
|
64
|
-
}
|
|
65
|
-
if (!data)
|
|
66
|
-
return null;
|
|
67
|
-
return toReaderPost(data);
|
|
68
|
-
}
|
|
69
|
-
export async function getAllBlogSlugs(config) {
|
|
70
|
-
const client = getClient(config);
|
|
71
|
-
const table = config.table ?? "blog_posts";
|
|
72
|
-
const { data, error } = await client
|
|
73
|
-
.from(table)
|
|
74
|
-
.select("slug, updated_at, published_at")
|
|
75
|
-
.eq("published", true)
|
|
76
|
-
.eq("site_slug", config.siteSlug)
|
|
77
|
-
.order("published_at", { ascending: false });
|
|
78
|
-
if (error) {
|
|
79
|
-
throw new Error(`Failed to fetch slugs for ${config.siteSlug}: ${error.message}`);
|
|
80
|
-
}
|
|
81
|
-
return (data ?? []).map((row) => String(row.slug));
|
|
82
|
-
}
|
|
83
|
-
export async function getBlogPostSummaries(config) {
|
|
84
|
-
const client = getClient(config);
|
|
85
|
-
const table = config.table ?? "blog_posts";
|
|
86
|
-
const { data, error } = await client
|
|
87
|
-
.from(table)
|
|
88
|
-
.select("slug, updated_at, published_at")
|
|
89
|
-
.eq("published", true)
|
|
90
|
-
.eq("site_slug", config.siteSlug)
|
|
91
|
-
.order("published_at", { ascending: false });
|
|
92
|
-
if (error) {
|
|
93
|
-
throw new Error(`Failed to fetch summaries for ${config.siteSlug}: ${error.message}`);
|
|
94
|
-
}
|
|
95
|
-
return (data ?? []).map((row) => {
|
|
96
|
-
const record = row;
|
|
97
|
-
return {
|
|
98
|
-
slug: String(record.slug),
|
|
99
|
-
updatedAt: (record.updated_at ?? undefined),
|
|
100
|
-
publishedAt: (record.published_at ?? undefined)
|
|
101
|
-
};
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YA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