@opinly/next 0.1.4 → 0.1.6

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 CHANGED
@@ -1,14 +1,8 @@
1
1
  "use strict";
2
- var __create = Object.create;
3
2
  var __defProp = Object.defineProperty;
4
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
6
  var __copyProps = (to, from, except, desc) => {
13
7
  if (from && typeof from === "object" || typeof from === "function") {
14
8
  for (let key of __getOwnPropNames(from))
@@ -17,855 +11,15 @@ var __copyProps = (to, from, except, desc) => {
17
11
  }
18
12
  return to;
19
13
  };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
14
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
28
15
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
-
30
- // src/index.ts
31
16
  var index_exports = {};
32
- __export(index_exports, {
33
- HomePage: () => HomePage,
34
- OpinlyBlog: () => OpinlyBlog
35
- });
36
17
  module.exports = __toCommonJS(index_exports);
37
-
38
- // src/components/blog-post/index.tsx
39
- var import_link5 = __toESM(require("next/link"), 1);
40
-
41
- // src/utils/merge.ts
42
- var import_clsx = require("clsx");
43
- var import_tailwind_merge = require("tailwind-merge");
44
- var cn = (...inputs) => {
45
- return (0, import_tailwind_merge.twMerge)((0, import_clsx.clsx)(inputs));
46
- };
47
-
48
- // src/sdk-config.ts
49
- var siteUrl = process.env.OPINLY_SITE_URL;
50
- var opinlyEnvVars = {
51
- OPINLY_IMAGES_PREFIX: process.env.OPINLY_IMAGES_PREFIX,
52
- OPINLY_SITE_URL: process.env.OPINLY_SITE_URL,
53
- OPINLY_BLOG_PREFIX: process.env.OPINLY_BLOG_PREFIX,
54
- OPINLY_CDN_URL: process.env.OPINLY_CDN_URL,
55
- OPINLY_SITE_NAME: process.env.OPINLY_SITE_NAME
56
- };
57
- Object.entries(opinlyEnvVars).forEach(([key, value]) => {
58
- if (!value) {
59
- throw new Error(`OPINLY ERROR: env var ${key} is not set`);
60
- }
61
- });
62
- var opinlyConfig = {
63
- cdnUrl: process.env.OPINLY_CDN_URL || "https://cdn.opinly.ai",
64
- siteUrl: process.env.OPINLY_SITE_URL,
65
- imagesPrefix: process.env.OPINLY_IMAGES_PREFIX,
66
- imagesUrl: `${process.env.OPINLY_SITE_URL}${process.env.OPINLY_IMAGES_PREFIX}`,
67
- blogPrefix: process.env.OPINLY_BLOG_PREFIX,
68
- blogUrl: `${process.env.OPINLY_SITE_URL}${process.env.OPINLY_BLOG_PREFIX}`,
69
- siteName: process.env.OPINLY_SITE_NAME
70
- };
71
-
72
- // src/utils/images.ts
73
- function replaceImageNameSpace(fileKey) {
74
- const pathParts = fileKey.split("/").filter(Boolean);
75
- if (pathParts.length > 1) {
76
- pathParts.shift();
77
- }
78
- return pathParts.join("/");
79
- }
80
-
81
- // src/components/blog-post/_helpers/json-ld.ts
82
- function generateArticleBodyHtml(content) {
83
- if (!content?.content) return "";
84
- let htmlString = "";
85
- content.content.forEach((node) => {
86
- switch (node.type) {
87
- case "paragraph":
88
- htmlString += `<p>${generateChildrenHtml(node.content)}</p>`;
89
- break;
90
- case "heading":
91
- const headingLevel = node.attrs?.level || 1;
92
- htmlString += `<h${headingLevel}>${generateChildrenHtml(node.content)}</h${headingLevel}>`;
93
- break;
94
- case "bulletList":
95
- htmlString += `<ul>${generateChildrenHtml(node.content)}</ul>`;
96
- break;
97
- case "orderedList":
98
- htmlString += `<ol>${generateChildrenHtml(node.content)}</ol>`;
99
- break;
100
- case "listItem":
101
- htmlString += `<li>${generateChildrenHtml(node.content)}</li>`;
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;
111
- default:
112
- break;
113
- }
114
- });
115
- return htmlString;
116
- }
117
- function generateChildrenHtml(nodes) {
118
- if (!nodes) return "";
119
- let childrenHtml = "";
120
- nodes.forEach((child) => {
121
- if (child.type === "text") {
122
- let text = child.text || "";
123
- if (child.marks) {
124
- child.marks.forEach((mark) => {
125
- if (mark.type === "bold") text = `<strong>${text}</strong>`;
126
- if (mark.type === "italic") text = `<em>${text}</em>`;
127
- if (mark.type === "link" && mark.attrs?.href) {
128
- text = `<a href="${mark.attrs.href}">${text}</a>`;
129
- }
130
- });
131
- }
132
- childrenHtml += text;
133
- }
134
- });
135
- return childrenHtml;
136
- }
137
- var genFaqJSONLD = (faqs) => {
138
- return {
139
- "@context": "https://schema.org",
140
- "@type": "FAQPage",
141
- mainEntity: faqs.map((faq) => ({
142
- "@type": "Question",
143
- name: faq.question,
144
- acceptedAnswer: {
145
- "@type": "Answer",
146
- text: faq.answer
147
- }
148
- }))
149
- };
150
- };
151
- var genBlogPostingJSONLD = (post) => {
152
- return {
153
- "@context": "https://schema.org",
154
- "@type": "BlogPosting",
155
- headline: post.title,
156
- description: post.description || void 0,
157
- url: `${opinlyConfig.blogUrl}/${post.folder ? `${post.folder.slug + "/"}${post.slug}` : post.slug}`,
158
- datePublished: post.firstPublishedAt || void 0,
159
- dateModified: post.modifiedAt || void 0,
160
- image: post.titleFile?.fileKey ? {
161
- "@type": "ImageObject",
162
- url: `${opinlyConfig.imagesUrl}/${replaceImageNameSpace(post.titleFile.fileKey)}`
163
- } : void 0,
164
- author: post.author ? {
165
- "@type": "Person",
166
- name: post.author.name,
167
- url: `${opinlyConfig.blogUrl}/author/${post.author.slug}`,
168
- description: post.author.bio || void 0
169
- } : void 0,
170
- isAccessibleForFree: true,
171
- articleBody: generateArticleBodyHtml(post.content)
172
- };
173
- };
174
- var genBreadcrumbJSONLD = (post) => {
175
- const itemListElement = [
176
- {
177
- "@type": "ListItem",
178
- position: 1,
179
- name: "Company Name",
180
- item: opinlyConfig.siteUrl
181
- },
182
- {
183
- "@type": "ListItem",
184
- position: 2,
185
- name: post.folder?.name || "Blog",
186
- item: `${opinlyConfig.blogUrl}/blog`
187
- }
188
- ];
189
- if (post.folder) {
190
- itemListElement.push({
191
- "@type": "ListItem",
192
- position: 3,
193
- name: post.folder.name,
194
- item: `${opinlyConfig.blogUrl}/blog/${post.folder.slug}`
195
- });
196
- itemListElement.push({
197
- "@type": "ListItem",
198
- position: 4,
199
- name: post.title,
200
- item: `${opinlyConfig.blogUrl}/blog/${post.folder.slug}/${post.slug}`
201
- });
202
- } else {
203
- itemListElement.push({
204
- "@type": "ListItem",
205
- position: 3,
206
- name: post.title,
207
- item: `${opinlyConfig.blogUrl}/blog/${post.slug}`
208
- });
209
- }
210
- return {
211
- "@context": "https://schema.org",
212
- "@type": "BreadcrumbList",
213
- itemListElement
214
- };
215
- };
216
-
217
- // src/components/blog-post/_components/faq.tsx
218
- var import_jsx_runtime = require("react/jsx-runtime");
219
- var FAQS = ({ faqs }) => {
220
- if (!faqs) return null;
221
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
222
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h2", { className: "text-lg font-semibold mb-2", children: "FAQS" }),
223
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("ul", { children: faqs.map((faq) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("li", { children: [
224
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h3", { className: "text-lg font-semibold mb-2", children: faq.question }),
225
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "text-sm text-gray-700", children: faq.answer })
226
- ] }, faq.question)) })
227
- ] });
228
- };
229
-
230
- // src/components/blog-post/_helpers/reading-time.ts
231
- var countWords = (content) => {
232
- if (!content?.content) return 0;
233
- let wordCount = 0;
234
- const countWords2 = (nodes) => {
235
- for (const node of nodes) {
236
- if (node.type === "text" && node.text) {
237
- const words = node.text.trim().split(/\s+/).filter(Boolean);
238
- wordCount += words.length;
239
- }
240
- if (node.content) countWords2(node.content);
241
- }
242
- };
243
- countWords2(content.content);
244
- return wordCount;
245
- };
246
- function calculateReadingTime(content) {
247
- const wordCount = countWords(content.content);
248
- const readingTimeMinutes = Math.ceil(wordCount / 200);
249
- return readingTimeMinutes;
250
- }
251
-
252
- // src/components/blog-post/_components/content.tsx
253
- var import_link = __toESM(require("next/link"), 1);
254
- var import_jsx_runtime2 = require("react/jsx-runtime");
255
- function renderTiptapContent(content, classNames) {
256
- if (!content?.content) return [];
257
- return content.content.map((node, index) => {
258
- switch (node.type) {
259
- case "paragraph":
260
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: classNames.paragraph || "mb-4", children: renderChildren(node.content, classNames) }, index);
261
- case "heading": {
262
- const text = node.content?.[0]?.text ?? "";
263
- const slug = text.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
264
- const Tag = `h${node.attrs?.level || 1}`;
265
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
266
- Tag,
267
- {
268
- id: slug,
269
- className: classNames.heading || "mt-8 mb-4 font-bold text-gray-800",
270
- children: renderChildren(node.content, classNames)
271
- },
272
- index
273
- );
274
- }
275
- case "image":
276
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
277
- "div",
278
- {
279
- className: cn(
280
- "relative w-full max-w-[800px] my-6",
281
- classNames.image
282
- ),
283
- style: { aspectRatio: "2 / 1" }
284
- },
285
- index
286
- );
287
- case "bulletList":
288
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
289
- "ul",
290
- {
291
- className: classNames.bulletList || "list-disc pl-6 my-4",
292
- children: renderChildren(node.content, classNames)
293
- },
294
- index
295
- );
296
- case "orderedList":
297
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
298
- "ol",
299
- {
300
- className: classNames.orderedList || "list-decimal pl-6 my-4",
301
- children: renderChildren(node.content, classNames)
302
- },
303
- index
304
- );
305
- case "listItem":
306
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("li", { className: classNames.listItem || "my-1", children: renderChildren(node.content, classNames) }, index);
307
- default:
308
- return null;
309
- }
310
- }).filter(Boolean);
311
- }
312
- var Content = ({
313
- content,
314
- classNames
315
- }) => {
316
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "prose min-w-full", children: renderTiptapContent(content, classNames) });
317
- };
318
- function renderChildren(nodes, classNames) {
319
- if (!nodes) return [];
320
- return nodes.map((child, idx) => {
321
- if (child.type === "text") {
322
- let text = child.text;
323
- if (child.marks) {
324
- child.marks.forEach((mark) => {
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);
327
- if (mark.type === "link")
328
- text = /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
329
- import_link.default,
330
- {
331
- href: mark.attrs?.href,
332
- className: classNames.link || "text-blue-600 underline",
333
- children: text
334
- },
335
- idx
336
- );
337
- });
338
- }
339
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: text }, idx);
340
- }
341
- return null;
342
- }).filter(Boolean);
343
- }
344
-
345
- // src/components/blog-post/_components/table-of-contents.tsx
346
- var import_image = __toESM(require("next/image"), 1);
347
-
348
- // src/components/blog-post/_helpers/extract-headings.ts
349
- function extractHeadings(content) {
350
- const headings = [];
351
- if (!content?.content) return headings;
352
- const walk = (nodes) => {
353
- for (const node of nodes) {
354
- if (node.type === "heading" && node.content?.[0]?.text) {
355
- const text = node.content[0].text;
356
- const slug = text.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
357
- headings.push({ text, slug });
358
- }
359
- if (node.content) walk(node.content);
360
- }
361
- };
362
- walk(content.content);
363
- return headings;
364
- }
365
-
366
- // src/components/blog-post/_components/share.tsx
367
- var import_lucide_react = require("lucide-react");
368
- var import_link2 = __toESM(require("next/link"), 1);
369
- var import_jsx_runtime3 = require("react/jsx-runtime");
370
- var Share = ({ post }) => {
371
- const postUrl = encodeURIComponent(`${opinlyConfig.blogUrl}/${post.slug}`);
372
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "flex gap-2 mb-6", children: [
373
- /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
374
- import_link2.default,
375
- {
376
- href: `https://linkedin.com/sharing/share-offsite?url=${postUrl}`,
377
- target: "_blank",
378
- rel: "noopener noreferrer",
379
- className: "border p-1 rounded flex items-center justify-center w-8 h-8",
380
- children: [
381
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "sr-only", children: "Share on LinkedIn" }),
382
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_lucide_react.Linkedin, { className: "w-4 h-4" })
383
- ]
384
- }
385
- ),
386
- /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
387
- import_link2.default,
388
- {
389
- href: `https://twitter.com/intent/tweet?url=${postUrl}&text=${encodeURIComponent(
390
- `Check out this article by ${post.author?.name}`
391
- )}`,
392
- target: "_blank",
393
- rel: "noopener noreferrer",
394
- className: "border p-1 rounded flex items-center justify-center w-8 h-8",
395
- children: [
396
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "sr-only", children: "Share on Twitter" }),
397
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_lucide_react.Twitter, {})
398
- ]
399
- }
400
- ),
401
- /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
402
- import_link2.default,
403
- {
404
- href: `https://facebook.com/sharer/sharer.php?u=${postUrl}`,
405
- target: "_blank",
406
- rel: "noopener noreferrer",
407
- className: "border p-1 rounded flex items-center justify-center w-8 h-8",
408
- children: [
409
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "sr-only", children: "Share on Facebook" }),
410
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_lucide_react.Facebook, {})
411
- ]
412
- }
413
- ),
414
- /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
415
- import_link2.default,
416
- {
417
- href: `mailto:?body=${encodeURIComponent(`${post.title}
418
- ${postUrl}`)}`,
419
- className: "border p-1 rounded flex items-center justify-center w-8 h-8",
420
- children: [
421
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "sr-only", children: "Share via Email" }),
422
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_lucide_react.Mail, { className: "w-4 h-4" })
423
- ]
424
- }
425
- )
426
- ] });
427
- };
428
-
429
- // src/components/blog-post/_components/table-of-contents.tsx
430
- var import_link3 = __toESM(require("next/link"), 1);
431
- var import_jsx_runtime4 = require("react/jsx-runtime");
432
- var TableOfContents = ({
433
- content,
434
- author,
435
- post
436
- }) => {
437
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("aside", { className: cn("w-full lg:w-1/3 lg:sticky lg:top-20 lg:self-start"), children: [
438
- author && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "w-full mb-6 border p-4 rounded-md text-sm", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "flex items-center gap-3 mb-3", children: [
439
- author.fileKey && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
440
- import_image.default,
441
- {
442
- src: `${opinlyConfig.imagesPrefix}/${replaceImageNameSpace(author.fileKey)}`,
443
- alt: author.name,
444
- width: 48,
445
- height: 48,
446
- className: "rounded-full"
447
- }
448
- ),
449
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { children: [
450
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
451
- import_link3.default,
452
- {
453
- href: `${opinlyConfig.blogPrefix}/authors/${author.slug}`,
454
- className: "text-xs uppercase text-muted-foreground font-medium",
455
- children: author.name
456
- }
457
- ),
458
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "text-muted-foreground text-sm", children: author.bio })
459
- ] })
460
- ] }) }),
461
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Share, { post }),
462
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "border-l-4 border-opinlyAccent pl-4 mb-4", children: [
463
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("h2", { className: "text-lg font-semibold mb-2", children: "TABLE OF CONTENTS" }),
464
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("ul", { className: "text-sm text-gray-700 space-y-1", children: (extractHeadings(content) || []).map((heading) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("li", { children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("a", { href: `#${heading.slug}`, className: "hover:underline", children: heading.text }) }, heading.slug)) })
465
- ] })
466
- ] });
467
- };
468
-
469
- // src/components/bread-crumbs.tsx
470
- var import_link4 = __toESM(require("next/link"), 1);
471
- var import_react = require("react");
472
- var import_jsx_runtime5 = require("react/jsx-runtime");
473
- var BreadCrumbs = ({
474
- breadcrumbs
475
- }) => {
476
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("nav", { className: "text-sm text-orange-100 text-muted-foreground mb-4", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("ol", { className: "list-reset flex space-x-2", children: [
477
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_link4.default, { href: "/", className: "font-bold", children: opinlyConfig.siteName }),
478
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { children: "/" }),
479
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_link4.default, { href: opinlyConfig.blogPrefix, className: "font-bold", children: "Blog" }),
480
- breadcrumbs?.map((breadcrumb, index) => {
481
- if (!breadcrumb) {
482
- return null;
483
- }
484
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_react.Fragment, { children: [
485
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { children: "/" }),
486
- breadcrumb.url ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_link4.default, { href: breadcrumb.url, className: "font-bold", children: breadcrumb.name }) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "font-bold", children: breadcrumb.name })
487
- ] }, index);
488
- })
489
- ] }) });
490
- };
491
-
492
- // src/utils/dates.ts
493
- var formatDate = (iso) => new Date(iso).toLocaleDateString("en-US", {
494
- month: "short",
495
- day: "2-digit",
496
- year: "numeric"
497
- });
498
-
499
- // src/components/blog-post/index.tsx
500
- var import_script = __toESM(require("next/script"), 1);
501
- var import_jsx_runtime6 = require("react/jsx-runtime");
502
- var BlogPost = ({
503
- post,
504
- classNames = {}
505
- }) => {
506
- const content = post.content;
507
- console.log("content", content);
508
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
509
- post.faqs && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
510
- import_script.default,
511
- {
512
- strategy: "beforeInteractive",
513
- type: "application/ld+json",
514
- dangerouslySetInnerHTML: {
515
- __html: JSON.stringify(genFaqJSONLD(post.faqs)).replace(
516
- /</g,
517
- "\\u003c"
518
- )
519
- }
520
- }
521
- ),
522
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
523
- import_script.default,
524
- {
525
- strategy: "beforeInteractive",
526
- type: "application/ld+json",
527
- dangerouslySetInnerHTML: {
528
- __html: JSON.stringify(genBlogPostingJSONLD(post))
529
- }
530
- }
531
- ),
532
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
533
- import_script.default,
534
- {
535
- strategy: "beforeInteractive",
536
- type: "application/ld+json",
537
- dangerouslySetInnerHTML: {
538
- __html: JSON.stringify(genBreadcrumbJSONLD(post))
539
- }
540
- }
541
- ),
542
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "max-w-7xl mx-auto px-4 py-24 flex items-start space-x-8", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "flex flex-col gap-12 w-full", children: [
543
- /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "bg-orange-600", children: [
544
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
545
- BreadCrumbs,
546
- {
547
- breadcrumbs: [
548
- post.folder && {
549
- url: `${opinlyConfig.blogPrefix}/${post.folder.slug}`,
550
- name: post.folder.name
551
- }
552
- ]
553
- }
554
- ),
555
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("h1", { className: "text-4xl font-bold mb-2 leading-tight", children: post.title }),
556
- /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "text-sm mb-4", children: [
557
- "Author:",
558
- " ",
559
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
560
- import_link5.default,
561
- {
562
- href: `${opinlyConfig.blogPrefix}/authors/${post.author?.slug}`,
563
- className: "font-medium",
564
- children: post.author?.name
565
- }
566
- ),
567
- " ",
568
- "\xB7 ",
569
- calculateReadingTime(content),
570
- " min read \xB7",
571
- " ",
572
- formatDate(post.firstPublishedAt) || "Today"
573
- ] })
574
- ] }),
575
- /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
576
- "div",
577
- {
578
- className: cn(
579
- "flex flex-col-reverse md:flex-row mx-auto mt-10 gap-12 relative w-full ",
580
- classNames.container
581
- ),
582
- children: [
583
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("article", { className: "w-full lg:w-2/3 order-2 lg:order-1 flex items-start space-x-4", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "prose w-full", children: [
584
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Content, { content, classNames }),
585
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(FAQS, { faqs: post.faqs })
586
- ] }) }),
587
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "block md:min-w-72 md:sticky md:top-20 md:self-start", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
588
- TableOfContents,
589
- {
590
- content,
591
- author: post.author,
592
- post
593
- }
594
- ) })
595
- ]
596
- }
597
- )
598
- ] }) })
599
- ] });
600
- };
601
-
602
- // src/components/post-preview.tsx
603
- var import_link6 = __toESM(require("next/link"), 1);
604
- var import_image2 = __toESM(require("next/image"), 1);
605
- var import_jsx_runtime7 = require("react/jsx-runtime");
606
- var PostPreview = ({
607
- post
608
- }) => {
609
- const postSlug = `${opinlyConfig.blogPrefix}/${post.folder?.slug ? `${post.folder.slug}/` : ""}${post.slug}`;
610
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { children: [
611
- post.image?.fileKey && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_link6.default, { href: postSlug, className: "group", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "relative w-full h-48 mb-4", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
612
- import_image2.default,
613
- {
614
- src: `${opinlyConfig.imagesPrefix}/${replaceImageNameSpace(post.image.fileKey)}`,
615
- alt: post.title,
616
- fill: true,
617
- className: "object-cover rounded-lg"
618
- }
619
- ) }) }, post.slug),
620
- /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "text-sm text-muted-foreground mb-1", children: [
621
- post.folder?.name && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, { children: [
622
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
623
- import_link6.default,
624
- {
625
- href: `${opinlyConfig.blogPrefix}/${post.folder.slug}`,
626
- className: "hover:underline",
627
- children: post.folder.name
628
- }
629
- ),
630
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "mx-1", children: "\xB7" })
631
- ] }),
632
- " ",
633
- formatDate(post.firstPublishedAt)
634
- ] }),
635
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_link6.default, { href: postSlug, className: "group", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("h2", { className: "text-lg font-semibold leading-snug group-hover:underline", children: post.title }) }, post.slug),
636
- post.description && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("p", { className: "text-sm text-gray-600 mt-1 line-clamp-2", children: post.description }),
637
- /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "text-xs text-gray-500 mt-2", children: [
638
- post.author && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, { children: [
639
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
640
- import_link6.default,
641
- {
642
- href: `${opinlyConfig.blogPrefix}/authors/${post.author.slug}`,
643
- className: "font-medium hover:underline",
644
- children: post.author?.name
645
- }
646
- ),
647
- " ",
648
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "mx-1", children: "\xB7" })
649
- ] }),
650
- " ",
651
- formatDate(post.firstPublishedAt)
652
- ] })
653
- ] });
654
- };
655
-
656
- // src/components/folder-page/index.tsx
657
- var import_jsx_runtime8 = require("react/jsx-runtime");
658
- var FolderPage = ({
659
- folder
660
- }) => {
661
- console.log("folder", JSON.stringify(folder, null, 2));
662
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "max-w-6xl mx-auto px-4 py-10", children: [
663
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(BreadCrumbs, {}),
664
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("h1", { className: "text-4xl font-bold mb-2", children: folder.name }),
665
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { className: "text-muted-foreground max-w-2xl mb-8", children: folder.description || `Explore articles about ${folder.name}.` }),
666
- /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-8", children: [
667
- folder.posts.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "text-muted-foreground", children: "No posts added yet" }),
668
- folder.posts.map((post) => {
669
- console.log("post.image", post.image);
670
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(PostPreview, { post }, post.slug);
671
- })
672
- ] })
673
- ] });
674
- };
675
-
676
- // src/components/home-page.tsx
677
- var import_link7 = __toESM(require("next/link"), 1);
678
- var import_jsx_runtime9 = require("react/jsx-runtime");
679
- var HomePage = ({
680
- homePage,
681
- page
682
- }) => {
683
- const { posts, folders, count } = homePage;
684
- console.log("posts", JSON.stringify(posts, null, 2));
685
- const currentPage = page;
686
- const totalPages = Math.ceil(count / 10);
687
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "max-w-7xl mx-auto px-4 py-10", children: [
688
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-10", children: posts.map((post) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(PostPreview, { post }, post.slug)) }),
689
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "flex justify-center items-center mt-10 gap-2", children: Array.from({ length: totalPages }, (_, i) => i + 1).map((p) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
690
- import_link7.default,
691
- {
692
- href: `?page=${p}`,
693
- className: `px-3 py-1 border rounded ${p === currentPage ? "bg-black text-white" : "hover:bg-gray-100 text-gray-700"}`,
694
- children: p
695
- },
696
- p
697
- )) }),
698
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "flex flex-wrap gap-2 mb-10", children: folders.map((folder) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
699
- import_link7.default,
700
- {
701
- href: `/blog/${folder.slug}`,
702
- className: "px-4 py-1 bg-gray-100 text-sm rounded-full hover:bg-gray-200",
703
- children: folder.title
704
- },
705
- folder.slug
706
- )) })
707
- ] });
708
- };
709
-
710
- // src/components/author-page/index.tsx
711
- var import_image3 = __toESM(require("next/image"), 1);
712
- var import_jsx_runtime10 = require("react/jsx-runtime");
713
- var AuthorPage = ({
714
- author
715
- }) => {
716
- return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "max-w-5xl mx-auto px-4 py-10", children: [
717
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
718
- BreadCrumbs,
719
- {
720
- breadcrumbs: [
721
- {
722
- name: "Authors",
723
- url: `${opinlyConfig.blogPrefix}/authors`
724
- }
725
- ]
726
- }
727
- ),
728
- /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "flex items-center gap-6 mb-10", children: [
729
- author.image.fileKey && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
730
- import_image3.default,
731
- {
732
- src: `${opinlyConfig.imagesPrefix}/${replaceImageNameSpace(author.image.fileKey)}`,
733
- alt: author.image.alt || author.name,
734
- width: 150,
735
- height: 150,
736
- className: "rounded-full border"
737
- }
738
- ),
739
- /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { children: [
740
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("h1", { className: "text-3xl font-bold mb-1", children: author.name }),
741
- author.bio && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("p", { className: "text-muted-foreground text-base max-w-2xl", children: author.bio })
742
- ] })
743
- ] }),
744
- /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("h2", { className: "text-xl font-semibold mb-6", children: [
745
- "Posts by ",
746
- author.name
747
- ] }),
748
- /* @__PURE__ */ (0, import_jsx_runtime10.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(
749
- (post) => post && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(PostPreview, { post }, post.slug)
750
- ) : /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "text-muted-foreground col-span-full", children: "No posts yet." }) })
751
- ] });
752
- };
753
-
754
- // src/components/not-found.tsx
755
- var import_link8 = __toESM(require("next/link"), 1);
756
- var import_jsx_runtime11 = require("react/jsx-runtime");
757
- var OpinlyNotFound = () => {
758
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_jsx_runtime11.Fragment, { children: [
759
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "bg-orange-600 py-10", children: /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "max-w-7xl mx-auto px-4", children: [
760
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("h1", { className: "text-4xl font-bold mb-2 leading-tight text-white", children: "Post Not Found" }),
761
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "text-sm mb-4 text-orange-100", children: "The post you're looking for doesn't exist or has been removed." })
762
- ] }) }),
763
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "flex max-w-7xl mx-auto mt-10 gap-12", children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("article", { className: "w-2/3", children: /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "prose max-w-none", children: [
764
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("p", { className: "text-gray-600", children: "You can try:" }),
765
- /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("ul", { className: "list-disc pl-6 my-4", children: [
766
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("li", { children: "Checking the URL for typos" }),
767
- /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("li", { children: [
768
- "Returning to the",
769
- " ",
770
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_link8.default, { href: "/blog", className: "text-blue-600 underline", children: "blog homepage" })
771
- ] }),
772
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("li", { children: "Using the search function to find what you're looking for" })
773
- ] })
774
- ] }) }) })
775
- ] });
776
- };
777
-
778
- // src/components/authors-page/index.tsx
779
- var import_image4 = __toESM(require("next/image"), 1);
780
- var import_link9 = __toESM(require("next/link"), 1);
781
- var import_jsx_runtime12 = require("react/jsx-runtime");
782
- var AuthorsPage = ({
783
- authors
784
- }) => {
785
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "max-w-5xl mx-auto px-4 py-10", children: [
786
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
787
- BreadCrumbs,
788
- {
789
- breadcrumbs: [
790
- {
791
- name: "Authors"
792
- }
793
- ]
794
- }
795
- ),
796
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("h1", { className: "text-3xl font-bold mb-10", children: "Authors" }),
797
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "space-y-16", children: authors.map((author, idx) => {
798
- const authorSlug = `${opinlyConfig.blogPrefix}/authors/${author.slug}`;
799
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
800
- "div",
801
- {
802
- className: "rounded-lg p-6 flex flex-col gap-6",
803
- children: [
804
- /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "flex items-center gap-6 mb-4", children: [
805
- author.image?.fileKey && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_link9.default, { href: authorSlug, children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
806
- import_image4.default,
807
- {
808
- src: `${opinlyConfig.imagesPrefix}/${replaceImageNameSpace(author.image.fileKey)}`,
809
- alt: author.image.alt || author.name,
810
- width: 100,
811
- height: 100,
812
- className: "rounded-full border"
813
- }
814
- ) }),
815
- /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { children: [
816
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_link9.default, { href: authorSlug, children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("h2", { className: "text-2xl font-semibold mb-1", children: author.name }) }),
817
- author.bio && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("p", { className: "text-muted-foreground text-base max-w-2xl", children: author.bio })
818
- ] })
819
- ] }),
820
- /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { children: [
821
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-6 mb-4", children: author.posts && author.posts.length > 0 ? author.posts.map(
822
- (post) => post && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(PostPreview, { post }, post.slug)
823
- ) : /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "text-muted-foreground col-span-full", children: "No posts yet." }) }),
824
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "flex justify-end", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
825
- import_link9.default,
826
- {
827
- href: `${opinlyConfig.blogPrefix}/authors/${author.slug}`,
828
- className: "text-bold",
829
- children: [
830
- "View more posts from ",
831
- author.name
832
- ]
833
- }
834
- ) })
835
- ] })
836
- ]
837
- },
838
- author.name + idx
839
- );
840
- }) })
841
- ] });
842
- };
843
-
844
- // src/components/opinly-blog.tsx
845
- var import_jsx_runtime13 = require("react/jsx-runtime");
846
- var OpinlyBlog = ({
847
- blog,
848
- page
849
- }) => {
850
- if (blog.type === "not-found") {
851
- return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(OpinlyNotFound, {});
852
- }
853
- if (blog.type === "home") {
854
- return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(HomePage, { homePage: blog.data, page });
855
- }
856
- if (blog.type === "post") {
857
- return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(BlogPost, { post: blog.data });
858
- }
859
- if (blog.type === "author") {
860
- return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(AuthorPage, { author: blog.data });
861
- }
862
- if (blog.type === "authors") {
863
- return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(AuthorsPage, { authors: blog.data });
864
- }
865
- return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(FolderPage, { folder: blog.data });
866
- };
18
+ __reExport(index_exports, require("./components/opinly-blog"), module.exports);
19
+ __reExport(index_exports, require("./components/home-page"), module.exports);
867
20
  // Annotate the CommonJS export names for ESM import in node:
868
21
  0 && (module.exports = {
869
- HomePage,
870
- OpinlyBlog
22
+ ...require("./components/opinly-blog"),
23
+ ...require("./components/home-page")
871
24
  });
25
+ //# sourceMappingURL=index.cjs.map