@opinly/next 0.1.14 → 0.1.16

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.
Files changed (153) hide show
  1. package/dist/components/author-page/_helpers/json-ld.cjs +2 -0
  2. package/dist/components/author-page/_helpers/json-ld.js +0 -1
  3. package/dist/components/author-page/index.cjs +84 -0
  4. package/dist/components/author-page/{index.mjs.map → index.cjs.map} +1 -1
  5. package/dist/components/author-page/index.js +23 -57
  6. package/dist/components/author-page/index.js.map +1 -1
  7. package/dist/components/authors-page/index.cjs +105 -0
  8. package/dist/components/authors-page/{index.mjs.map → index.cjs.map} +1 -1
  9. package/dist/components/authors-page/index.js +29 -63
  10. package/dist/components/authors-page/index.js.map +1 -1
  11. package/dist/components/blog-post/_components/content.cjs +160 -0
  12. package/dist/components/blog-post/_components/{content.mjs.map → content.cjs.map} +1 -1
  13. package/dist/components/blog-post/_components/content.js +29 -63
  14. package/dist/components/blog-post/_components/content.js.map +1 -1
  15. package/dist/components/blog-post/_components/faq.cjs +39 -0
  16. package/dist/components/blog-post/_components/{faq.mjs.map → faq.cjs.map} +1 -1
  17. package/dist/components/blog-post/_components/faq.js +8 -32
  18. package/dist/components/blog-post/_components/faq.js.map +1 -1
  19. package/dist/components/blog-post/_components/share.cjs +100 -0
  20. package/dist/components/blog-post/_components/{share.mjs.map → share.cjs.map} +1 -1
  21. package/dist/components/blog-post/_components/share.js +24 -58
  22. package/dist/components/blog-post/_components/share.js.map +1 -1
  23. package/dist/components/blog-post/_components/table-of-contents.cjs +82 -0
  24. package/dist/components/blog-post/_components/{table-of-contents.mjs.map → table-of-contents.cjs.map} +1 -1
  25. package/dist/components/blog-post/_components/table-of-contents.js +24 -58
  26. package/dist/components/blog-post/_components/table-of-contents.js.map +1 -1
  27. package/dist/components/blog-post/_helpers/calc-reading-time.cjs +2 -0
  28. package/dist/components/blog-post/_helpers/calc-reading-time.js +0 -1
  29. package/dist/components/blog-post/_helpers/extract-headings.cjs +44 -0
  30. package/dist/components/blog-post/_helpers/{extract-headings.mjs.map → extract-headings.cjs.map} +1 -1
  31. package/dist/components/blog-post/_helpers/extract-headings.js +2 -26
  32. package/dist/components/blog-post/_helpers/extract-headings.js.map +1 -1
  33. package/dist/components/blog-post/_helpers/{json-ld.mjs → json-ld.cjs} +39 -12
  34. package/dist/components/blog-post/_helpers/{json-ld.mjs.map → json-ld.cjs.map} +1 -1
  35. package/dist/components/blog-post/_helpers/json-ld.js +11 -38
  36. package/dist/components/blog-post/_helpers/json-ld.js.map +1 -1
  37. package/dist/components/blog-post/_helpers/reading-time.cjs +50 -0
  38. package/dist/components/blog-post/_helpers/{reading-time.mjs.map → reading-time.cjs.map} +1 -1
  39. package/dist/components/blog-post/_helpers/reading-time.js +2 -27
  40. package/dist/components/blog-post/_helpers/reading-time.js.map +1 -1
  41. package/dist/components/blog-post/_types/blog-post.cjs +17 -0
  42. package/dist/components/blog-post/_types/blog-post.cjs.map +1 -0
  43. package/dist/components/blog-post/_types/blog-post.js +0 -16
  44. package/dist/components/blog-post/_types/blog-post.js.map +1 -1
  45. package/dist/components/blog-post/_types/class-names.cjs +17 -0
  46. package/dist/components/blog-post/_types/class-names.cjs.map +1 -0
  47. package/dist/components/blog-post/_types/class-names.js +0 -16
  48. package/dist/components/blog-post/_types/class-names.js.map +1 -1
  49. package/dist/components/blog-post/index.cjs +148 -0
  50. package/dist/components/blog-post/{index.mjs.map → index.cjs.map} +1 -1
  51. package/dist/components/blog-post/index.js +47 -77
  52. package/dist/components/blog-post/index.js.map +1 -1
  53. package/dist/components/bread-crumbs.cjs +60 -0
  54. package/dist/components/{bread-crumbs.mjs.map → bread-crumbs.cjs.map} +1 -1
  55. package/dist/components/bread-crumbs.js +13 -47
  56. package/dist/components/bread-crumbs.js.map +1 -1
  57. package/dist/components/folder-page/index.cjs +61 -0
  58. package/dist/components/folder-page/{index.mjs.map → index.cjs.map} +1 -1
  59. package/dist/components/folder-page/index.js +12 -36
  60. package/dist/components/folder-page/index.js.map +1 -1
  61. package/dist/components/home-page/folders.cjs +98 -0
  62. package/dist/components/home-page/{folders.mjs.map → folders.cjs.map} +1 -1
  63. package/dist/components/home-page/folders.js +29 -64
  64. package/dist/components/home-page/folders.js.map +1 -1
  65. package/dist/components/home-page/index.cjs +44 -0
  66. package/dist/components/home-page/{index.mjs.map → index.cjs.map} +1 -1
  67. package/dist/components/home-page/index.js +11 -35
  68. package/dist/components/home-page/index.js.map +1 -1
  69. package/dist/components/home-page/pagination.cjs +91 -0
  70. package/dist/components/home-page/{pagination.mjs.map → pagination.cjs.map} +1 -1
  71. package/dist/components/home-page/pagination.js +9 -43
  72. package/dist/components/home-page/pagination.js.map +1 -1
  73. package/dist/components/home-page/top-posts.cjs +52 -0
  74. package/dist/components/home-page/{top-posts.mjs.map → top-posts.cjs.map} +1 -1
  75. package/dist/components/home-page/top-posts.js +10 -34
  76. package/dist/components/home-page/top-posts.js.map +1 -1
  77. package/dist/components/not-found.cjs +60 -0
  78. package/dist/components/{not-found.mjs.map → not-found.cjs.map} +1 -1
  79. package/dist/components/not-found.js +15 -49
  80. package/dist/components/not-found.js.map +1 -1
  81. package/dist/components/opinly-blog.cjs +57 -0
  82. package/dist/components/{opinly-blog.mjs.map → opinly-blog.cjs.map} +1 -1
  83. package/dist/components/opinly-blog.js +15 -39
  84. package/dist/components/opinly-blog.js.map +1 -1
  85. package/dist/components/post-preview.cjs +112 -0
  86. package/dist/components/{post-preview.mjs.map → post-preview.cjs.map} +1 -1
  87. package/dist/components/post-preview.js +42 -77
  88. package/dist/components/post-preview.js.map +1 -1
  89. package/dist/index.cjs +25 -0
  90. package/dist/index.cjs.map +1 -0
  91. package/dist/index.d.cts +3 -0
  92. package/dist/index.d.ts +3 -0
  93. package/dist/index.js +2 -22
  94. package/dist/index.js.map +1 -1
  95. package/dist/utils/dates.cjs +33 -0
  96. package/dist/utils/{dates.mjs.map → dates.cjs.map} +1 -1
  97. package/dist/utils/dates.js +2 -26
  98. package/dist/utils/dates.js.map +1 -1
  99. package/dist/utils/generate-metadata.cjs +62 -0
  100. package/dist/utils/generate-metadata.cjs.map +1 -0
  101. package/dist/utils/generate-metadata.js +9 -31
  102. package/dist/utils/generate-metadata.js.map +1 -1
  103. package/dist/utils/merge.cjs +33 -0
  104. package/dist/utils/{merge.mjs.map → merge.cjs.map} +1 -1
  105. package/dist/utils/merge.js +5 -29
  106. package/dist/utils/merge.js.map +1 -1
  107. package/dist/utils/sdk-config.cjs +51 -0
  108. package/dist/utils/sdk-config.cjs.map +1 -0
  109. package/dist/utils/sdk-config.d.cts +10 -2
  110. package/dist/utils/sdk-config.d.ts +10 -2
  111. package/dist/utils/sdk-config.js +3 -34
  112. package/dist/utils/sdk-config.js.map +1 -1
  113. package/dist/utils/with-opinly-config.cjs +115 -0
  114. package/dist/utils/with-opinly-config.cjs.map +1 -0
  115. package/dist/utils/with-opinly-config.d.cts +39 -0
  116. package/dist/utils/with-opinly-config.d.ts +39 -0
  117. package/dist/utils/with-opinly-config.js +91 -0
  118. package/dist/utils/with-opinly-config.js.map +1 -0
  119. package/package.json +3 -2
  120. package/dist/components/author-page/_helpers/json-ld.mjs +0 -1
  121. package/dist/components/author-page/index.mjs +0 -50
  122. package/dist/components/authors-page/index.mjs +0 -71
  123. package/dist/components/blog-post/_components/content.mjs +0 -126
  124. package/dist/components/blog-post/_components/faq.mjs +0 -15
  125. package/dist/components/blog-post/_components/share.mjs +0 -66
  126. package/dist/components/blog-post/_components/table-of-contents.mjs +0 -48
  127. package/dist/components/blog-post/_helpers/calc-reading-time.mjs +0 -1
  128. package/dist/components/blog-post/_helpers/extract-headings.mjs +0 -20
  129. package/dist/components/blog-post/_helpers/reading-time.mjs +0 -25
  130. package/dist/components/blog-post/_types/blog-post.mjs +0 -1
  131. package/dist/components/blog-post/_types/blog-post.mjs.map +0 -1
  132. package/dist/components/blog-post/_types/class-names.mjs +0 -1
  133. package/dist/components/blog-post/_types/class-names.mjs.map +0 -1
  134. package/dist/components/blog-post/index.mjs +0 -118
  135. package/dist/components/bread-crumbs.mjs +0 -26
  136. package/dist/components/folder-page/index.mjs +0 -37
  137. package/dist/components/home-page/folders.mjs +0 -63
  138. package/dist/components/home-page/index.mjs +0 -20
  139. package/dist/components/home-page/pagination.mjs +0 -57
  140. package/dist/components/home-page/top-posts.mjs +0 -28
  141. package/dist/components/not-found.mjs +0 -26
  142. package/dist/components/opinly-blog.mjs +0 -33
  143. package/dist/components/post-preview.mjs +0 -77
  144. package/dist/index.mjs +0 -2
  145. package/dist/index.mjs.map +0 -1
  146. package/dist/utils/dates.mjs +0 -9
  147. package/dist/utils/generate-metadata.mjs +0 -36
  148. package/dist/utils/generate-metadata.mjs.map +0 -1
  149. package/dist/utils/merge.mjs +0 -9
  150. package/dist/utils/sdk-config.mjs +0 -32
  151. package/dist/utils/sdk-config.mjs.map +0 -1
  152. /package/dist/components/author-page/_helpers/{json-ld.mjs.map → json-ld.cjs.map} +0 -0
  153. /package/dist/components/blog-post/_helpers/{calc-reading-time.mjs.map → calc-reading-time.cjs.map} +0 -0
