@opinly/next 0.1.3 → 0.1.4
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/dist/index.cjs +24 -29
- package/dist/index.d.cts +17 -0
- package/dist/index.js +21 -26
- package/package.json +5 -2
package/dist/index.cjs
CHANGED
|
@@ -28,12 +28,12 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
29
|
|
|
30
30
|
// src/index.ts
|
|
31
|
-
var
|
|
32
|
-
__export(
|
|
31
|
+
var index_exports = {};
|
|
32
|
+
__export(index_exports, {
|
|
33
33
|
HomePage: () => HomePage,
|
|
34
34
|
OpinlyBlog: () => OpinlyBlog
|
|
35
35
|
});
|
|
36
|
-
module.exports = __toCommonJS(
|
|
36
|
+
module.exports = __toCommonJS(index_exports);
|
|
37
37
|
|
|
38
38
|
// src/components/blog-post/index.tsx
|
|
39
39
|
var import_link5 = __toESM(require("next/link"), 1);
|
|
@@ -80,8 +80,7 @@ function replaceImageNameSpace(fileKey) {
|
|
|
80
80
|
|
|
81
81
|
// src/components/blog-post/_helpers/json-ld.ts
|
|
82
82
|
function generateArticleBodyHtml(content) {
|
|
83
|
-
if (!content?.content)
|
|
84
|
-
return "";
|
|
83
|
+
if (!content?.content) return "";
|
|
85
84
|
let htmlString = "";
|
|
86
85
|
content.content.forEach((node) => {
|
|
87
86
|
switch (node.type) {
|
|
@@ -101,6 +100,14 @@ function generateArticleBodyHtml(content) {
|
|
|
101
100
|
case "listItem":
|
|
102
101
|
htmlString += `<li>${generateChildrenHtml(node.content)}</li>`;
|
|
103
102
|
break;
|
|
103
|
+
// Add other node types if they contain text content relevant for articleBody
|
|
104
|
+
// For images, you might just skip them or include an <img> tag if semantic
|
|
105
|
+
// For example:
|
|
106
|
+
// case "image":
|
|
107
|
+
// if (node.attrs?.src) {
|
|
108
|
+
// htmlString += `<img src="${replaceImageHostname(node.attrs.src, opinlyConfig.imagesPrefix)}" alt="${node.attrs?.alt || ''}" />`;
|
|
109
|
+
// }
|
|
110
|
+
// break;
|
|
104
111
|
default:
|
|
105
112
|
break;
|
|
106
113
|
}
|
|
@@ -108,18 +115,15 @@ function generateArticleBodyHtml(content) {
|
|
|
108
115
|
return htmlString;
|
|
109
116
|
}
|
|
110
117
|
function generateChildrenHtml(nodes) {
|
|
111
|
-
if (!nodes)
|
|
112
|
-
return "";
|
|
118
|
+
if (!nodes) return "";
|
|
113
119
|
let childrenHtml = "";
|
|
114
120
|
nodes.forEach((child) => {
|
|
115
121
|
if (child.type === "text") {
|
|
116
122
|
let text = child.text || "";
|
|
117
123
|
if (child.marks) {
|
|
118
124
|
child.marks.forEach((mark) => {
|
|
119
|
-
if (mark.type === "bold")
|
|
120
|
-
|
|
121
|
-
if (mark.type === "italic")
|
|
122
|
-
text = `<em>${text}</em>`;
|
|
125
|
+
if (mark.type === "bold") text = `<strong>${text}</strong>`;
|
|
126
|
+
if (mark.type === "italic") text = `<em>${text}</em>`;
|
|
123
127
|
if (mark.type === "link" && mark.attrs?.href) {
|
|
124
128
|
text = `<a href="${mark.attrs.href}">${text}</a>`;
|
|
125
129
|
}
|
|
@@ -213,8 +217,7 @@ var genBreadcrumbJSONLD = (post) => {
|
|
|
213
217
|
// src/components/blog-post/_components/faq.tsx
|
|
214
218
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
215
219
|
var FAQS = ({ faqs }) => {
|
|
216
|
-
if (!faqs)
|
|
217
|
-
return null;
|
|
220
|
+
if (!faqs) return null;
|
|
218
221
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
|
|
219
222
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h2", { className: "text-lg font-semibold mb-2", children: "FAQS" }),
|
|
220
223
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("ul", { children: faqs.map((faq) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("li", { children: [
|
|
@@ -226,8 +229,7 @@ var FAQS = ({ faqs }) => {
|
|
|
226
229
|
|
|
227
230
|
// src/components/blog-post/_helpers/reading-time.ts
|
|
228
231
|
var countWords = (content) => {
|
|
229
|
-
if (!content?.content)
|
|
230
|
-
return 0;
|
|
232
|
+
if (!content?.content) return 0;
|
|
231
233
|
let wordCount = 0;
|
|
232
234
|
const countWords2 = (nodes) => {
|
|
233
235
|
for (const node of nodes) {
|
|
@@ -235,8 +237,7 @@ var countWords = (content) => {
|
|
|
235
237
|
const words = node.text.trim().split(/\s+/).filter(Boolean);
|
|
236
238
|
wordCount += words.length;
|
|
237
239
|
}
|
|
238
|
-
if (node.content)
|
|
239
|
-
countWords2(node.content);
|
|
240
|
+
if (node.content) countWords2(node.content);
|
|
240
241
|
}
|
|
241
242
|
};
|
|
242
243
|
countWords2(content.content);
|
|
@@ -252,8 +253,7 @@ function calculateReadingTime(content) {
|
|
|
252
253
|
var import_link = __toESM(require("next/link"), 1);
|
|
253
254
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
254
255
|
function renderTiptapContent(content, classNames) {
|
|
255
|
-
if (!content?.content)
|
|
256
|
-
return [];
|
|
256
|
+
if (!content?.content) return [];
|
|
257
257
|
return content.content.map((node, index) => {
|
|
258
258
|
switch (node.type) {
|
|
259
259
|
case "paragraph":
|
|
@@ -316,17 +316,14 @@ var Content = ({
|
|
|
316
316
|
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "prose min-w-full", children: renderTiptapContent(content, classNames) });
|
|
317
317
|
};
|
|
318
318
|
function renderChildren(nodes, classNames) {
|
|
319
|
-
if (!nodes)
|
|
320
|
-
return [];
|
|
319
|
+
if (!nodes) return [];
|
|
321
320
|
return nodes.map((child, idx) => {
|
|
322
321
|
if (child.type === "text") {
|
|
323
322
|
let text = child.text;
|
|
324
323
|
if (child.marks) {
|
|
325
324
|
child.marks.forEach((mark) => {
|
|
326
|
-
if (mark.type === "bold")
|
|
327
|
-
|
|
328
|
-
if (mark.type === "italic")
|
|
329
|
-
text = /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("em", { children: text }, idx);
|
|
325
|
+
if (mark.type === "bold") text = /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("strong", { children: text }, idx);
|
|
326
|
+
if (mark.type === "italic") text = /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("em", { children: text }, idx);
|
|
330
327
|
if (mark.type === "link")
|
|
331
328
|
text = /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
332
329
|
import_link.default,
|
|
@@ -351,8 +348,7 @@ var import_image = __toESM(require("next/image"), 1);
|
|
|
351
348
|
// src/components/blog-post/_helpers/extract-headings.ts
|
|
352
349
|
function extractHeadings(content) {
|
|
353
350
|
const headings = [];
|
|
354
|
-
if (!content?.content)
|
|
355
|
-
return headings;
|
|
351
|
+
if (!content?.content) return headings;
|
|
356
352
|
const walk = (nodes) => {
|
|
357
353
|
for (const node of nodes) {
|
|
358
354
|
if (node.type === "heading" && node.content?.[0]?.text) {
|
|
@@ -360,8 +356,7 @@ function extractHeadings(content) {
|
|
|
360
356
|
const slug = text.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
|
|
361
357
|
headings.push({ text, slug });
|
|
362
358
|
}
|
|
363
|
-
if (node.content)
|
|
364
|
-
walk(node.content);
|
|
359
|
+
if (node.content) walk(node.content);
|
|
365
360
|
}
|
|
366
361
|
};
|
|
367
362
|
walk(content.content);
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { Opinly } from '@opinly/backend';
|
|
3
|
+
|
|
4
|
+
declare const OpinlyBlog: ({ blog, page, }: {
|
|
5
|
+
blog: Awaited<ReturnType<Opinly["content"]["blog"]>>;
|
|
6
|
+
page: number | null | undefined;
|
|
7
|
+
}) => react_jsx_runtime.JSX.Element;
|
|
8
|
+
|
|
9
|
+
type HomePage = Extract<Awaited<ReturnType<Opinly["content"]["blog"]>>, {
|
|
10
|
+
type: "home";
|
|
11
|
+
}>["data"];
|
|
12
|
+
declare const HomePage: ({ homePage, page, }: {
|
|
13
|
+
homePage: HomePage;
|
|
14
|
+
page: number | null | undefined;
|
|
15
|
+
}) => react_jsx_runtime.JSX.Element;
|
|
16
|
+
|
|
17
|
+
export { HomePage, OpinlyBlog };
|
package/dist/index.js
CHANGED
|
@@ -43,8 +43,7 @@ function replaceImageNameSpace(fileKey) {
|
|
|
43
43
|
|
|
44
44
|
// src/components/blog-post/_helpers/json-ld.ts
|
|
45
45
|
function generateArticleBodyHtml(content) {
|
|
46
|
-
if (!content?.content)
|
|
47
|
-
return "";
|
|
46
|
+
if (!content?.content) return "";
|
|
48
47
|
let htmlString = "";
|
|
49
48
|
content.content.forEach((node) => {
|
|
50
49
|
switch (node.type) {
|
|
@@ -64,6 +63,14 @@ function generateArticleBodyHtml(content) {
|
|
|
64
63
|
case "listItem":
|
|
65
64
|
htmlString += `<li>${generateChildrenHtml(node.content)}</li>`;
|
|
66
65
|
break;
|
|
66
|
+
// Add other node types if they contain text content relevant for articleBody
|
|
67
|
+
// For images, you might just skip them or include an <img> tag if semantic
|
|
68
|
+
// For example:
|
|
69
|
+
// case "image":
|
|
70
|
+
// if (node.attrs?.src) {
|
|
71
|
+
// htmlString += `<img src="${replaceImageHostname(node.attrs.src, opinlyConfig.imagesPrefix)}" alt="${node.attrs?.alt || ''}" />`;
|
|
72
|
+
// }
|
|
73
|
+
// break;
|
|
67
74
|
default:
|
|
68
75
|
break;
|
|
69
76
|
}
|
|
@@ -71,18 +78,15 @@ function generateArticleBodyHtml(content) {
|
|
|
71
78
|
return htmlString;
|
|
72
79
|
}
|
|
73
80
|
function generateChildrenHtml(nodes) {
|
|
74
|
-
if (!nodes)
|
|
75
|
-
return "";
|
|
81
|
+
if (!nodes) return "";
|
|
76
82
|
let childrenHtml = "";
|
|
77
83
|
nodes.forEach((child) => {
|
|
78
84
|
if (child.type === "text") {
|
|
79
85
|
let text = child.text || "";
|
|
80
86
|
if (child.marks) {
|
|
81
87
|
child.marks.forEach((mark) => {
|
|
82
|
-
if (mark.type === "bold")
|
|
83
|
-
|
|
84
|
-
if (mark.type === "italic")
|
|
85
|
-
text = `<em>${text}</em>`;
|
|
88
|
+
if (mark.type === "bold") text = `<strong>${text}</strong>`;
|
|
89
|
+
if (mark.type === "italic") text = `<em>${text}</em>`;
|
|
86
90
|
if (mark.type === "link" && mark.attrs?.href) {
|
|
87
91
|
text = `<a href="${mark.attrs.href}">${text}</a>`;
|
|
88
92
|
}
|
|
@@ -176,8 +180,7 @@ var genBreadcrumbJSONLD = (post) => {
|
|
|
176
180
|
// src/components/blog-post/_components/faq.tsx
|
|
177
181
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
178
182
|
var FAQS = ({ faqs }) => {
|
|
179
|
-
if (!faqs)
|
|
180
|
-
return null;
|
|
183
|
+
if (!faqs) return null;
|
|
181
184
|
return /* @__PURE__ */ jsxs("div", { children: [
|
|
182
185
|
/* @__PURE__ */ jsx("h2", { className: "text-lg font-semibold mb-2", children: "FAQS" }),
|
|
183
186
|
/* @__PURE__ */ jsx("ul", { children: faqs.map((faq) => /* @__PURE__ */ jsxs("li", { children: [
|
|
@@ -189,8 +192,7 @@ var FAQS = ({ faqs }) => {
|
|
|
189
192
|
|
|
190
193
|
// src/components/blog-post/_helpers/reading-time.ts
|
|
191
194
|
var countWords = (content) => {
|
|
192
|
-
if (!content?.content)
|
|
193
|
-
return 0;
|
|
195
|
+
if (!content?.content) return 0;
|
|
194
196
|
let wordCount = 0;
|
|
195
197
|
const countWords2 = (nodes) => {
|
|
196
198
|
for (const node of nodes) {
|
|
@@ -198,8 +200,7 @@ var countWords = (content) => {
|
|
|
198
200
|
const words = node.text.trim().split(/\s+/).filter(Boolean);
|
|
199
201
|
wordCount += words.length;
|
|
200
202
|
}
|
|
201
|
-
if (node.content)
|
|
202
|
-
countWords2(node.content);
|
|
203
|
+
if (node.content) countWords2(node.content);
|
|
203
204
|
}
|
|
204
205
|
};
|
|
205
206
|
countWords2(content.content);
|
|
@@ -215,8 +216,7 @@ function calculateReadingTime(content) {
|
|
|
215
216
|
import Link from "next/link";
|
|
216
217
|
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
217
218
|
function renderTiptapContent(content, classNames) {
|
|
218
|
-
if (!content?.content)
|
|
219
|
-
return [];
|
|
219
|
+
if (!content?.content) return [];
|
|
220
220
|
return content.content.map((node, index) => {
|
|
221
221
|
switch (node.type) {
|
|
222
222
|
case "paragraph":
|
|
@@ -279,17 +279,14 @@ var Content = ({
|
|
|
279
279
|
return /* @__PURE__ */ jsx2("div", { className: "prose min-w-full", children: renderTiptapContent(content, classNames) });
|
|
280
280
|
};
|
|
281
281
|
function renderChildren(nodes, classNames) {
|
|
282
|
-
if (!nodes)
|
|
283
|
-
return [];
|
|
282
|
+
if (!nodes) return [];
|
|
284
283
|
return nodes.map((child, idx) => {
|
|
285
284
|
if (child.type === "text") {
|
|
286
285
|
let text = child.text;
|
|
287
286
|
if (child.marks) {
|
|
288
287
|
child.marks.forEach((mark) => {
|
|
289
|
-
if (mark.type === "bold")
|
|
290
|
-
|
|
291
|
-
if (mark.type === "italic")
|
|
292
|
-
text = /* @__PURE__ */ jsx2("em", { children: text }, idx);
|
|
288
|
+
if (mark.type === "bold") text = /* @__PURE__ */ jsx2("strong", { children: text }, idx);
|
|
289
|
+
if (mark.type === "italic") text = /* @__PURE__ */ jsx2("em", { children: text }, idx);
|
|
293
290
|
if (mark.type === "link")
|
|
294
291
|
text = /* @__PURE__ */ jsx2(
|
|
295
292
|
Link,
|
|
@@ -314,8 +311,7 @@ import Image from "next/image";
|
|
|
314
311
|
// src/components/blog-post/_helpers/extract-headings.ts
|
|
315
312
|
function extractHeadings(content) {
|
|
316
313
|
const headings = [];
|
|
317
|
-
if (!content?.content)
|
|
318
|
-
return headings;
|
|
314
|
+
if (!content?.content) return headings;
|
|
319
315
|
const walk = (nodes) => {
|
|
320
316
|
for (const node of nodes) {
|
|
321
317
|
if (node.type === "heading" && node.content?.[0]?.text) {
|
|
@@ -323,8 +319,7 @@ function extractHeadings(content) {
|
|
|
323
319
|
const slug = text.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
|
|
324
320
|
headings.push({ text, slug });
|
|
325
321
|
}
|
|
326
|
-
if (node.content)
|
|
327
|
-
walk(node.content);
|
|
322
|
+
if (node.content) walk(node.content);
|
|
328
323
|
}
|
|
329
324
|
};
|
|
330
325
|
walk(content.content);
|
package/package.json
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opinly/next",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"private": false,
|
|
6
|
+
"main": "dist/index.cjs.js",
|
|
7
|
+
"module": "dist/index.esm.js",
|
|
8
|
+
"types": "dist/index.d.ts",
|
|
6
9
|
"devDependencies": {
|
|
7
10
|
"@tsconfig/next": "^2.0.3",
|
|
8
11
|
"@types/node": "^20.0.0",
|
|
@@ -25,7 +28,7 @@
|
|
|
25
28
|
"react-syntax-highlighter": "^15.6.1",
|
|
26
29
|
"schema-dts": "^1.1.5",
|
|
27
30
|
"tailwind-merge": "^1.14.0",
|
|
28
|
-
"@opinly/backend": "0.1.
|
|
31
|
+
"@opinly/backend": "0.1.4"
|
|
29
32
|
},
|
|
30
33
|
"engines": {
|
|
31
34
|
"node": ">=16"
|