@opinly/next 0.1.17 → 0.1.18
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/components/author-page/index.cjs +51 -25
- package/dist/components/author-page/index.cjs.map +1 -1
- package/dist/components/author-page/index.js +52 -26
- package/dist/components/author-page/index.js.map +1 -1
- package/dist/components/blog-post/_components/content.cjs +5 -8
- package/dist/components/blog-post/_components/content.cjs.map +1 -1
- package/dist/components/blog-post/_components/content.js +5 -8
- package/dist/components/blog-post/_components/content.js.map +1 -1
- package/dist/components/blog-post/_components/faq.cjs +2 -2
- package/dist/components/blog-post/_components/faq.cjs.map +1 -1
- package/dist/components/blog-post/_components/faq.js +2 -2
- package/dist/components/blog-post/_components/faq.js.map +1 -1
- package/dist/components/blog-post/_components/table-of-contents.cjs +36 -9
- package/dist/components/blog-post/_components/table-of-contents.cjs.map +1 -1
- package/dist/components/blog-post/_components/table-of-contents.js +36 -9
- package/dist/components/blog-post/_components/table-of-contents.js.map +1 -1
- package/dist/components/blog-post/_helpers/extract-headings.cjs +2 -1
- package/dist/components/blog-post/_helpers/extract-headings.cjs.map +1 -1
- package/dist/components/blog-post/_helpers/extract-headings.d.cts +1 -0
- package/dist/components/blog-post/_helpers/extract-headings.d.ts +1 -0
- package/dist/components/blog-post/_helpers/extract-headings.js +2 -1
- package/dist/components/blog-post/_helpers/extract-headings.js.map +1 -1
- package/dist/components/blog-post/_helpers/json-ld.cjs +5 -12
- package/dist/components/blog-post/_helpers/json-ld.cjs.map +1 -1
- package/dist/components/blog-post/_helpers/json-ld.d.cts +6 -2
- package/dist/components/blog-post/_helpers/json-ld.d.ts +6 -2
- package/dist/components/blog-post/_helpers/json-ld.js +5 -12
- package/dist/components/blog-post/_helpers/json-ld.js.map +1 -1
- package/dist/components/blog-post/_helpers/reading-time.cjs +1 -1
- package/dist/components/blog-post/_helpers/reading-time.cjs.map +1 -1
- package/dist/components/blog-post/_helpers/reading-time.js +1 -1
- package/dist/components/blog-post/_helpers/reading-time.js.map +1 -1
- package/dist/components/blog-post/index.cjs +20 -17
- package/dist/components/blog-post/index.cjs.map +1 -1
- package/dist/components/blog-post/index.js +20 -17
- package/dist/components/blog-post/index.js.map +1 -1
- package/dist/components/bread-crumbs.cjs +1 -1
- package/dist/components/bread-crumbs.cjs.map +1 -1
- package/dist/components/bread-crumbs.js +1 -1
- package/dist/components/bread-crumbs.js.map +1 -1
- package/dist/components/folder-page/index.cjs +46 -11
- package/dist/components/folder-page/index.cjs.map +1 -1
- package/dist/components/folder-page/index.js +47 -12
- package/dist/components/folder-page/index.js.map +1 -1
- package/dist/components/home-page/folders.cjs +6 -9
- package/dist/components/home-page/folders.cjs.map +1 -1
- package/dist/components/home-page/folders.d.cts +4 -2
- package/dist/components/home-page/folders.d.ts +4 -2
- package/dist/components/home-page/folders.js +6 -9
- package/dist/components/home-page/folders.js.map +1 -1
- package/dist/components/home-page/index.cjs +5 -7
- package/dist/components/home-page/index.cjs.map +1 -1
- package/dist/components/home-page/index.d.cts +4 -5
- package/dist/components/home-page/index.d.ts +4 -5
- package/dist/components/home-page/index.js +5 -7
- package/dist/components/home-page/index.js.map +1 -1
- package/dist/components/home-page/pagination.cjs +23 -17
- package/dist/components/home-page/pagination.cjs.map +1 -1
- package/dist/components/home-page/pagination.d.cts +2 -3
- package/dist/components/home-page/pagination.d.ts +2 -3
- package/dist/components/home-page/pagination.js +23 -17
- package/dist/components/home-page/pagination.js.map +1 -1
- package/dist/components/home-page/top-posts.cjs +2 -19
- package/dist/components/home-page/top-posts.cjs.map +1 -1
- package/dist/components/home-page/top-posts.d.cts +4 -3
- package/dist/components/home-page/top-posts.d.ts +4 -3
- package/dist/components/home-page/top-posts.js +4 -21
- package/dist/components/home-page/top-posts.js.map +1 -1
- package/dist/components/opinly-blog.cjs +6 -6
- package/dist/components/opinly-blog.cjs.map +1 -1
- package/dist/components/opinly-blog.d.cts +4 -7
- package/dist/components/opinly-blog.d.ts +4 -7
- package/dist/components/opinly-blog.js +6 -6
- package/dist/components/opinly-blog.js.map +1 -1
- package/dist/components/post-preview.cjs +7 -6
- package/dist/components/post-preview.cjs.map +1 -1
- package/dist/components/post-preview.js +7 -6
- package/dist/components/post-preview.js.map +1 -1
- package/dist/{utils/with-opinly-config.cjs → config.cjs} +17 -9
- package/dist/config.cjs.map +1 -0
- package/dist/{utils/with-opinly-config.d.cts → config.d.cts} +3 -0
- package/dist/{utils/with-opinly-config.d.ts → config.d.ts} +3 -0
- package/dist/{utils/with-opinly-config.js → config.js} +14 -6
- package/dist/config.js.map +1 -0
- package/dist/index.cjs +1 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +0 -3
- package/dist/index.d.ts +0 -3
- package/dist/index.js +0 -1
- package/dist/index.js.map +1 -1
- package/dist/pages/index.cjs +23 -0
- package/dist/pages/index.cjs.map +1 -0
- package/dist/pages/index.d.cts +3 -0
- package/dist/pages/index.d.ts +3 -0
- package/dist/pages/index.js +2 -0
- package/dist/pages/index.js.map +1 -0
- package/dist/pages/opinly-blog-pages.cjs +128 -0
- package/dist/pages/opinly-blog-pages.cjs.map +1 -0
- package/dist/pages/opinly-blog-pages.d.cts +9 -0
- package/dist/pages/opinly-blog-pages.d.ts +9 -0
- package/dist/pages/opinly-blog-pages.js +104 -0
- package/dist/pages/opinly-blog-pages.js.map +1 -0
- package/dist/utils/generate-metadata.cjs +1 -1
- package/dist/utils/generate-metadata.cjs.map +1 -1
- package/dist/utils/generate-metadata.d.cts +2 -4
- package/dist/utils/generate-metadata.d.ts +2 -4
- package/dist/utils/generate-metadata.js +1 -1
- package/dist/utils/generate-metadata.js.map +1 -1
- package/dist/utils/generate-sitemap-xml.cjs +42 -0
- package/dist/utils/generate-sitemap-xml.cjs.map +1 -0
- package/dist/utils/generate-sitemap-xml.d.cts +5 -0
- package/dist/utils/generate-sitemap-xml.d.ts +5 -0
- package/dist/utils/generate-sitemap-xml.js +18 -0
- package/dist/utils/generate-sitemap-xml.js.map +1 -0
- package/dist/utils/sdk-config.cjs +4 -2
- package/dist/utils/sdk-config.cjs.map +1 -1
- package/dist/utils/sdk-config.d.cts +2 -0
- package/dist/utils/sdk-config.d.ts +2 -0
- package/dist/utils/sdk-config.js +4 -2
- package/dist/utils/sdk-config.js.map +1 -1
- package/package.json +12 -3
- package/dist/components/not-found.cjs +0 -60
- package/dist/components/not-found.cjs.map +0 -1
- package/dist/components/not-found.d.cts +0 -5
- package/dist/components/not-found.d.ts +0 -5
- package/dist/components/not-found.js +0 -26
- package/dist/components/not-found.js.map +0 -1
- package/dist/utils/with-opinly-config.cjs.map +0 -1
- package/dist/utils/with-opinly-config.js.map +0 -1
|
@@ -36,45 +36,71 @@ var import_image = __toESM(require("next/image"), 1);
|
|
|
36
36
|
var import_sdk_config = require("../../utils/sdk-config");
|
|
37
37
|
var import_post_preview = require("../post-preview");
|
|
38
38
|
var import_bread_crumbs = require("../bread-crumbs");
|
|
39
|
+
var import_next_seo = require("next-seo");
|
|
39
40
|
const AuthorPage = ({
|
|
40
41
|
author
|
|
41
42
|
}) => {
|
|
42
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
43
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
43
44
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
44
|
-
|
|
45
|
+
import_next_seo.BreadcrumbJsonLd,
|
|
45
46
|
{
|
|
46
|
-
|
|
47
|
+
useAppDir: !import_sdk_config.opinlyConfig.pagesRouter,
|
|
48
|
+
itemListElements: [
|
|
47
49
|
{
|
|
50
|
+
position: 1,
|
|
51
|
+
name: import_sdk_config.opinlyConfig.siteName,
|
|
52
|
+
item: import_sdk_config.opinlyConfig.siteUrl
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
position: 2,
|
|
56
|
+
name: "Blog",
|
|
57
|
+
item: import_sdk_config.opinlyConfig.blogUrl
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
position: 3,
|
|
48
61
|
name: "Authors",
|
|
49
|
-
|
|
62
|
+
item: `${import_sdk_config.opinlyConfig.blogPrefix}/authors`
|
|
50
63
|
}
|
|
51
64
|
]
|
|
52
65
|
}
|
|
53
66
|
),
|
|
54
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "
|
|
55
|
-
|
|
56
|
-
|
|
67
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "max-w-5xl mx-auto px-4 py-10", children: [
|
|
68
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
69
|
+
import_bread_crumbs.BreadCrumbs,
|
|
57
70
|
{
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
71
|
+
breadcrumbs: [
|
|
72
|
+
{
|
|
73
|
+
name: "Authors",
|
|
74
|
+
url: `${import_sdk_config.opinlyConfig.blogPrefix}/authors`
|
|
75
|
+
}
|
|
76
|
+
]
|
|
64
77
|
}
|
|
65
78
|
),
|
|
66
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
|
|
67
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
79
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex items-center gap-6 mb-10", children: [
|
|
80
|
+
author.image.fileKey && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
81
|
+
import_image.default,
|
|
82
|
+
{
|
|
83
|
+
unoptimized: import_sdk_config.opinlyConfig.unoptimizedImages,
|
|
84
|
+
src: `${import_sdk_config.opinlyConfig.imagesPrefix}/${author.image.fileKey}`,
|
|
85
|
+
alt: author.image.alt || author.name,
|
|
86
|
+
width: 150,
|
|
87
|
+
height: 150,
|
|
88
|
+
className: "rounded-full border"
|
|
89
|
+
}
|
|
90
|
+
),
|
|
91
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
|
|
92
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h1", { className: "text-3xl font-bold mb-1", children: author.name }),
|
|
93
|
+
author.bio && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "text-muted-foreground text-base max-w-2xl", children: author.bio })
|
|
94
|
+
] })
|
|
95
|
+
] }),
|
|
96
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("h2", { className: "text-xl font-semibold mb-6", children: [
|
|
97
|
+
"Posts by ",
|
|
98
|
+
author.name
|
|
99
|
+
] }),
|
|
100
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-8", children: author.posts && author.posts.length > 0 ? author.posts.map(
|
|
101
|
+
(post) => post && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_post_preview.PostPreview, { post }, post.slug)
|
|
102
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "text-muted-foreground col-span-full", children: "No posts yet." }) })
|
|
103
|
+
] })
|
|
78
104
|
] });
|
|
79
105
|
};
|
|
80
106
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/author-page/index.tsx"],"sourcesContent":["import { Opinly } from \"@opinly/backend\";\nimport Image from \"next/image\";\nimport { opinlyConfig } from \"../../utils/sdk-config\";\nimport { PostPreview } from \"../post-preview\";\nimport { BreadCrumbs } from \"../bread-crumbs\";\n\nexport const AuthorPage = ({\n author,\n}: {\n author: Extract<\n Awaited<ReturnType<Opinly[\"content\"][\"blog\"]>>,\n { type: \"author\" }\n >[\"data\"];\n}) => {\n return (\n <div className=\"max-w-5xl mx-auto px-4 py-10\">\n
|
|
1
|
+
{"version":3,"sources":["../../../src/components/author-page/index.tsx"],"sourcesContent":["import { Opinly } from \"@opinly/backend\";\nimport Image from \"next/image\";\nimport { opinlyConfig } from \"../../utils/sdk-config\";\nimport { PostPreview } from \"../post-preview\";\nimport { BreadCrumbs } from \"../bread-crumbs\";\nimport { BreadcrumbJsonLd } from \"next-seo\";\n\nexport const AuthorPage = ({\n author,\n}: {\n author: Extract<\n Awaited<ReturnType<Opinly[\"content\"][\"blog\"]>>,\n { type: \"author\" }\n >[\"data\"];\n}) => {\n return (\n <>\n <BreadcrumbJsonLd\n useAppDir={!opinlyConfig.pagesRouter}\n itemListElements={[\n {\n position: 1,\n name: opinlyConfig.siteName,\n item: opinlyConfig.siteUrl,\n },\n {\n position: 2,\n name: \"Blog\",\n item: opinlyConfig.blogUrl,\n },\n {\n position: 3,\n name: \"Authors\",\n item: `${opinlyConfig.blogPrefix}/authors`,\n },\n ]}\n />\n <div className=\"max-w-5xl mx-auto px-4 py-10\">\n <BreadCrumbs\n breadcrumbs={[\n {\n name: \"Authors\",\n url: `${opinlyConfig.blogPrefix}/authors`,\n },\n ]}\n />\n {/* Author Header */}\n <div className=\"flex items-center gap-6 mb-10\">\n {author.image.fileKey && (\n <Image\n unoptimized={opinlyConfig.unoptimizedImages}\n src={`${opinlyConfig.imagesPrefix}/${author.image.fileKey}`}\n alt={author.image.alt || author.name}\n width={150}\n height={150}\n className=\"rounded-full border\"\n />\n )}\n <div>\n <h1 className=\"text-3xl font-bold mb-1\">{author.name}</h1>\n {author.bio && (\n <p className=\"text-muted-foreground text-base max-w-2xl\">\n {author.bio}\n </p>\n )}\n </div>\n </div>\n\n {/* Posts Grid */}\n <h2 className=\"text-xl font-semibold mb-6\">Posts by {author.name}</h2>\n <div className=\"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-8\">\n {author.posts && author.posts.length > 0 ? (\n author.posts.map(\n (post) => post && <PostPreview key={post.slug} post={post} />\n )\n ) : (\n <div className=\"text-muted-foreground col-span-full\">\n No pos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V;AAAA,WAEJ;AAAA,SACF;AAAA,MAGA,6CAAC,QAAG,WAAU,8BAA6B;AAAA;AAAA,QAAU,OAAO;AAAA,SAAK;AAAA,MACjE,4CAAC,SAAI,WAAU,wDACZ,iBAAO,SAAS,OAAO,MAAM,SAAS,IACrC,OAAO,MAAM;AAAA,QACX,CAAC,SAAS,QAAQ,4CAAC,mCAA4B,QAAX,KAAK,IAAkB;AAAA,MAC7D,IAEA,4CAAC,SAAI,WAAU,uCAAsC,2BAErD,GAEJ;AAAA,OACF;AAAA,KACF;AAEJ;","names":["Image"]}
|
|
@@ -1,47 +1,73 @@
|
|
|
1
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import Image from "next/image";
|
|
3
3
|
import { opinlyConfig } from "../../utils/sdk-config";
|
|
4
4
|
import { PostPreview } from "../post-preview";
|
|
5
5
|
import { BreadCrumbs } from "../bread-crumbs";
|
|
6
|
+
import { BreadcrumbJsonLd } from "next-seo";
|
|
6
7
|
const AuthorPage = ({
|
|
7
8
|
author
|
|
8
9
|
}) => {
|
|
9
|
-
return /* @__PURE__ */ jsxs(
|
|
10
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
10
11
|
/* @__PURE__ */ jsx(
|
|
11
|
-
|
|
12
|
+
BreadcrumbJsonLd,
|
|
12
13
|
{
|
|
13
|
-
|
|
14
|
+
useAppDir: !opinlyConfig.pagesRouter,
|
|
15
|
+
itemListElements: [
|
|
14
16
|
{
|
|
17
|
+
position: 1,
|
|
18
|
+
name: opinlyConfig.siteName,
|
|
19
|
+
item: opinlyConfig.siteUrl
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
position: 2,
|
|
23
|
+
name: "Blog",
|
|
24
|
+
item: opinlyConfig.blogUrl
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
position: 3,
|
|
15
28
|
name: "Authors",
|
|
16
|
-
|
|
29
|
+
item: `${opinlyConfig.blogPrefix}/authors`
|
|
17
30
|
}
|
|
18
31
|
]
|
|
19
32
|
}
|
|
20
33
|
),
|
|
21
|
-
/* @__PURE__ */ jsxs("div", { className: "
|
|
22
|
-
|
|
23
|
-
|
|
34
|
+
/* @__PURE__ */ jsxs("div", { className: "max-w-5xl mx-auto px-4 py-10", children: [
|
|
35
|
+
/* @__PURE__ */ jsx(
|
|
36
|
+
BreadCrumbs,
|
|
24
37
|
{
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
38
|
+
breadcrumbs: [
|
|
39
|
+
{
|
|
40
|
+
name: "Authors",
|
|
41
|
+
url: `${opinlyConfig.blogPrefix}/authors`
|
|
42
|
+
}
|
|
43
|
+
]
|
|
31
44
|
}
|
|
32
45
|
),
|
|
33
|
-
/* @__PURE__ */ jsxs("div", { children: [
|
|
34
|
-
/* @__PURE__ */ jsx(
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
46
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-6 mb-10", children: [
|
|
47
|
+
author.image.fileKey && /* @__PURE__ */ jsx(
|
|
48
|
+
Image,
|
|
49
|
+
{
|
|
50
|
+
unoptimized: opinlyConfig.unoptimizedImages,
|
|
51
|
+
src: `${opinlyConfig.imagesPrefix}/${author.image.fileKey}`,
|
|
52
|
+
alt: author.image.alt || author.name,
|
|
53
|
+
width: 150,
|
|
54
|
+
height: 150,
|
|
55
|
+
className: "rounded-full border"
|
|
56
|
+
}
|
|
57
|
+
),
|
|
58
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
59
|
+
/* @__PURE__ */ jsx("h1", { className: "text-3xl font-bold mb-1", children: author.name }),
|
|
60
|
+
author.bio && /* @__PURE__ */ jsx("p", { className: "text-muted-foreground text-base max-w-2xl", children: author.bio })
|
|
61
|
+
] })
|
|
62
|
+
] }),
|
|
63
|
+
/* @__PURE__ */ jsxs("h2", { className: "text-xl font-semibold mb-6", children: [
|
|
64
|
+
"Posts by ",
|
|
65
|
+
author.name
|
|
66
|
+
] }),
|
|
67
|
+
/* @__PURE__ */ jsx("div", { className: "grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-8", children: author.posts && author.posts.length > 0 ? author.posts.map(
|
|
68
|
+
(post) => post && /* @__PURE__ */ jsx(PostPreview, { post }, post.slug)
|
|
69
|
+
) : /* @__PURE__ */ jsx("div", { className: "text-muted-foreground col-span-full", children: "No posts yet." }) })
|
|
70
|
+
] })
|
|
45
71
|
] });
|
|
46
72
|
};
|
|
47
73
|
export {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/author-page/index.tsx"],"sourcesContent":["import { Opinly } from \"@opinly/backend\";\nimport Image from \"next/image\";\nimport { opinlyConfig } from \"../../utils/sdk-config\";\nimport { PostPreview } from \"../post-preview\";\nimport { BreadCrumbs } from \"../bread-crumbs\";\n\nexport const AuthorPage = ({\n author,\n}: {\n author: Extract<\n Awaited<ReturnType<Opinly[\"content\"][\"blog\"]>>,\n { type: \"author\" }\n >[\"data\"];\n}) => {\n return (\n <div className=\"max-w-5xl mx-auto px-4 py-10\">\n
|
|
1
|
+
{"version":3,"sources":["../../../src/components/author-page/index.tsx"],"sourcesContent":["import { Opinly } from \"@opinly/backend\";\nimport Image from \"next/image\";\nimport { opinlyConfig } from \"../../utils/sdk-config\";\nimport { PostPreview } from \"../post-preview\";\nimport { BreadCrumbs } from \"../bread-crumbs\";\nimport { BreadcrumbJsonLd } from \"next-seo\";\n\nexport const AuthorPage = ({\n author,\n}: {\n author: Extract<\n Awaited<ReturnType<Opinly[\"content\"][\"blog\"]>>,\n { type: \"author\" }\n >[\"data\"];\n}) => {\n return (\n <>\n <BreadcrumbJsonLd\n useAppDir={!opinlyConfig.pagesRouter}\n itemListElements={[\n {\n position: 1,\n name: opinlyConfig.siteName,\n item: opinlyConfig.siteUrl,\n },\n {\n position: 2,\n name: \"Blog\",\n item: opinlyConfig.blogUrl,\n },\n {\n position: 3,\n name: \"Authors\",\n item: `${opinlyConfig.blogPrefix}/authors`,\n },\n ]}\n />\n <div className=\"max-w-5xl mx-auto px-4 py-10\">\n <BreadCrumbs\n breadcrumbs={[\n {\n name: \"Authors\",\n url: `${opinlyConfig.blogPrefix}/authors`,\n },\n ]}\n />\n {/* Author Header */}\n <div className=\"flex items-center gap-6 mb-10\">\n {author.image.fileKey && (\n <Image\n unoptimized={opinlyConfig.unoptimizedImages}\n src={`${opinlyConfig.imagesPrefix}/${author.image.fileKey}`}\n alt={author.image.alt || author.name}\n width={150}\n height={150}\n className=\"rounded-full border\"\n />\n )}\n <div>\n <h1 className=\"text-3xl font-bold mb-1\">{author.name}</h1>\n {author.bio && (\n <p className=\"text-muted-foreground text-base max-w-2xl\">\n {author.bio}\n </p>\n )}\n </div>\n </div>\n\n {/* Posts Grid */}\n <h2 className=\"text-xl font-semibold mb-6\">Posts by {author.name}</h2>\n <div className=\"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-8\">\n {author.posts && author.posts.length > 0 ? (\n author.posts.map(\n (post) => post && <PostPreview key={post.slug} post={post} />\n )\n ) : (\n <div className=\"text-muted-foreground col-span-full\">\n No posts yet.\n </div>\n )}\n </div>\n </div>\n </>\n );\n};\n"],"mappings":"AAgBI,mBACE,KAyCI,YA1CN;AAfJ,OAAO,WAAW;AAClB,SAAS,oBAAoB;AAC7B,SAAS,mBAAmB;AAC5B,SAAS,mBAAmB;AAC5B,SAAS,wBAAwB;AAE1B,MAAM,aAAa,CAAC;AAAA,EACzB;AACF,MAKM;AACJ,SACE,iCACE;AAAA;AAAA,MAAC;AAAA;AAAA,QACC,WAAW,CAAC,aAAa;AAAA,QACzB,kBAAkB;AAAA,UAChB;AAAA,YACE,UAAU;AAAA,YACV,MAAM,aAAa;AAAA,Y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|
|
52
52
|
{
|
|
53
53
|
id: slug,
|
|
54
|
-
className: classNames.heading || "mt-8 mb-4 font-bold text-
|
|
54
|
+
className: classNames.heading || "mt-8 mb-4 font-bold text-op-heading",
|
|
55
55
|
children: renderChildren(node.content, classNames)
|
|
56
56
|
},
|
|
57
57
|
index
|
|
@@ -66,10 +66,9 @@ function renderTiptapContent(content, classNames) {
|
|
|
66
66
|
"div",
|
|
67
67
|
{
|
|
68
68
|
className: (0, import_merge.cn)(
|
|
69
|
-
"
|
|
69
|
+
"w-full max-w-[800px] my-10 rounded-lg overflow-hidden flex items-center justify-center",
|
|
70
70
|
classNames.image
|
|
71
71
|
),
|
|
72
|
-
style: { aspectRatio: "2 / 1" },
|
|
73
72
|
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
74
73
|
import_image.default,
|
|
75
74
|
{
|
|
@@ -77,9 +76,9 @@ function renderTiptapContent(content, classNames) {
|
|
|
77
76
|
src: `${import_sdk_config.opinlyConfig.imagesPrefix}/${fileKey}`,
|
|
78
77
|
title: node.attrs?.title || "",
|
|
79
78
|
alt: node.attrs?.alt || "",
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
79
|
+
width: 800,
|
|
80
|
+
height: 400,
|
|
81
|
+
className: "rounded-lg max-w-full max-h-full"
|
|
83
82
|
}
|
|
84
83
|
)
|
|
85
84
|
},
|
|
@@ -121,7 +120,6 @@ const Content = ({
|
|
|
121
120
|
};
|
|
122
121
|
function renderChildren(nodes, classNames) {
|
|
123
122
|
if (!nodes) {
|
|
124
|
-
console.log("no nodes");
|
|
125
123
|
return [];
|
|
126
124
|
}
|
|
127
125
|
return nodes.map((child, idx) => {
|
|
@@ -145,7 +143,6 @@ function renderChildren(nodes, classNames) {
|
|
|
145
143
|
}
|
|
146
144
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: text }, idx);
|
|
147
145
|
} else {
|
|
148
|
-
console.log("child", child);
|
|
149
146
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react2.default.Fragment, { children: renderTiptapContent(
|
|
150
147
|
{ ...child, content: child.content },
|
|
151
148
|
classNames
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/blog-post/_components/content.tsx"],"sourcesContent":["import type { JSONContent } from \"@tiptap/core\";\nimport { BlogComponentClassNames } from \"../_types/class-names\";\nimport { cn } from \"../../../utils/merge\";\nimport Link from \"next/link\";\nimport { JSX } from \"react\";\nimport Image from \"next/image\";\nimport { opinlyConfig } from \"../../../utils/sdk-config\";\nimport React from \"react\";\n\nfunction renderTiptapContent(\n content: JSONContent,\n classNames: BlogComponentClassNames\n): React.ReactNode[] {\n if (!content?.content) return [];\n\n return content.content\n .map((node, index) => {\n switch (node.type) {\n case \"paragraph\":\n return (\n <p key={index} className={classNames.paragraph || \"mb-4\"}>\n {renderChildren(node.content, classNames)}\n </p>\n );\n case \"heading\": {\n const text = node.content?.[0]?.text ?? \"\";\n const slug = text\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, \"-\")\n .replace(/^-+|-+$/g, \"\");\n const Tag = `h${\n node.attrs?.level || 1\n }` as keyof JSX.IntrinsicElements;\n return (\n <Tag\n key={index}\n id={slug}\n className={\n classNames.heading || \"mt-8 mb-4 font-bold text-
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/blog-post/_components/content.tsx"],"sourcesContent":["import type { JSONContent } from \"@tiptap/core\";\nimport { BlogComponentClassNames } from \"../_types/class-names\";\nimport { cn } from \"../../../utils/merge\";\nimport Link from \"next/link\";\nimport { JSX } from \"react\";\nimport Image from \"next/image\";\nimport { opinlyConfig } from \"../../../utils/sdk-config\";\nimport React from \"react\";\n\nfunction renderTiptapContent(\n content: JSONContent,\n classNames: BlogComponentClassNames\n): React.ReactNode[] {\n if (!content?.content) return [];\n\n return content.content\n .map((node, index) => {\n switch (node.type) {\n case \"paragraph\":\n return (\n <p key={index} className={classNames.paragraph || \"mb-4\"}>\n {renderChildren(node.content, classNames)}\n </p>\n );\n case \"heading\": {\n const text = node.content?.[0]?.text ?? \"\";\n const slug = text\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, \"-\")\n .replace(/^-+|-+$/g, \"\");\n const Tag = `h${\n node.attrs?.level || 1\n }` as keyof JSX.IntrinsicElements;\n return (\n <Tag\n key={index}\n id={slug}\n className={\n classNames.heading || \"mt-8 mb-4 font-bold text-op-heading\"\n }\n >\n {renderChildren(node.content, classNames)}\n </Tag>\n );\n }\n case \"image\":\n const fileKey = node.attrs?.fileKey;\n\n if (!fileKey) {\n return null;\n }\n\n return (\n <div\n key={index}\n className={cn(\n \"w-full max-w-[800px] my-10 rounded-lg overflow-hidden flex items-center justify-center\",\n classNames.image\n )}\n >\n <Image\n unoptimized={opinlyConfig.unoptimizedImages}\n src={`${opinlyConfig.imagesPrefix}/${fileKey}`}\n title={node.attrs?.title || \"\"}\n alt={node.attrs?.alt || \"\"}\n width={800}\n height={400}\n className=\"rounded-lg max-w-full max-h-full\"\n />\n </div>\n );\n case \"bulletList\":\n return (\n <ul\n key={index}\n className={cn(\"list-disc pl-6 my-4\", classNames.bulletList)}\n >\n {renderTiptapContent(node, classNames)}\n </ul>\n );\n case \"orderedList\":\n return (\n <ol\n key={index}\n className={cn(\"list-decimal pl-6 my-4\", classNames.orderedList)}\n >\n {renderTiptapContent(node, classNames)}\n </ol>\n );\n case \"listItem\":\n if (\n node.content &&\n node.content.length === 1 &&\n node.content[0].type === \"paragraph\"\n ) {\n return (\n <li key={index} className={cn(\"my-1\", classNames.listItem)}>\n {renderChildren(node.content[0].content, classNames)}\n </li>\n );\n }\n return (\n <li key={index} className={cn(\"my-1\", classNames.listItem)}>\n {renderChildren(node.content, classNames)}\n </li>\n );\n default:\n return null;\n }\n })\n .filter(Boolean);\n}\n\nexport const Content = ({\n content,\n classNames,\n}: {\n content: JSONContent;\n classNames: BlogComponentClassNames;\n}) => {\n return (\n <div className=\"prose min-w-full\">\n {renderTiptapContent(content, classNames)}\n </div>\n );\n};\n\nfunction renderChildren(\n nodes: JSONContent[\"content\"] | undefined,\n classNames: BlogComponentClassNames\n): JSX.Element[] {\n if (!nodes) {\n return [];\n }\n\n return nodes\n .map((child, idx) => {\n if (child.type === \"text\") {\n let text: React.ReactNode = child.text;\n if (child.marks) {\n child.marks.forEach((mark) => {\n if (mark.type === \"bold\") text = <strong key={idx}>{text}</strong>;\n if (mark.type === \"italic\") text = <em key={idx}>{text}</em>;\n if (mark.type === \"link\")\n text = (\n <Link\n key={idx}\n href={mark.attrs?.href}\n className={classNames.link || \"text-blue-600 underline\"}\n >\n {text}\n </Link>\n );\n });\n }\n return <span key={idx}>{text}</span>;\n } else {\n // Recursively render non-text nodes (e.g., paragraph, listItem, etc.)\n return (\n <React.Fragment key={idx}>\n {renderTiptapContent(\n { ...child, content: child.content },\n classNames\n )}\n </React.Fragment>\n );\n }\n })\n .filter(Boolean) as JSX.Element[];\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAoBY;AAlBZ,mBAAmB;AACnB,kBAAiB;AAEjB,mBAAkB;AAClB,wBAA6B;AAC7B,IAAAA,gBAAkB;AAElB,SAAS,oBACP,SACA,YACmB;AACnB,MAAI,CAAC,SAAS,QAAS,QAAO,CAAC;AAE/B,SAAO,QAAQ,QACZ,IAAI,CAAC,MAAM,UAAU;AACpB,YAAQ,KAAK,MAAM;AAAA,MACjB,KAAK;AACH,eACE,4CAAC,OAAc,WAAW,WAAW,aAAa,QAC/C,yBAAe,KAAK,SAAS,UAAU,KADlC,KAER;AAAA,MAEJ,KAAK,WAAW;AACd,cAAM,OAAO,KAAK,UAAU,CAAC,GAAG,QAAQ;AACxC,cAAM,OAAO,KACV,YAAY,EACZ,QAAQ,eAAe,GAAG,EAC1B,QAAQ,YAAY,EAAE;AACzB,cAAM,MAAM,IACV,KAAK,OAAO,SAAS,CACvB;AACA,eACE;AAAA,UAAC;AAAA;AAAA,YAEC,IAAI;A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ADjC,KAET;AAAA,MAEJ;AACE,eAAO;AAAA,IACX;AAAA,EACF,CAAC,EACA,OAAO,OAAO;AACnB;AAEO,MAAM,UAAU,CAAC;AAAA,EACtB;AAAA,EACA;AACF,MAGM;AACJ,SACE,4CAAC,SAAI,WAAU,oBACZ,8BAAoB,SAAS,UAAU,GAC1C;AAEJ;AAEA,SAAS,eACP,OACA,YACe;AACf,MAAI,CAAC,OAAO;AACV,WAAO,CAAC;AAAA,EACV;AAEA,SAAO,MACJ,IAAI,CAAC,OAAO,QAAQ;AACnB,QAAI,MAAM,SAAS,QAAQ;AACzB,UAAI,OAAwB,MAAM;AAClC,UAAI,MAAM,OAAO;AACf,cAAM,MAAM,QAAQ,CAAC,SAAS;AAC5B,cAAI,KAAK,SAAS,OAAQ,QAAO,4CAAC,YAAkB,kBAAN,GAAW;AACzD,cAAI,KAAK,SAAS,SAAU,QAAO,4CAAC,QAAc,kBAAN,GAAW;AACvD,cAAI,KAAK,SAAS;AAChB,mBACE;AAAA,cAAC,YAAAC;AAAA,cAAA;AAAA,gBAEC,MAAM,KAAK,OAAO;AAAA,gBAClB,WAAW,WAAW,QAAQ;AAAA,gBAE7B;AAAA;AAAA,cAJI;AAAA,YAKP;AAAA,QAEN,CAAC;AAAA,MACH;AACA,aAAO,4CAAC,UAAgB,kBAAN,GAAW;AAAA,IAC/B,OAAO;AAEL,aACE,4CAAC,cAAAC,QAAM,UAAN,EACE;AAAA,QACC,EAAE,GAAG,OAAO,SAAS,MAAM,QAAQ;AAAA,QACnC;AAAA,MACF,KAJmB,GAKrB;AAAA,IAEJ;AAAA,EACF,CAAC,EACA,OAAO,OAAO;AACnB;","names":["import_react","Image","Link","React"]}
|
|
@@ -18,7 +18,7 @@ function renderTiptapContent(content, classNames) {
|
|
|
18
18
|
Tag,
|
|
19
19
|
{
|
|
20
20
|
id: slug,
|
|
21
|
-
className: classNames.heading || "mt-8 mb-4 font-bold text-
|
|
21
|
+
className: classNames.heading || "mt-8 mb-4 font-bold text-op-heading",
|
|
22
22
|
children: renderChildren(node.content, classNames)
|
|
23
23
|
},
|
|
24
24
|
index
|
|
@@ -33,10 +33,9 @@ function renderTiptapContent(content, classNames) {
|
|
|
33
33
|
"div",
|
|
34
34
|
{
|
|
35
35
|
className: cn(
|
|
36
|
-
"
|
|
36
|
+
"w-full max-w-[800px] my-10 rounded-lg overflow-hidden flex items-center justify-center",
|
|
37
37
|
classNames.image
|
|
38
38
|
),
|
|
39
|
-
style: { aspectRatio: "2 / 1" },
|
|
40
39
|
children: /* @__PURE__ */ jsx(
|
|
41
40
|
Image,
|
|
42
41
|
{
|
|
@@ -44,9 +43,9 @@ function renderTiptapContent(content, classNames) {
|
|
|
44
43
|
src: `${opinlyConfig.imagesPrefix}/${fileKey}`,
|
|
45
44
|
title: node.attrs?.title || "",
|
|
46
45
|
alt: node.attrs?.alt || "",
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
46
|
+
width: 800,
|
|
47
|
+
height: 400,
|
|
48
|
+
className: "rounded-lg max-w-full max-h-full"
|
|
50
49
|
}
|
|
51
50
|
)
|
|
52
51
|
},
|
|
@@ -88,7 +87,6 @@ const Content = ({
|
|
|
88
87
|
};
|
|
89
88
|
function renderChildren(nodes, classNames) {
|
|
90
89
|
if (!nodes) {
|
|
91
|
-
console.log("no nodes");
|
|
92
90
|
return [];
|
|
93
91
|
}
|
|
94
92
|
return nodes.map((child, idx) => {
|
|
@@ -112,7 +110,6 @@ function renderChildren(nodes, classNames) {
|
|
|
112
110
|
}
|
|
113
111
|
return /* @__PURE__ */ jsx("span", { children: text }, idx);
|
|
114
112
|
} else {
|
|
115
|
-
console.log("child", child);
|
|
116
113
|
return /* @__PURE__ */ jsx(React.Fragment, { children: renderTiptapContent(
|
|
117
114
|
{ ...child, content: child.content },
|
|
118
115
|
classNames
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/blog-post/_components/content.tsx"],"sourcesContent":["import type { JSONContent } from \"@tiptap/core\";\nimport { BlogComponentClassNames } from \"../_types/class-names\";\nimport { cn } from \"../../../utils/merge\";\nimport Link from \"next/link\";\nimport { JSX } from \"react\";\nimport Image from \"next/image\";\nimport { opinlyConfig } from \"../../../utils/sdk-config\";\nimport React from \"react\";\n\nfunction renderTiptapContent(\n content: JSONContent,\n classNames: BlogComponentClassNames\n): React.ReactNode[] {\n if (!content?.content) return [];\n\n return content.content\n .map((node, index) => {\n switch (node.type) {\n case \"paragraph\":\n return (\n <p key={index} className={classNames.paragraph || \"mb-4\"}>\n {renderChildren(node.content, classNames)}\n </p>\n );\n case \"heading\": {\n const text = node.content?.[0]?.text ?? \"\";\n const slug = text\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, \"-\")\n .replace(/^-+|-+$/g, \"\");\n const Tag = `h${\n node.attrs?.level || 1\n }` as keyof JSX.IntrinsicElements;\n return (\n <Tag\n key={index}\n id={slug}\n className={\n classNames.heading || \"mt-8 mb-4 font-bold text-
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/blog-post/_components/content.tsx"],"sourcesContent":["import type { JSONContent } from \"@tiptap/core\";\nimport { BlogComponentClassNames } from \"../_types/class-names\";\nimport { cn } from \"../../../utils/merge\";\nimport Link from \"next/link\";\nimport { JSX } from \"react\";\nimport Image from \"next/image\";\nimport { opinlyConfig } from \"../../../utils/sdk-config\";\nimport React from \"react\";\n\nfunction renderTiptapContent(\n content: JSONContent,\n classNames: BlogComponentClassNames\n): React.ReactNode[] {\n if (!content?.content) return [];\n\n return content.content\n .map((node, index) => {\n switch (node.type) {\n case \"paragraph\":\n return (\n <p key={index} className={classNames.paragraph || \"mb-4\"}>\n {renderChildren(node.content, classNames)}\n </p>\n );\n case \"heading\": {\n const text = node.content?.[0]?.text ?? \"\";\n const slug = text\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, \"-\")\n .replace(/^-+|-+$/g, \"\");\n const Tag = `h${\n node.attrs?.level || 1\n }` as keyof JSX.IntrinsicElements;\n return (\n <Tag\n key={index}\n id={slug}\n className={\n classNames.heading || \"mt-8 mb-4 font-bold text-op-heading\"\n }\n >\n {renderChildren(node.content, classNames)}\n </Tag>\n );\n }\n case \"image\":\n const fileKey = node.attrs?.fileKey;\n\n if (!fileKey) {\n return null;\n }\n\n return (\n <div\n key={index}\n className={cn(\n \"w-full max-w-[800px] my-10 rounded-lg overflow-hidden flex items-center justify-center\",\n classNames.image\n )}\n >\n <Image\n unoptimized={opinlyConfig.unoptimizedImages}\n src={`${opinlyConfig.imagesPrefix}/${fileKey}`}\n title={node.attrs?.title || \"\"}\n alt={node.attrs?.alt || \"\"}\n width={800}\n height={400}\n className=\"rounded-lg max-w-full max-h-full\"\n />\n </div>\n );\n case \"bulletList\":\n return (\n <ul\n key={index}\n className={cn(\"list-disc pl-6 my-4\", classNames.bulletList)}\n >\n {renderTiptapContent(node, classNames)}\n </ul>\n );\n case \"orderedList\":\n return (\n <ol\n key={index}\n className={cn(\"list-decimal pl-6 my-4\", classNames.orderedList)}\n >\n {renderTiptapContent(node, classNames)}\n </ol>\n );\n case \"listItem\":\n if (\n node.content &&\n node.content.length === 1 &&\n node.content[0].type === \"paragraph\"\n ) {\n return (\n <li key={index} className={cn(\"my-1\", classNames.listItem)}>\n {renderChildren(node.content[0].content, classNames)}\n </li>\n );\n }\n return (\n <li key={index} className={cn(\"my-1\", classNames.listItem)}>\n {renderChildren(node.content, classNames)}\n </li>\n );\n default:\n return null;\n }\n })\n .filter(Boolean);\n}\n\nexport const Content = ({\n content,\n classNames,\n}: {\n content: JSONContent;\n classNames: BlogComponentClassNames;\n}) => {\n return (\n <div className=\"prose min-w-full\">\n {renderTiptapContent(content, classNames)}\n </div>\n );\n};\n\nfunction renderChildren(\n nodes: JSONContent[\"content\"] | undefined,\n classNames: BlogComponentClassNames\n): JSX.Element[] {\n if (!nodes) {\n return [];\n }\n\n return nodes\n .map((child, idx) => {\n if (child.type === \"text\") {\n let text: React.ReactNode = child.text;\n if (child.marks) {\n child.marks.forEach((mark) => {\n if (mark.type === \"bold\") text = <strong key={idx}>{text}</strong>;\n if (mark.type === \"italic\") text = <em key={idx}>{text}</em>;\n if (mark.type === \"link\")\n text = (\n <Link\n key={idx}\n href={mark.attrs?.href}\n className={classNames.link || \"text-blue-600 underline\"}\n >\n {text}\n </Link>\n );\n });\n }\n return <span key={idx}>{text}</span>;\n } else {\n // Recursively render non-text nodes (e.g., paragraph, listItem, etc.)\n return (\n <React.Fragment key={idx}>\n {renderTiptapContent(\n { ...child, content: child.content },\n classNames\n )}\n </React.Fragment>\n );\n }\n })\n .filter(Boolean) as JSX.Element[];\n}\n"],"mappings":"AAoBY;AAlBZ,SAAS,UAAU;AACnB,OAAO,UAAU;AAEjB,OAAO,WAAW;AAClB,SAAS,oBAAoB;AAC7B,OAAO,WAAW;AAElB,SAAS,oBACP,SACA,YACmB;AACnB,MAAI,CAAC,SAAS,QAAS,QAAO,CAAC;AAE/B,SAAO,QAAQ,QACZ,IAAI,CAAC,MAAM,UAAU;AACpB,YAAQ,KAAK,MAAM;AAAA,MACjB,KAAK;AACH,eACE,oBAAC,OAAc,WAAW,WAAW,aAAa,QAC/C,yBAAe,KAAK,SAAS,UAAU,KADlC,KAER;AAAA,MAEJ,KAAK,WAAW;AACd,cAAM,OAAO,KAAK,UAAU,CAAC,GAAG,QAAQ;AACxC,cAAM,OAAO,KACV,YAAY,EACZ,QAAQ,eAAe,GAAG,EAC1B,QAAQ,YAAY,EAAE;AACzB,cAAM,MAAM,IACV,KAAK,OAAO,SAAS,CACvB;AACA,eACE;AAAA,UAAC;AAAA;AAAA,YAEC,IAAI;AAAA,YACJ,WACE,WAAW,WAAW;AAAA,YAGvB,yBAAe,KAAK,SAAS,UAAU;AAAA;AAAA,UANnC;AAAA,QAOP;AAAA,MAEJ;AAAA,MACA,KAAK;AACH,cAAM,UAAU,KAAK,OAAO;AAE5B,YAAI,CAAC,SAAS;AACZ,iBAAO;AAAA,QACT;AAEA,eACE;AAAA,UAAC;AAAA;AAAA,YAEC,WAAW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AO,CAAC;AAAA,EACV;AAEA,SAAO,MACJ,IAAI,CAAC,OAAO,QAAQ;AACnB,QAAI,MAAM,SAAS,QAAQ;AACzB,UAAI,OAAwB,MAAM;AAClC,UAAI,MAAM,OAAO;AACf,cAAM,MAAM,QAAQ,CAAC,SAAS;AAC5B,cAAI,KAAK,SAAS,OAAQ,QAAO,oBAAC,YAAkB,kBAAN,GAAW;AACzD,cAAI,KAAK,SAAS,SAAU,QAAO,oBAAC,QAAc,kBAAN,GAAW;AACvD,cAAI,KAAK,SAAS;AAChB,mBACE;AAAA,cAAC;AAAA;AAAA,gBAEC,MAAM,KAAK,OAAO;AAAA,gBAClB,WAAW,WAAW,QAAQ;AAAA,gBAE7B;AAAA;AAAA,cAJI;AAAA,YAKP;AAAA,QAEN,CAAC;AAAA,MACH;AACA,aAAO,oBAAC,UAAgB,kBAAN,GAAW;AAAA,IAC/B,OAAO;AAEL,aACE,oBAAC,MAAM,UAAN,EACE;AAAA,QACC,EAAE,GAAG,OAAO,SAAS,MAAM,QAAQ;AAAA,QACnC;AAAA,MACF,KAJmB,GAKrB;AAAA,IAEJ;AAAA,EACF,CAAC,EACA,OAAO,OAAO;AACnB;","names":[]}
|
|
@@ -27,8 +27,8 @@ const FAQS = ({ faqs }) => {
|
|
|
27
27
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
|
|
28
28
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h2", { className: "text-lg font-semibold mb-2", children: "FAQS" }),
|
|
29
29
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("ul", { children: faqs.map((faq) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("li", { children: [
|
|
30
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h3", { className: "text-lg font-semibold mb-2", children: faq.question }),
|
|
31
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "text-sm text-
|
|
30
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h3", { className: "text-lg text-op-heading font-semibold mb-2", children: faq.question }),
|
|
31
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "text-sm text-op-body", children: faq.answer })
|
|
32
32
|
] }, faq.question)) })
|
|
33
33
|
] });
|
|
34
34
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/blog-post/_components/faq.tsx"],"sourcesContent":["import { BlogPostRes } from \"../_types/blog-post\";\n\nexport const FAQS = ({ faqs }: { faqs: BlogPostRes[\"faqs\"] }) => {\n if (!faqs) return null;\n return (\n <div>\n <h2 className=\"text-lg font-semibold mb-2\">FAQS</h2>\n <ul>\n {faqs.map((faq) => (\n <li key={faq.question}>\n <h3 className=\"text-lg font-semibold mb-2\"
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/blog-post/_components/faq.tsx"],"sourcesContent":["import { BlogPostRes } from \"../_types/blog-post\";\n\nexport const FAQS = ({ faqs }: { faqs: BlogPostRes[\"faqs\"] }) => {\n if (!faqs) return null;\n return (\n <div>\n <h2 className=\"text-lg font-semibold mb-2\">FAQS</h2>\n <ul>\n {faqs.map((faq) => (\n <li key={faq.question}>\n <h3 className=\"text-lg text-op-heading font-semibold mb-2\">\n {faq.question}\n </h3>\n <p className=\"text-sm text-op-body\">{faq.answer}</p>\n </li>\n ))}\n </ul>\n </div>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAMM;AAJC,MAAM,OAAO,CAAC,EAAE,KAAK,MAAqC;AAC/D,MAAI,CAAC,KAAM,QAAO;AAClB,SACE,6CAAC,SACC;AAAA,gDAAC,QAAG,WAAU,8BAA6B,kBAAI;AAAA,IAC/C,4CAAC,QACE,eAAK,IAAI,CAAC,QACT,6CAAC,QACC;AAAA,kDAAC,QAAG,WAAU,8CACX,cAAI,UACP;AAAA,MACA,4CAAC,OAAE,WAAU,wBAAwB,cAAI,QAAO;AAAA,SAJzC,IAAI,QAKb,CACD,GACH;AAAA,KACF;AAEJ;","names":[]}
|
|
@@ -4,8 +4,8 @@ const FAQS = ({ faqs }) => {
|
|
|
4
4
|
return /* @__PURE__ */ jsxs("div", { children: [
|
|
5
5
|
/* @__PURE__ */ jsx("h2", { className: "text-lg font-semibold mb-2", children: "FAQS" }),
|
|
6
6
|
/* @__PURE__ */ jsx("ul", { children: faqs.map((faq) => /* @__PURE__ */ jsxs("li", { children: [
|
|
7
|
-
/* @__PURE__ */ jsx("h3", { className: "text-lg font-semibold mb-2", children: faq.question }),
|
|
8
|
-
/* @__PURE__ */ jsx("p", { className: "text-sm text-
|
|
7
|
+
/* @__PURE__ */ jsx("h3", { className: "text-lg text-op-heading font-semibold mb-2", children: faq.question }),
|
|
8
|
+
/* @__PURE__ */ jsx("p", { className: "text-sm text-op-body", children: faq.answer })
|
|
9
9
|
] }, faq.question)) })
|
|
10
10
|
] });
|
|
11
11
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/blog-post/_components/faq.tsx"],"sourcesContent":["import { BlogPostRes } from \"../_types/blog-post\";\n\nexport const FAQS = ({ faqs }: { faqs: BlogPostRes[\"faqs\"] }) => {\n if (!faqs) return null;\n return (\n <div>\n <h2 className=\"text-lg font-semibold mb-2\">FAQS</h2>\n <ul>\n {faqs.map((faq) => (\n <li key={faq.question}>\n <h3 className=\"text-lg font-semibold mb-2\"
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/blog-post/_components/faq.tsx"],"sourcesContent":["import { BlogPostRes } from \"../_types/blog-post\";\n\nexport const FAQS = ({ faqs }: { faqs: BlogPostRes[\"faqs\"] }) => {\n if (!faqs) return null;\n return (\n <div>\n <h2 className=\"text-lg font-semibold mb-2\">FAQS</h2>\n <ul>\n {faqs.map((faq) => (\n <li key={faq.question}>\n <h3 className=\"text-lg text-op-heading font-semibold mb-2\">\n {faq.question}\n </h3>\n <p className=\"text-sm text-op-body\">{faq.answer}</p>\n </li>\n ))}\n </ul>\n </div>\n );\n};\n"],"mappings":"AAMM,cAGI,YAHJ;AAJC,MAAM,OAAO,CAAC,EAAE,KAAK,MAAqC;AAC/D,MAAI,CAAC,KAAM,QAAO;AAClB,SACE,qBAAC,SACC;AAAA,wBAAC,QAAG,WAAU,8BAA6B,kBAAI;AAAA,IAC/C,oBAAC,QACE,eAAK,IAAI,CAAC,QACT,qBAAC,QACC;AAAA,0BAAC,QAAG,WAAU,8CACX,cAAI,UACP;AAAA,MACA,oBAAC,OAAE,WAAU,wBAAwB,cAAI,QAAO;AAAA,SAJzC,IAAI,QAKb,CACD,GACH;AAAA,KACF;AAEJ;","names":[]}
|
|
@@ -38,13 +38,17 @@ var import_sdk_config = require("../../../utils/sdk-config");
|
|
|
38
38
|
var import_extract_headings = require("../_helpers/extract-headings");
|
|
39
39
|
var import_share = require("./share");
|
|
40
40
|
var import_link = __toESM(require("next/link"), 1);
|
|
41
|
+
const headingColorMap = {
|
|
42
|
+
2: "text-op-heading",
|
|
43
|
+
3: "text-op-body"
|
|
44
|
+
};
|
|
41
45
|
const TableOfContents = ({
|
|
42
46
|
content,
|
|
43
47
|
author,
|
|
44
48
|
post
|
|
45
49
|
}) => {
|
|
46
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("
|
|
47
|
-
author && /* @__PURE__ */ (0, import_jsx_runtime.
|
|
50
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: (0, import_merge.cn)("w-full flex flex-col space-y-4"), children: [
|
|
51
|
+
author && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "w-full flex flex-col space-y-2 mb-6 border p-4 rounded-md text-sm", children: [
|
|
48
52
|
author.fileKey && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
49
53
|
import_image.default,
|
|
50
54
|
{
|
|
@@ -56,22 +60,45 @@ const TableOfContents = ({
|
|
|
56
60
|
className: "rounded-full"
|
|
57
61
|
}
|
|
58
62
|
),
|
|
59
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
|
|
63
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "w-full flex flex-col space-y-2", children: [
|
|
60
64
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
61
65
|
import_link.default,
|
|
62
66
|
{
|
|
63
67
|
href: `${import_sdk_config.opinlyConfig.blogPrefix}/authors/${author.slug}`,
|
|
64
|
-
className: "text-
|
|
68
|
+
className: "text-lg text-op-heading font-bold",
|
|
65
69
|
children: author.name
|
|
66
70
|
}
|
|
67
71
|
),
|
|
68
|
-
/* @__PURE__ */ (0, import_jsx_runtime.
|
|
72
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "w-48 ", children: [
|
|
73
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "text-op-muted text-sm w-56 break-words block md:hidden", children: author.bio && author.bio.length > 40 ? author.bio.slice(0, 40) + "..." : author.bio }),
|
|
74
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "text-op-muted text-sm w-48 hidden md:block", children: author.bio })
|
|
75
|
+
] })
|
|
69
76
|
] })
|
|
70
|
-
] })
|
|
77
|
+
] }),
|
|
71
78
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_share.Share, { post }),
|
|
72
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "border-l-4 border-
|
|
73
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h2", { className: "text-lg font-semibold mb-2", children: "
|
|
74
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("ul", { className: "text-sm
|
|
79
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "border-l-4 border-op-accent pl-4 mb-4", children: [
|
|
80
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h2", { className: "text-lg font-semibold mb-2", children: "Table of Contents" }),
|
|
81
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("ul", { className: "text-sm space-y-1", children: ((0, import_extract_headings.extractHeadings)(content) || []).map((heading) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
82
|
+
"li",
|
|
83
|
+
{
|
|
84
|
+
className: (0, import_merge.cn)(heading.level === 3 && "ml-2"),
|
|
85
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
86
|
+
"a",
|
|
87
|
+
{
|
|
88
|
+
href: `#${heading.slug}`,
|
|
89
|
+
className: (0, import_merge.cn)(
|
|
90
|
+
headingColorMap[heading.level]
|
|
91
|
+
),
|
|
92
|
+
children: [
|
|
93
|
+
heading.level === 3 && "-",
|
|
94
|
+
" ",
|
|
95
|
+
heading.text
|
|
96
|
+
]
|
|
97
|
+
}
|
|
98
|
+
)
|
|
99
|
+
},
|
|
100
|
+
heading.slug
|
|
101
|
+
)) })
|
|
75
102
|
] })
|
|
76
103
|
] });
|
|
77
104
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/blog-post/_components/table-of-contents.tsx"],"sourcesContent":["import { JSONContent } from \"@tiptap/core\";\nimport { BlogPostRes } from \"../_types/blog-post\";\nimport { cn } from \"../../../utils/merge\";\nimport Image from \"next/image\";\nimport { opinlyConfig } from \"../../../utils/sdk-config\";\nimport { extractHeadings } from \"../_helpers/extract-headings\";\nimport { Share } from \"./share\";\nimport Link from \"next/link\";\n\ntype TableOfContentsProps = {\n content: JSONContent;\n author: BlogPostRes[\"author\"] | null;\n post: BlogPostRes;\n};\n\nexport const TableOfContents = ({\n content,\n author,\n post,\n}: TableOfContentsProps) => {\n return (\n <
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/blog-post/_components/table-of-contents.tsx"],"sourcesContent":["import { JSONContent } from \"@tiptap/core\";\nimport { BlogPostRes } from \"../_types/blog-post\";\nimport { cn } from \"../../../utils/merge\";\nimport Image from \"next/image\";\nimport { opinlyConfig } from \"../../../utils/sdk-config\";\nimport { extractHeadings } from \"../_helpers/extract-headings\";\nimport { Share } from \"./share\";\nimport Link from \"next/link\";\n\ntype TableOfContentsProps = {\n content: JSONContent;\n author: BlogPostRes[\"author\"] | null;\n post: BlogPostRes;\n};\n\nconst headingColorMap = {\n 2: \"text-op-heading\",\n 3: \"text-op-body\",\n};\n\nexport const TableOfContents = ({\n content,\n author,\n post,\n}: TableOfContentsProps) => {\n return (\n <div className={cn(\"w-full flex flex-col space-y-4\")}>\n {author && (\n <div className=\"w-full flex flex-col space-y-2 mb-6 border p-4 rounded-md text-sm\">\n {author.fileKey && (\n <Image\n unoptimized={opinlyConfig.unoptimizedImages}\n src={`${opinlyConfig.imagesPrefix}/${author.fileKey}`}\n alt={author.name}\n width={48}\n height={48}\n className=\"rounded-full\"\n />\n )}\n <div className=\"w-full flex flex-col space-y-2\">\n <Link\n href={`${opinlyConfig.blogPrefix}/authors/${author.slug}`}\n className=\"text-lg text-op-heading font-bold\"\n >\n {author.name}\n </Link>\n <div className=\"w-48 \">\n {/* Mobile: show truncated bio */}\n <span className=\"text-op-muted text-sm w-56 break-words block md:hidden\">\n {author.bio && author.bio.length > 40\n ? author.bio.slice(0, 40) + \"...\"\n : author.bio}\n </span>\n {/* Desktop: show full bio */}\n <p className=\"text-op-muted text-sm w-48 hidden md:block\">\n {author.bio}\n </p>\n </div>\n </div>\n </div>\n )}\n <Share post={post} />\n <div className=\"border-l-4 border-op-accent pl-4 mb-4\">\n <h2 className=\"text-lg font-semibold mb-2\">Table of Contents</h2>\n <ul className=\"text-sm space-y-1\">\n {(extractHeadings(content) || []).map((heading) => (\n <li\n key={heading.slug}\n className={cn(heading.level === 3 && \"ml-2\")}\n >\n <a\n href={`#${heading.slug}`}\n className={cn(\n headingColorMap[heading.level as keyof typeof headingColorMap]\n )}\n >\n {heading.level === 3 && \"-\"} {heading.text}\n </a>\n </li>\n ))}\n </ul>\n </div>\n </div>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAA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