@@ -1,126 +0,0 @@
1
- import { jsx } from "react/jsx-runtime";
2
- import { cn } from "../../../utils/merge";
3
- import Link from "next/link";
4
- import Image from "next/image";
5
- import { opinlyConfig } from "../../../utils/sdk-config";
6
- import React from "react";
7
- function renderTiptapContent(content, classNames) {
8
- if (!content?.content) return [];
9
- return content.content.map((node, index) => {
10
- switch (node.type) {
11
- case "paragraph":
12
- return /* @__PURE__ */ jsx("p", { className: classNames.paragraph || "mb-4", children: renderChildren(node.content, classNames) }, index);
13
- case "heading": {
14
- const text = node.content?.[0]?.text ?? "";
15
- const slug = text.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
16
- const Tag = `h${node.attrs?.level || 1}`;
17
- return /* @__PURE__ */ jsx(
18
- Tag,
19
- {
20
- id: slug,
21
- className: classNames.heading || "mt-8 mb-4 font-bold text-gray-800",
22
- children: renderChildren(node.content, classNames)
23
- },
24
- index
25
- );
26
- }
27
- case "image":
28
- const fileKey = node.attrs?.fileKey;
29
- if (!fileKey) {
30
- return null;
31
- }
32
- return /* @__PURE__ */ jsx(
33
- "div",
34
- {
35
- className: cn(
36
- "relative w-full max-w-[800px] my-6",
37
- classNames.image
38
- ),
39
- style: { aspectRatio: "2 / 1" },
40
- children: /* @__PURE__ */ jsx(
41
- Image,
42
- {
43
- unoptimized: opinlyConfig.unoptimizedImages,
44
- src: `${opinlyConfig.imagesPrefix}/${fileKey}`,
45
- title: node.attrs?.title || "",
46
- alt: node.attrs?.alt || "",
47
- fill: true,
48
- className: "object-contain rounded-lg",
49
- sizes: "(max-width: 800px) 100vw, 800px"
50
- }
51
- )
52
- },
53
- index
54
- );
55
- case "bulletList":
56
- return /* @__PURE__ */ jsx(
57
- "ul",
58
- {
59
- className: cn("list-disc pl-6 my-4", classNames.bulletList),
60
- children: renderTiptapContent(node, classNames)
61
- },
62
- index
63
- );
64
- case "orderedList":
65
- return /* @__PURE__ */ jsx(
66
- "ol",
67
- {
68
- className: cn("list-decimal pl-6 my-4", classNames.orderedList),
69
- children: renderTiptapContent(node, classNames)
70
- },
71
- index
72
- );
73
- case "listItem":
74
- if (node.content && node.content.length === 1 && node.content[0].type === "paragraph") {
75
- return /* @__PURE__ */ jsx("li", { className: cn("my-1", classNames.listItem), children: renderChildren(node.content[0].content, classNames) }, index);
76
- }
77
- return /* @__PURE__ */ jsx("li", { className: cn("my-1", classNames.listItem), children: renderChildren(node.content, classNames) }, index);
78
- default:
79
- return null;
80
- }
81
- }).filter(Boolean);
82
- }
83
- const Content = ({
84
- content,
85
- classNames
86
- }) => {
87
- return /* @__PURE__ */ jsx("div", { className: "prose min-w-full", children: renderTiptapContent(content, classNames) });
88
- };
89
- function renderChildren(nodes, classNames) {
90
- if (!nodes) {
91
- console.log("no nodes");
92
- return [];
93
- }
94
- return nodes.map((child, idx) => {
95
- if (child.type === "text") {
96
- let text = child.text;
97
- if (child.marks) {
98
- child.marks.forEach((mark) => {
99
- if (mark.type === "bold") text = /* @__PURE__ */ jsx("strong", { children: text }, idx);
100
- if (mark.type === "italic") text = /* @__PURE__ */ jsx("em", { children: text }, idx);
101
- if (mark.type === "link")
102
- text = /* @__PURE__ */ jsx(
103
- Link,
104
- {
105
- href: mark.attrs?.href,
106
- className: classNames.link || "text-blue-600 underline",
107
- children: text
108
- },
109
- idx
110
- );
111
- });
112
- }
113
- return /* @__PURE__ */ jsx("span", { children: text }, idx);
114
- } else {
115
- console.log("child", child);
116
- return /* @__PURE__ */ jsx(React.Fragment, { children: renderTiptapContent(
117
- { ...child, content: child.content },
118
- classNames
119
- ) }, idx);
120
- }
121
- }).filter(Boolean);
122
- }
123
- export {
124
- Content
125
- };
126
- //# sourceMappingURL=content.mjs.map
@@ -1,15 +0,0 @@
1
- import { jsx, jsxs } from "react/jsx-runtime";
2
- const FAQS = ({ faqs }) => {
3
- if (!faqs) return null;
4
- return /* @__PURE__ */ jsxs("div", { children: [
5
- /* @__PURE__ */ jsx("h2", { className: "text-lg font-semibold mb-2", children: "FAQS" }),
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-gray-700", children: faq.answer })
9
- ] }, faq.question)) })
10
- ] });
11
- };
12
- export {
13
- FAQS
14
- };
15
- //# sourceMappingURL=faq.mjs.map
@@ -1,66 +0,0 @@
1
- import { jsx, jsxs } from "react/jsx-runtime";
2
- import { Facebook, Linkedin, Mail, Twitter } from "lucide-react";
3
- import Link from "next/link";
4
- import { opinlyConfig } from "../../../utils/sdk-config";
5
- const Share = ({ post }) => {
6
- const postUrl = encodeURIComponent(`${opinlyConfig.blogUrl}/${post.slug}`);
7
- return /* @__PURE__ */ jsxs("div", { className: "flex gap-2 mb-6", children: [
8
- /* @__PURE__ */ jsxs(
9
- Link,
10
- {
11
- href: `https://linkedin.com/sharing/share-offsite?url=${postUrl}`,
12
- target: "_blank",
13
- rel: "noopener noreferrer",
14
- className: "border p-1 rounded flex items-center justify-center w-8 h-8",
15
- children: [
16
- /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Share on LinkedIn" }),
17
- /* @__PURE__ */ jsx(Linkedin, { className: "w-4 h-4" })
18
- ]
19
- }
20
- ),
21
- /* @__PURE__ */ jsxs(
22
- Link,
23
- {
24
- href: `https://twitter.com/intent/tweet?url=${postUrl}&text=${encodeURIComponent(
25
- `Check out this article by ${post.author?.name}`
26
- )}`,
27
- target: "_blank",
28
- rel: "noopener noreferrer",
29
- className: "border p-1 rounded flex items-center justify-center w-8 h-8",
30
- children: [
31
- /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Share on Twitter" }),
32
- /* @__PURE__ */ jsx(Twitter, {})
33
- ]
34
- }
35
- ),
36
- /* @__PURE__ */ jsxs(
37
- Link,
38
- {
39
- href: `https://facebook.com/sharer/sharer.php?u=${postUrl}`,
40
- target: "_blank",
41
- rel: "noopener noreferrer",
42
- className: "border p-1 rounded flex items-center justify-center w-8 h-8",
43
- children: [
44
- /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Share on Facebook" }),
45
- /* @__PURE__ */ jsx(Facebook, {})
46
- ]
47
- }
48
- ),
49
- /* @__PURE__ */ jsxs(
50
- Link,
51
- {
52
- href: `mailto:?body=${encodeURIComponent(`${post.title}
53
- ${postUrl}`)}`,
54
- className: "border p-1 rounded flex items-center justify-center w-8 h-8",
55
- children: [
56
- /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Share via Email" }),
57
- /* @__PURE__ */ jsx(Mail, { className: "w-4 h-4" })
58
- ]
59
- }
60
- )
61
- ] });
62
- };
63
- export {
64
- Share
65
- };
66
- //# sourceMappingURL=share.mjs.map
@@ -1,48 +0,0 @@
1
- import { jsx, jsxs } from "react/jsx-runtime";
2
- import { cn } from "../../../utils/merge";
3
- import Image from "next/image";
4
- import { opinlyConfig } from "../../../utils/sdk-config";
5
- import { extractHeadings } from "../_helpers/extract-headings";
6
- import { Share } from "./share";
7
- import Link from "next/link";
8
- const TableOfContents = ({
9
- content,
10
- author,
11
- post
12
- }) => {
13
- return /* @__PURE__ */ jsxs("aside", { className: cn("w-full lg:w-1/3 lg:sticky lg:top-20 lg:self-start"), children: [
14
- author && /* @__PURE__ */ jsx("div", { className: "w-full mb-6 border p-4 rounded-md text-sm", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3 mb-3", children: [
15
- author.fileKey && /* @__PURE__ */ jsx(
16
- Image,
17
- {
18
- unoptimized: opinlyConfig.unoptimizedImages,
19
- src: `${opinlyConfig.imagesPrefix}/${author.fileKey}`,
20
- alt: author.name,
21
- width: 48,
22
- height: 48,
23
- className: "rounded-full"
24
- }
25
- ),
26
- /* @__PURE__ */ jsxs("div", { children: [
27
- /* @__PURE__ */ jsx(
28
- Link,
29
- {
30
- href: `${opinlyConfig.blogPrefix}/authors/${author.slug}`,
31
- className: "text-xs uppercase text-muted-foreground font-medium",
32
- children: author.name
33
- }
34
- ),
35
- /* @__PURE__ */ jsx("div", { className: "text-muted-foreground text-sm", children: author.bio })
36
- ] })
37
- ] }) }),
38
- /* @__PURE__ */ jsx(Share, { post }),
39
- /* @__PURE__ */ jsxs("div", { className: "border-l-4 border-opinlyAccent pl-4 mb-4", children: [
40
- /* @__PURE__ */ jsx("h2", { className: "text-lg font-semibold mb-2", children: "TABLE OF CONTENTS" }),
41
- /* @__PURE__ */ jsx("ul", { className: "text-sm text-gray-700 space-y-1", children: (extractHeadings(content) || []).map((heading) => /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsx("a", { href: `#${heading.slug}`, className: "hover:underline", children: heading.text }) }, heading.slug)) })
42
- ] })
43
- ] });
44
- };
45
- export {
46
- TableOfContents
47
- };
48
- //# sourceMappingURL=table-of-contents.mjs.map
@@ -1 +0,0 @@
1
- //# sourceMappingURL=calc-reading-time.mjs.map
@@ -1,20 +0,0 @@
1
- function extractHeadings(content) {
2
- const headings = [];
3
- if (!content?.content) return headings;
4
- const walk = (nodes) => {
5
- for (const node of nodes) {
6
- if (node.type === "heading" && node.content?.[0]?.text) {
7
- const text = node.content[0].text;
8
- const slug = text.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
9
- headings.push({ text, slug });
10
- }
11
- if (node.content) walk(node.content);
12
- }
13
- };
14
- walk(content.content);
15
- return headings;
16
- }
17
- export {
18
- extractHeadings
19
- };
20
- //# sourceMappingURL=extract-headings.mjs.map
@@ -1,25 +0,0 @@
1
- const countWords = (content) => {
2
- if (!content?.content) return 0;
3
- let wordCount = 0;
4
- const countWords2 = (nodes) => {
5
- for (const node of nodes) {
6
- if (node.type === "text" && node.text) {
7
- const words = node.text.trim().split(/\s+/).filter(Boolean);
8
- wordCount += words.length;
9
- }
10
- if (node.content) countWords2(node.content);
11
- }
12
- };
13
- countWords2(content.content);
14
- return wordCount;
15
- };
16
- function calculateReadingTime(content) {
17
- const wordCount = countWords(content.content);
18
- const readingTimeMinutes = Math.ceil(wordCount / 200);
19
- return readingTimeMinutes;
20
- }
21
- export {
22
- calculateReadingTime,
23
- countWords
24
- };
25
- //# sourceMappingURL=reading-time.mjs.map
@@ -1 +0,0 @@
1
- //# sourceMappingURL=blog-post.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1 +0,0 @@
1
- //# sourceMappingURL=class-names.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1,118 +0,0 @@
1
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
- import Link from "next/link";
3
- import { cn } from "../../utils/merge";
4
- import { opinlyConfig } from "../../utils/sdk-config";
5
- import {
6
- genBlogPostingJSONLD,
7
- genBreadcrumbJSONLD,
8
- genFaqJSONLD
9
- } from "./_helpers/json-ld";
10
- import { FAQS } from "./_components/faq";
11
- import { calculateReadingTime } from "./_helpers/reading-time";
12
- import { Content } from "./_components/content";
13
- import { TableOfContents } from "./_components/table-of-contents";
14
- import { BreadCrumbs } from "../bread-crumbs";
15
- import { formatDate } from "../../utils/dates";
16
- import Script from "next/script";
17
- const BlogPost = ({
18
- post,
19
- classNames = {}
20
- }) => {
21
- const content = post.content;
22
- return /* @__PURE__ */ jsxs(Fragment, { children: [
23
- post.faqs && /* @__PURE__ */ jsx(
24
- Script,
25
- {
26
- strategy: "beforeInteractive",
27
- type: "application/ld+json",
28
- dangerouslySetInnerHTML: {
29
- __html: JSON.stringify(genFaqJSONLD(post.faqs)).replace(
30
- /</g,
31
- "\\u003c"
32
- )
33
- }
34
- }
35
- ),
36
- /* @__PURE__ */ jsx(
37
- Script,
38
- {
39
- strategy: "beforeInteractive",
40
- type: "application/ld+json",
41
- dangerouslySetInnerHTML: {
42
- __html: JSON.stringify(genBlogPostingJSONLD(post))
43
- }
44
- }
45
- ),
46
- /* @__PURE__ */ jsx(
47
- Script,
48
- {
49
- strategy: "beforeInteractive",
50
- type: "application/ld+json",
51
- dangerouslySetInnerHTML: {
52
- __html: JSON.stringify(genBreadcrumbJSONLD(post))
53
- }
54
- }
55
- ),
56
- /* @__PURE__ */ jsx("div", { className: "max-w-7xl mx-auto px-4 py-24 flex items-start space-x-8", children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-12 w-full", children: [
57
- /* @__PURE__ */ jsxs("div", { className: "bg-orange-600", children: [
58
- /* @__PURE__ */ jsx(
59
- BreadCrumbs,
60
- {
61
- breadcrumbs: [
62
- post.folder && {
63
- url: `${opinlyConfig.blogPrefix}/${post.folder.slug}`,
64
- name: post.folder.name
65
- }
66
- ]
67
- }
68
- ),
69
- /* @__PURE__ */ jsx("h1", { className: "text-4xl font-bold mb-2 leading-tight", children: post.title }),
70
- /* @__PURE__ */ jsxs("div", { className: "text-sm mb-4", children: [
71
- "Author:",
72
- " ",
73
- /* @__PURE__ */ jsx(
74
- Link,
75
- {
76
- href: `${opinlyConfig.blogPrefix}/authors/${post.author?.slug}`,
77
- className: "font-medium",
78
- children: post.author?.name
79
- }
80
- ),
81
- " ",
82
- "\xB7 ",
83
- calculateReadingTime(content),
84
- " min read \xB7",
85
- " ",
86
- formatDate(post.firstPublishedAt) || "Today"
87
- ] })
88
- ] }),
89
- /* @__PURE__ */ jsxs(
90
- "div",
91
- {
92
- className: cn(
93
- "flex flex-col-reverse md:flex-row mx-auto mt-10 gap-12 relative w-full ",
94
- classNames.container
95
- ),
96
- children: [
97
- /* @__PURE__ */ jsx("article", { className: "w-full lg:w-2/3 order-2 lg:order-1 flex items-start space-x-4", children: /* @__PURE__ */ jsxs("div", { className: "prose w-full", children: [
98
- /* @__PURE__ */ jsx(Content, { content, classNames }),
99
- /* @__PURE__ */ jsx(FAQS, { faqs: post.faqs })
100
- ] }) }),
101
- /* @__PURE__ */ jsx("div", { className: "block md:min-w-72 md:sticky md:top-20 md:self-start", children: /* @__PURE__ */ jsx(
102
- TableOfContents,
103
- {
104
- content,
105
- author: post.author,
106
- post
107
- }
108
- ) })
109
- ]
110
- }
111
- )
112
- ] }) })
113
- ] });
114
- };
115
- export {
116
- BlogPost
117
- };
118
- //# sourceMappingURL=index.mjs.map
@@ -1,26 +0,0 @@
1
- import { jsx, jsxs } from "react/jsx-runtime";
2
- import Link from "next/link";
3
- import { Fragment } from "react";
4
- import { opinlyConfig } from "../utils/sdk-config";
5
- const BreadCrumbs = ({
6
- breadcrumbs
7
- }) => {
8
- return /* @__PURE__ */ jsx("nav", { className: "text-sm text-orange-100 text-muted-foreground mb-4", children: /* @__PURE__ */ jsxs("ol", { className: "list-reset flex space-x-2", children: [
9
- /* @__PURE__ */ jsx(Link, { href: "/", className: "font-bold", children: opinlyConfig.siteName }),
10
- /* @__PURE__ */ jsx("span", { children: "/" }),
11
- /* @__PURE__ */ jsx(Link, { href: opinlyConfig.blogPrefix, className: "font-bold", children: "Blog" }),
12
- breadcrumbs?.map((breadcrumb, index) => {
13
- if (!breadcrumb) {
14
- return null;
15
- }
16
- return /* @__PURE__ */ jsxs(Fragment, { children: [
17
- /* @__PURE__ */ jsx("span", { children: "/" }),
18
- breadcrumb.url ? /* @__PURE__ */ jsx(Link, { href: breadcrumb.url, className: "font-bold", children: breadcrumb.name }) : /* @__PURE__ */ jsx("span", { className: "font-bold", children: breadcrumb.name })
19
- ] }, index);
20
- })
21
- ] }) });
22
- };
23
- export {
24
- BreadCrumbs
25
- };
26
- //# sourceMappingURL=bread-crumbs.mjs.map
@@ -1,37 +0,0 @@
1
- import { jsx, jsxs } from "react/jsx-runtime";
2
- import { PostPreview } from "../post-preview";
3
- import { BreadCrumbs } from "../bread-crumbs";
4
- const FolderPage = ({
5
- folder
6
- }) => {
7
- console.log("folder", JSON.stringify(folder, null, 2));
8
- return /* @__PURE__ */ jsxs("div", { className: "max-w-6xl mx-auto px-4 py-10", children: [
9
- /* @__PURE__ */ jsx(BreadCrumbs, {}),
10
- /* @__PURE__ */ jsx("h1", { className: "text-4xl font-bold mb-2", children: folder.name }),
11
- /* @__PURE__ */ jsx("p", { className: "text-muted-foreground max-w-2xl mb-8", children: folder.description || `Explore articles about ${folder.name}.` }),
12
- /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-8", children: [
13
- folder.posts.length === 0 && /* @__PURE__ */ jsx("div", { className: "text-muted-foreground", children: "No posts added yet" }),
14
- folder.posts.map((post) => {
15
- console.log("post.image", post.image);
16
- return /* @__PURE__ */ jsx(PostPreview, { post }, post.slug);
17
- })
18
- ] })
19
- ] });
20
- };
21
- function formatDate(dateStr) {
22
- return new Date(dateStr).toLocaleDateString("en-GB", {
23
- day: "2-digit",
24
- month: "short",
25
- year: "numeric"
26
- });
27
- }
28
- function formatMinutes(description) {
29
- if (!description) return "5 min read";
30
- const words = description.split(" ").length;
31
- const mins = Math.ceil(words / 200);
32
- return `${mins} min read`;
33
- }
34
- export {
35
- FolderPage
36
- };
37
- //# sourceMappingURL=index.mjs.map
@@ -1,63 +0,0 @@
1
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
- import Link from "next/link";
3
- import { PostPreview } from "../post-preview";
4
- import { ArrowRight } from "lucide-react";
5
- import { Suspense } from "react";
6
- const HomePageFoldersSkeleton = () => {
7
- return /* @__PURE__ */ jsx(Fragment, { children: Array(2).fill(null).map((_, sectionIdx) => /* @__PURE__ */ jsxs("div", { className: "space-y-4 mb-5", children: [
8
- /* @__PURE__ */ jsxs("div", { className: "animate-pulse space-y-2", children: [
9
- /* @__PURE__ */ jsx("div", { className: "h-8 w-1/3 bg-gray-200 dark:bg-gray-700 rounded" }),
10
- /* @__PURE__ */ jsx("div", { className: "h-4 w-1/2 bg-gray-200 dark:bg-gray-700 rounded" })
11
- ] }),
12
- /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-10", children: [
13
- Array(3).fill(null).map((__, postIdx) => /* @__PURE__ */ jsxs("div", { className: "animate-pulse space-y-3", children: [
14
- /* @__PURE__ */ jsx("div", { className: "w-full h-48 bg-gray-200 dark:bg-gray-700 rounded-lg" }),
15
- /* @__PURE__ */ jsx("div", { className: "h-5 w-3/4 bg-gray-200 dark:bg-gray-700 rounded" }),
16
- /* @__PURE__ */ jsx("div", { className: "h-4 w-full bg-gray-200 dark:bg-gray-700 rounded" })
17
- ] }, postIdx)),
18
- /* @__PURE__ */ jsx("div", { className: "flex justify-center items-center animate-pulse", children: /* @__PURE__ */ jsx("div", { className: "h-4 w-48 bg-gray-200 dark:bg-gray-700 rounded" }) })
19
- ] })
20
- ] }, sectionIdx)) });
21
- };
22
- const HomePageFoldersServer = async ({ client }) => {
23
- const folders = await client.client.content.homePageFolders.query();
24
- return /* @__PURE__ */ jsx(Fragment, { children: folders.map((folder) => /* @__PURE__ */ jsxs("div", { className: "space-y-4 ", children: [
25
- /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2 mb-20", children: [
26
- /* @__PURE__ */ jsx(
27
- Link,
28
- {
29
- href: `/blog/${folder.slug}`,
30
- className: "text-3xl",
31
- children: folder.title
32
- },
33
- folder.slug
34
- ),
35
- /* @__PURE__ */ jsx("p", { className: "text-sm text-gray-500", children: folder.description })
36
- ] }),
37
- /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-10 mb-20", children: [
38
- folder.posts.filter((post) => post !== null).map((post) => /* @__PURE__ */ jsx(PostPreview, { post }, post.slug)),
39
- /* @__PURE__ */ jsx("div", { className: "flex justify-center w-full h-full items-center ", children: /* @__PURE__ */ jsxs(
40
- Link,
41
- {
42
- href: `/blog/${folder.slug}`,
43
- className: "flex items-center gap-2",
44
- children: [
45
- /* @__PURE__ */ jsxs("span", { children: [
46
- "View all posts in ",
47
- folder.title
48
- ] }),
49
- /* @__PURE__ */ jsx(ArrowRight, { className: "w-4 h-4" })
50
- ]
51
- }
52
- ) })
53
- ] })
54
- ] })) });
55
- };
56
- const HomePageFolders = ({ client }) => {
57
- return /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx(HomePageFoldersSkeleton, {}), children: /* @__PURE__ */ jsx(HomePageFoldersServer, { client }) });
58
- };
59
- export {
60
- HomePageFolders,
61
- HomePageFoldersSkeleton
62
- };
63
- //# sourceMappingURL=folders.mjs.map
@@ -1,20 +0,0 @@
1
- import { jsx, jsxs } from "react/jsx-runtime";
2
- import { Suspense } from "react";
3
- import { TopPosts } from "./top-posts";
4
- import { HomePageFolders } from "./folders";
5
- import { HomePagePagination } from "./pagination";
6
- const HomePage = ({
7
- searchParams,
8
- client
9
- }) => {
10
- const parsedPage = searchParams.page ? parseInt(searchParams.page) : 1;
11
- return /* @__PURE__ */ jsxs("div", { className: "max-w-7xl mx-auto px-4 py-10", children: [
12
- /* @__PURE__ */ jsx("div", { className: "grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-10", children: /* @__PURE__ */ jsx(TopPosts, { client, page: parsedPage }) }),
13
- /* @__PURE__ */ jsx("div", { className: "flex justify-center items-center mt-10 gap-2", children: /* @__PURE__ */ jsx(HomePagePagination, { client, page: parsedPage }) }),
14
- /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-10 mt-20", children: /* @__PURE__ */ jsx(Suspense, { children: /* @__PURE__ */ jsx(HomePageFolders, { client }) }) })
15
- ] });
16
- };
17
- export {
18
- HomePage
19
- };
20
- //# sourceMappingURL=index.mjs.map
@@ -1,57 +0,0 @@
1
- import { jsx } from "react/jsx-runtime";
2
- import Link from "next/link";
3
- import { cn } from "../../utils/merge";
4
- const HomePagePagination = async ({
5
- client,
6
- page
7
- }) => {
8
- const count = await client.client.content.postsCount.query();
9
- const totalPages = Math.ceil(count / 9);
10
- const pages = [];
11
- if (totalPages <= 5) {
12
- for (let i = 1; i <= totalPages; i++) {
13
- pages.push(i);
14
- }
15
- } else {
16
- let start, end;
17
- if (page <= 3) {
18
- start = 1;
19
- end = 5;
20
- } else if (page >= totalPages - 2) {
21
- start = totalPages - 4;
22
- end = totalPages;
23
- } else {
24
- start = page - 2;
25
- end = page + 2;
26
- }
27
- if (start > 1) {
28
- pages.push(1);
29
- if (start > 2) pages.push("ellipsis");
30
- }
31
- for (let i = start; i <= end; i++) {
32
- pages.push(i);
33
- }
34
- if (end < totalPages) {
35
- if (end < totalPages - 1) pages.push("ellipsis");
36
- pages.push(totalPages);
37
- }
38
- }
39
- return /* @__PURE__ */ jsx("nav", { "aria-label": "Pagination", children: /* @__PURE__ */ jsx("div", { className: "flex items-center space-x-1", children: pages.map(
40
- (p, idx) => p === "ellipsis" ? /* @__PURE__ */ jsx("span", { className: "px-2", children: "\u2026" }, `el-${idx}`) : /* @__PURE__ */ jsx(
41
- Link,
42
- {
43
- href: `?page=${p}`,
44
- className: cn(
45
- "w-10 h-10 flex items-center justify-center rounded-md",
46
- page === p ? "bg-primary text-white bg-black" : "border border-gray-200 dark:border-gray-700"
47
- ),
48
- children: p
49
- },
50
- p
51
- )
52
- ) }) });
53
- };
54
- export {
55
- HomePagePagination
56
- };
57
- //# sourceMappingURL=pagination.mjs.map