@opinly/next 0.1.17 → 0.1.19

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 (129) hide show
  1. package/dist/components/author-page/index.cjs +51 -25
  2. package/dist/components/author-page/index.cjs.map +1 -1
  3. package/dist/components/author-page/index.js +52 -26
  4. package/dist/components/author-page/index.js.map +1 -1
  5. package/dist/components/blog-post/_components/content.cjs +5 -8
  6. package/dist/components/blog-post/_components/content.cjs.map +1 -1
  7. package/dist/components/blog-post/_components/content.js +5 -8
  8. package/dist/components/blog-post/_components/content.js.map +1 -1
  9. package/dist/components/blog-post/_components/faq.cjs +2 -2
  10. package/dist/components/blog-post/_components/faq.cjs.map +1 -1
  11. package/dist/components/blog-post/_components/faq.js +2 -2
  12. package/dist/components/blog-post/_components/faq.js.map +1 -1
  13. package/dist/components/blog-post/_components/table-of-contents.cjs +36 -9
  14. package/dist/components/blog-post/_components/table-of-contents.cjs.map +1 -1
  15. package/dist/components/blog-post/_components/table-of-contents.js +36 -9
  16. package/dist/components/blog-post/_components/table-of-contents.js.map +1 -1
  17. package/dist/components/blog-post/_helpers/extract-headings.cjs +2 -1
  18. package/dist/components/blog-post/_helpers/extract-headings.cjs.map +1 -1
  19. package/dist/components/blog-post/_helpers/extract-headings.d.cts +1 -0
  20. package/dist/components/blog-post/_helpers/extract-headings.d.ts +1 -0
  21. package/dist/components/blog-post/_helpers/extract-headings.js +2 -1
  22. package/dist/components/blog-post/_helpers/extract-headings.js.map +1 -1
  23. package/dist/components/blog-post/_helpers/json-ld.cjs +5 -12
  24. package/dist/components/blog-post/_helpers/json-ld.cjs.map +1 -1
  25. package/dist/components/blog-post/_helpers/json-ld.d.cts +6 -2
  26. package/dist/components/blog-post/_helpers/json-ld.d.ts +6 -2
  27. package/dist/components/blog-post/_helpers/json-ld.js +5 -12
  28. package/dist/components/blog-post/_helpers/json-ld.js.map +1 -1
  29. package/dist/components/blog-post/_helpers/reading-time.cjs +1 -1
  30. package/dist/components/blog-post/_helpers/reading-time.cjs.map +1 -1
  31. package/dist/components/blog-post/_helpers/reading-time.js +1 -1
  32. package/dist/components/blog-post/_helpers/reading-time.js.map +1 -1
  33. package/dist/components/blog-post/index.cjs +26 -22
  34. package/dist/components/blog-post/index.cjs.map +1 -1
  35. package/dist/components/blog-post/index.js +26 -22
  36. package/dist/components/blog-post/index.js.map +1 -1
  37. package/dist/components/bread-crumbs.cjs +1 -1
  38. package/dist/components/bread-crumbs.cjs.map +1 -1
  39. package/dist/components/bread-crumbs.js +1 -1
  40. package/dist/components/bread-crumbs.js.map +1 -1
  41. package/dist/components/folder-page/index.cjs +46 -11
  42. package/dist/components/folder-page/index.cjs.map +1 -1
  43. package/dist/components/folder-page/index.js +47 -12
  44. package/dist/components/folder-page/index.js.map +1 -1
  45. package/dist/components/home-page/folders.cjs +20 -10
  46. package/dist/components/home-page/folders.cjs.map +1 -1
  47. package/dist/components/home-page/folders.d.cts +4 -2
  48. package/dist/components/home-page/folders.d.ts +4 -2
  49. package/dist/components/home-page/folders.js +20 -10
  50. package/dist/components/home-page/folders.js.map +1 -1
  51. package/dist/components/home-page/index.cjs +5 -7
  52. package/dist/components/home-page/index.cjs.map +1 -1
  53. package/dist/components/home-page/index.d.cts +4 -5
  54. package/dist/components/home-page/index.d.ts +4 -5
  55. package/dist/components/home-page/index.js +5 -7
  56. package/dist/components/home-page/index.js.map +1 -1
  57. package/dist/components/home-page/pagination.cjs +23 -17
  58. package/dist/components/home-page/pagination.cjs.map +1 -1
  59. package/dist/components/home-page/pagination.d.cts +2 -3
  60. package/dist/components/home-page/pagination.d.ts +2 -3
  61. package/dist/components/home-page/pagination.js +23 -17
  62. package/dist/components/home-page/pagination.js.map +1 -1
  63. package/dist/components/home-page/top-posts.cjs +2 -19
  64. package/dist/components/home-page/top-posts.cjs.map +1 -1
  65. package/dist/components/home-page/top-posts.d.cts +4 -3
  66. package/dist/components/home-page/top-posts.d.ts +4 -3
  67. package/dist/components/home-page/top-posts.js +4 -21
  68. package/dist/components/home-page/top-posts.js.map +1 -1
  69. package/dist/components/opinly-blog.cjs +6 -6
  70. package/dist/components/opinly-blog.cjs.map +1 -1
  71. package/dist/components/opinly-blog.d.cts +4 -7
  72. package/dist/components/opinly-blog.d.ts +4 -7
  73. package/dist/components/opinly-blog.js +6 -6
  74. package/dist/components/opinly-blog.js.map +1 -1
  75. package/dist/components/post-preview.cjs +7 -6
  76. package/dist/components/post-preview.cjs.map +1 -1
  77. package/dist/components/post-preview.js +7 -6
  78. package/dist/components/post-preview.js.map +1 -1
  79. package/dist/{utils/with-opinly-config.cjs → config.cjs} +17 -9
  80. package/dist/config.cjs.map +1 -0
  81. package/dist/{utils/with-opinly-config.d.cts → config.d.cts} +3 -0
  82. package/dist/{utils/with-opinly-config.d.ts → config.d.ts} +3 -0
  83. package/dist/{utils/with-opinly-config.js → config.js} +14 -6
  84. package/dist/config.js.map +1 -0
  85. package/dist/index.cjs +1 -3
  86. package/dist/index.cjs.map +1 -1
  87. package/dist/index.d.cts +0 -3
  88. package/dist/index.d.ts +0 -3
  89. package/dist/index.js +0 -1
  90. package/dist/index.js.map +1 -1
  91. package/dist/pages/index.cjs +23 -0
  92. package/dist/pages/index.cjs.map +1 -0
  93. package/dist/pages/index.d.cts +3 -0
  94. package/dist/pages/index.d.ts +3 -0
  95. package/dist/pages/index.js +2 -0
  96. package/dist/pages/index.js.map +1 -0
  97. package/dist/pages/opinly-blog-pages.cjs +128 -0
  98. package/dist/pages/opinly-blog-pages.cjs.map +1 -0
  99. package/dist/pages/opinly-blog-pages.d.cts +9 -0
  100. package/dist/pages/opinly-blog-pages.d.ts +9 -0
  101. package/dist/pages/opinly-blog-pages.js +104 -0
  102. package/dist/pages/opinly-blog-pages.js.map +1 -0
  103. package/dist/utils/generate-metadata.cjs +1 -1
  104. package/dist/utils/generate-metadata.cjs.map +1 -1
  105. package/dist/utils/generate-metadata.d.cts +2 -4
  106. package/dist/utils/generate-metadata.d.ts +2 -4
  107. package/dist/utils/generate-metadata.js +1 -1
  108. package/dist/utils/generate-metadata.js.map +1 -1
  109. package/dist/utils/generate-sitemap-xml.cjs +42 -0
  110. package/dist/utils/generate-sitemap-xml.cjs.map +1 -0
  111. package/dist/utils/generate-sitemap-xml.d.cts +5 -0
  112. package/dist/utils/generate-sitemap-xml.d.ts +5 -0
  113. package/dist/utils/generate-sitemap-xml.js +18 -0
  114. package/dist/utils/generate-sitemap-xml.js.map +1 -0
  115. package/dist/utils/sdk-config.cjs +4 -2
  116. package/dist/utils/sdk-config.cjs.map +1 -1
  117. package/dist/utils/sdk-config.d.cts +2 -0
  118. package/dist/utils/sdk-config.d.ts +2 -0
  119. package/dist/utils/sdk-config.js +4 -2
  120. package/dist/utils/sdk-config.js.map +1 -1
  121. package/package.json +12 -3
  122. package/dist/components/not-found.cjs +0 -60
  123. package/dist/components/not-found.cjs.map +0 -1
  124. package/dist/components/not-found.d.cts +0 -5
  125. package/dist/components/not-found.d.ts +0 -5
  126. package/dist/components/not-found.js +0 -26
  127. package/dist/components/not-found.js.map +0 -1
  128. package/dist/utils/with-opinly-config.cjs.map +0 -1
  129. package/dist/utils/with-opinly-config.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/components/post-preview.tsx"],"sourcesContent":["import { Opinly } from \"@opinly/backend\";\nimport Link from \"next/link\";\nimport Image from \"next/image\";\nimport { opinlyConfig } from \"../utils/sdk-config\";\nimport { formatDate } from \"../utils/dates\";\n\nexport const PostPreviewSkeleton: React.FC = () => (\n <div className=\"w-full h-full \">\n {/* Image placeholder (with same mb-4 as real) */}\n <div className=\"animate-pulse mb-5\">\n <div className=\"w-full h-48 bg-gray-200 dark:bg-gray-700 rounded-lg\" />\n </div>\n\n {/* Folder · dot · date (text-sm text-muted-foreground mb-1) */}\n <div className=\"flex items-center space-x-2 text-sm text-muted-foreground mb-3\">\n <div className=\"animate-pulse h-4 w-20 bg-gray-200 dark:bg-gray-700 rounded\" />\n <div className=\"animate-pulse h-4 w-1 bg-gray-200 dark:bg-gray-700 rounded-full\" />\n <div className=\"animate-pulse h-4 w-16 bg-gray-200 dark:bg-gray-700 rounded\" />\n </div>\n\n {/* Title (text-lg font-semibold leading-snug) */}\n <div className=\"animate-pulse h-5 w-3/4 bg-gray-200 dark:bg-gray-700 rounded mb-2\" />\n\n {/* Description (text-sm mt-1 line-clamp-2) */}\n <div className=\"space-y-1 mt-1 pr-4\">\n <div className=\"animate-pulse h-4 w-full bg-gray-200 dark:bg-gray-700 rounded\" />\n <div className=\"animate-pulse h-4 w-10/12 bg-gray-200 dark:bg-gray-700 rounded\" />\n </div>\n\n {/* Author · date (text-xs text-gray-500 mt-2 flex items-center space-x-2) */}\n <div className=\"flex items-center space-x-2 text-xs text-gray-500 mt-2\">\n <div className=\"animate-pulse h-3 w-24 bg-gray-200 dark:bg-gray-700 rounded\" />\n <div className=\"animate-pulse h-3 w-12 bg-gray-200 dark:bg-gray-700 rounded\" />\n </div>\n </div>\n);\nexport const PostPreview = ({\n post,\n}: {\n post: NonNullable<\n NonNullable<\n Awaited<\n ReturnType<Opinly[\"client\"][\"content\"][\"authorPage\"][\"query\"]>\n >[\"data\"]\n >[\"posts\"][number]\n >;\n}) => {\n const postSlug = `${opinlyConfig.blogPrefix}/${post.folder?.slug ? `${post.folder.slug}/` : \"\"}${post.slug}`;\n\n return (\n <div className=\"w-full h-full \">\n {post.image?.fileKey && (\n <Link href={postSlug} className=\"group\">\n <div className=\"relative w-full h-48 mb-4\">\n <Image\n unoptimized={opinlyConfig.unoptimizedImages}\n src={`${opinlyConfig.imagesPrefix}/${post.image.fileKey}`}\n alt={post.title}\n fill\n className=\"object-cover rounded-lg\"\n />\n </div>\n </Link>\n )}\n <div className=\"text-sm text-muted-foreground mb-1\">\n {post.folder?.name && (\n <>\n <Link\n href={`${opinlyConfig.blogPrefix}/${post.folder.slug}`}\n className=\"hover:underline\"\n >\n {post.folder.name}\n </Link>\n <span className=\"mx-1\">·</span>\n </>\n )}{\" \"}\n {formatDate(post.firstPublishedAt as string)}\n </div>\n <Link href={postSlug} className=\"group\">\n <h2 className=\"text-lg font-semibold leading-snug group-hover:underline\">\n {post.title}\n </h2>\n </Link>\n\n {post.description && (\n <p className=\"text-sm text-gray-600 mt-1 line-clamp-2\">\n {post.description}\n </p>\n )}\n <div className=\"text-xs text-gray-500 mt-2\">\n {post.author && (\n <>\n <Link\n href={`${opinlyConfig.blogPrefix}/authors/${post.author.slug}`}\n className=\"font-medium hover:underline\"\n >\n {post.author?.name}\n </Link>{\" \"}\n <span className=\"mx-1\">·</span>\n </>\n )}{\" \"}\n {formatDate(post.firstPublishedAt as string)}\n </div>\n </div>\n );\n};\n"],"mappings":"AAUM,SAwDI,UAxDJ,KAIF,YAJE;AATN,OAAO,UAAU;AACjB,OAAO,WAAW;AAClB,SAAS,oBAAoB;AAC7B,SAAS,kBAAkB;AAEpB,MAAM,sBAAgC,MAC3C,qBAAC,SAAI,WAAU,kBAEb;AAAA,sBAAC,SAAI,WAAU,sBACb,8BAAC,SAAI,WAAU,uDAAsD,GACvE;AAAA,EAGA,qBAAC,SAAI,WAAU,kEACb;AAAA,wBAAC,SAAI,WAAU,+DAA8D;AAAA,IAC7E,oBAAC,SAAI,WAAU,mEAAkE;AAAA,IACjF,oBAAC,SAAI,WAAU,+DAA8D;AAAA,KAC/E;AAAA,EAGA,oBAAC,SAAI,WAAU,qEAAoE;AAAA,EAGnF,qBAAC,SAAI,WAAU,uBACb;AAAA,wBAAC,SAAI,WAAU,iEAAgE;AAAA,IAC/E,oBAAC,SAAI,WAAU,kEAAiE;AAAA,KAClF;AAAA,EAGA,qBAAC,SAAI,WAAU,0DACb;AAAA,wBAAC,SAAI,WAAU,+DAA8D;AAAA,IAC7E,oBAAC,SAAI,WAAU,+DAA8D;AAAA,KAC/E;AAAA,GACF;AAEK,MAAM,cAAc,CAAC;AAAA,EAC1B;AACF,MAQM;AACJ,QAAM,WAAW,GAAG,aAAa,UAAU,IAAI,KAAK,QAAQ,OAAO,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sx"],"sourcesContent":["import { Opinly } from \"@opinly/backend\";\nimport Link from \"next/link\";\nimport Image from \"next/image\";\nimport { opinlyConfig } from \"../utils/sdk-config\";\nimport { formatDate } from \"../utils/dates\";\n\nexport const PostPreviewSkeleton: React.FC = () => (\n <div className=\"w-full h-full \">\n <div className=\"animate-pulse mb-5\">\n <div className=\"w-full h-48 bg-gray-200 dark:bg-gray-700 rounded-lg\" />\n </div>\n <div className=\"flex items-center space-x-2 text-sm text-muted-foreground mb-3\">\n <div className=\"animate-pulse h-4 w-20 bg-gray-200 dark:bg-gray-700 rounded\" />\n <div className=\"animate-pulse h-4 w-1 bg-gray-200 dark:bg-gray-700 rounded-full\" />\n <div className=\"animate-pulse h-4 w-16 bg-gray-200 dark:bg-gray-700 rounded\" />\n </div>\n <div className=\"animate-pulse h-5 w-3/4 bg-gray-200 dark:bg-gray-700 rounded mb-2\" />\n <div className=\"space-y-1 mt-1 pr-4\">\n <div className=\"animate-pulse h-4 w-full bg-gray-200 dark:bg-gray-700 rounded\" />\n <div className=\"animate-pulse h-4 w-10/12 bg-gray-200 dark:bg-gray-700 rounded\" />\n </div>\n <div className=\"flex items-center space-x-2 text-xs mt-2\">\n <div className=\"animate-pulse h-3 w-24 bg-gray-200 dark:bg-gray-700 rounded\" />\n <div className=\"animate-pulse h-3 w-12 bg-gray-200 dark:bg-gray-700 rounded\" />\n </div>\n </div>\n);\n\nexport const PostPreview = ({\n post,\n}: {\n post: NonNullable<\n NonNullable<\n Awaited<\n ReturnType<Opinly[\"client\"][\"content\"][\"authorPage\"][\"query\"]>\n >[\"data\"]\n >[\"posts\"][number]\n >;\n}) => {\n const postSlug = `${opinlyConfig.blogPrefix}/${\n post.folder?.slug ? `${post.folder.slug}/` : \"\"\n }${post.slug}`;\n\n console.log(\"Image is\", Image);\n\n return (\n <div className=\"w-full h-full\">\n {post.image?.fileKey && (\n <Link href={postSlug} className=\"group\">\n <div className=\"relative w-full h-48 mb-4\">\n <Image\n unoptimized={opinlyConfig.unoptimizedImages}\n src={`${opinlyConfig.imagesPrefix}/${post.image.fileKey}`}\n alt={post.title}\n fill\n className=\"object-cover rounded-lg\"\n />\n </div>\n </Link>\n )}\n <div className=\"text-sm text-op-muted mb-1\">\n {post.folder?.name && (\n <>\n <Link\n href={`${opinlyConfig.blogPrefix}/${post.folder.slug}`}\n className=\"hover:underline\"\n >\n {post.folder.name}\n </Link>\n <span className=\"mx-1\">·</span>\n </>\n )}{\" \"}\n {formatDate(post.firstPublishedAt as string)}\n </div>\n <Link href={postSlug} className=\"group\">\n <h2 className=\"text-lg font-semibold leading-snug group-hover:underline text-op-heading\">\n {post.title}\n </h2>\n </Link>\n\n {post.description && (\n <p className=\"text-sm text-op-body mt-1 line-clamp-2\">\n {post.description}\n </p>\n )}\n <div className=\"text-xs text-op-muted mt-2\">\n {post.author && (\n <>\n <Link\n href={`${opinlyConfig.blogPrefix}/authors/${post.author.slug}`}\n className=\"font-medium hover:underline\"\n >\n {post.author?.name}\n </Link>{\" \"}\n <span className=\"mx-1\">·</span>\n </>\n )}{\" \"}\n {formatDate(post.firstPublishedAt as string)}\n </div>\n </div>\n );\n};\n"],"mappings":"AASM,SAqDI,UArDJ,KAEF,YAFE;AARN,OAAO,UAAU;AACjB,OAAO,WAAW;AAClB,SAAS,oBAAoB;AAC7B,SAAS,kBAAkB;AAEpB,MAAM,sBAAgC,MAC3C,qBAAC,SAAI,WAAU,kBACb;AAAA,sBAAC,SAAI,WAAU,sBACb,8BAAC,SAAI,WAAU,uDAAsD,GACvE;AAAA,EACA,qBAAC,SAAI,WAAU,kEACb;AAAA,wBAAC,SAAI,WAAU,+DAA8D;AAAA,IAC7E,oBAAC,SAAI,WAAU,mEAAkE;AAAA,IACjF,oBAAC,SAAI,WAAU,+DAA8D;AAAA,KAC/E;AAAA,EACA,oBAAC,SAAI,WAAU,qEAAoE;AAAA,EACnF,qBAAC,SAAI,WAAU,uBACb;AAAA,wBAAC,SAAI,WAAU,iEAAgE;AAAA,IAC/E,oB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AAC;AAAA;AAAA,YACC,MAAM,GAAG,aAAa,UAAU,YAAY,KAAK,OAAO,IAAI;AAAA,YAC5D,WAAU;AAAA,YAET,eAAK,QAAQ;AAAA;AAAA,QAChB;AAAA,QAAQ;AAAA,QACR,oBAAC,UAAK,WAAU,QAAO,kBAAC;AAAA,SAC1B;AAAA,MACC;AAAA,MACF,WAAW,KAAK,gBAA0B;AAAA,OAC7C;AAAA,KACF;AAEJ;","names":[]}
@@ -16,11 +16,11 @@ var __copyProps = (to, from, except, desc) => {
16
16
  return to;
17
17
  };
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var with_opinly_config_exports = {};
20
- __export(with_opinly_config_exports, {
19
+ var config_exports = {};
20
+ __export(config_exports, {
21
21
  withOpinlyConfig: () => withOpinlyConfig
22
22
  });
23
- module.exports = __toCommonJS(with_opinly_config_exports);
23
+ module.exports = __toCommonJS(config_exports);
24
24
  var import_zod = require("zod");
25
25
  const opinlyOptionsSchema = import_zod.z.object({
26
26
  imagesPath: import_zod.z.string({}).refine(
@@ -45,7 +45,8 @@ const opinlyOptionsSchema = import_zod.z.object({
45
45
  description: "INTERNAL USE ONLY: The domain of the CDN. If not provided, the default domain will be used."
46
46
  }).url({
47
47
  message: "cdnDomain must be a valid URL"
48
- }).optional()
48
+ }).optional(),
49
+ pagesRouter: import_zod.z.boolean().optional()
49
50
  });
50
51
  const validateOpinlyOptions = (opinlyOptions) => {
51
52
  if (!opinlyOptions) {
@@ -74,9 +75,15 @@ const processRewrites = (userNextConfig, opinlyOptions) => {
74
75
  source: `${opinlyOptions.imagesPath}/:path*`,
75
76
  destination: `${opinlyOptions.cdnDomain || "https://cdn.opinly.ai"}/${opinlyOptions.cdnNamespace}/:path*`
76
77
  };
77
- console.log("opinlyRewrite", opinlyRewrite);
78
+ const newRewrites = [opinlyRewrite];
79
+ if (opinlyOptions.pagesRouter) {
80
+ newRewrites.push({
81
+ source: "/sitemap.xml",
82
+ destination: "/sitemap"
83
+ });
84
+ }
78
85
  if (typeof originalRewrites !== "function") {
79
- return [opinlyRewrite];
86
+ return newRewrites;
80
87
  }
81
88
  const resolvedRewrites = await originalRewrites();
82
89
  if (Array.isArray(resolvedRewrites)) {
@@ -84,7 +91,7 @@ const processRewrites = (userNextConfig, opinlyOptions) => {
84
91
  } else {
85
92
  return {
86
93
  ...resolvedRewrites,
87
- beforeFiles: [...resolvedRewrites.beforeFiles || [], opinlyRewrite]
94
+ beforeFiles: [...resolvedRewrites.beforeFiles || [], ...newRewrites]
88
95
  };
89
96
  }
90
97
  };
@@ -95,7 +102,8 @@ function addEnvVars(userNextConfig, opinlyOptions) {
95
102
  OPINLY_BLOG_PREFIX: opinlyOptions.blogPath,
96
103
  OPINLY_SITE_NAME: opinlyOptions.companyName,
97
104
  OPINLY_SITE_URL: opinlyOptions.siteUrl,
98
- OPINLY_UNOPTIMIZED_IMAGES: opinlyOptions.unoptimizedImages ? "true" : void 0
105
+ OPINLY_UNOPTIMIZED_IMAGES: opinlyOptions.unoptimizedImages ? "true" : void 0,
106
+ OPINLY_PAGES_ROUTER: opinlyOptions.pagesRouter ? "true" : void 0
99
107
  };
100
108
  userNextConfig.env = {
101
109
  ...userNextConfig.env || {},
@@ -112,4 +120,4 @@ const withOpinlyConfig = (opinlyOptions) => (nextConfig) => {
112
120
  0 && (module.exports = {
113
121
  withOpinlyConfig
114
122
  });
115
- //# sourceMappingURL=with-opinly-config.cjs.map
123
+ //# sourceMappingURL=config.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/config.ts"],"sourcesContent":["import { NextConfig } from \"next\";\nimport { Rewrite } from \"next/dist/lib/load-custom-routes\";\nimport type { OpinlyEnvVars } from \"./utils/sdk-config\";\nimport { z } from \"zod\";\n\ninterface WithOpinlyOptions {\n imagesPath: `/${string}`;\n blogPath: `/${string}`;\n companyName: string;\n cdnNamespace: string;\n siteUrl: string;\n unoptimizedImages?: boolean;\n}\n\ntype ResolvedRewrites = ReturnType<\n NonNullable<Awaited<NextConfig[\"rewrites\"]>>\n>;\n\nconst opinlyOptionsSchema = z.object({\n imagesPath: z\n .string({})\n .refine(\n (val) => val.startsWith(\"/\") || z.string().url().safeParse(val).success,\n {\n message: \"imagesPath must start with a leading slash (e.g. '/images')\",\n }\n ),\n blogPath: z.string({}).startsWith(\"/\", {\n message: \"blogPath must start with a leading slash i.e. `/blog`\",\n }),\n companyName: z.string({\n required_error: \"companyName is required\",\n invalid_type_error: \"companyName must be a string\",\n }),\n cdnNamespace: z\n .string()\n .min(21, \"CDN namespace must be 21 characters long\")\n .max(21, \"CDN namespace must be 21 characters long\"),\n siteUrl: z.string().url({\n message: \"siteUrl must be a valid URL\",\n }),\n unoptimizedImages: z.boolean().optional(),\n cdnDomain: z\n .string({\n description:\n \"INTERNAL USE ONLY: The domain of the CDN. If not provided, the default domain will be used.\",\n })\n .url({\n message: \"cdnDomain must be a valid URL\",\n })\n .optional(),\n pagesRouter: z.boolean().optional(),\n});\n\ntype OpinlyOptions = z.infer<typeof opinlyOptionsSchema>;\n\nconst validateOpinlyOptions = (opinlyOptions: OpinlyOptions) => {\n if (!opinlyOptions) {\n throw new Error(\n \"[@opinly/next] `opts` is required. Please provide the options object.\"\n );\n }\n\n const parsedOpinlyOptions = opinlyOptionsSchema.safeParse(opinlyOptions);\n\n if (!parsedOpinlyOptions.success) {\n throw new Error(\n `[@opinly/next] Invalid options provided in next.config.js: ${parsedOpinlyOptions.error.message}`\n );\n }\n};\n\nconst processRewrites = (\n userNextConfig: NextConfig,\n opinlyOptions: OpinlyOptions\n): void => {\n const imagesPath = opinlyOptions.imagesPath;\n\n if (!imagesPath.startsWith(\"/\")) {\n console.warn(\n `[@opinly/next] You have provided a url for imagesPath. This is only valid for internal testing and rewrites will be skipped.`\n );\n\n return;\n }\n\n const originalRewrites = userNextConfig.rewrites;\n\n userNextConfig.rewrites = async () => {\n const opinlyRewrite = {\n source: `${opinlyOptions.imagesPath}/:path*`,\n destination: `${opinlyOptions.cdnDomain || \"https://cdn.opinly.ai\"}/${\n opinlyOptions.cdnNamespace\n }/:path*`,\n };\n\n const newRewrites = [opinlyRewrite];\n\n if (opinlyOptions.pagesRouter) {\n newRewrites.push({\n source: \"/sitemap.xml\",\n destination: \"/sitemap\",\n });\n }\n\n if (typeof originalRewrites !== \"function\") {\n return newRewrites;\n }\n\n const resolvedRewrites = await originalRewrites();\n\n if (Array.isArray(resolvedRewrites)) {\n return [...resolvedRewrites, opinlyRewrite];\n } else {\n return {\n ...resolvedRewrites,\n beforeFiles: [...(resolvedRewrites.beforeFiles || []), ...newRewrites],\n };\n }\n };\n};\n\nfunction addEnvVars(userNextConfig: NextConfig, opinlyOptions: OpinlyOptions) {\n const opinlyEnvVars: OpinlyEnvVars = {\n OPINLY_IMAGES_PREFIX: opinlyOptions.imagesPath,\n OPINLY_BLOG_PREFIX: opinlyOptions.blogPath,\n OPINLY_SITE_NAME: opinlyOptions.companyName,\n OPINLY_SITE_URL: opinlyOptions.siteUrl,\n OPINLY_UNOPTIMIZED_IMAGES: opinlyOptions.unoptimizedImages\n ? \"true\"\n : undefined,\n OPINLY_PAGES_ROUTER: opinlyOptions.pagesRouter ? \"true\" : undefined,\n };\n\n userNextConfig.env = {\n ...(userNextConfig.env || {}),\n ...opinlyEnvVars,\n };\n}\n\n/**\n * Modifies the passed in Next.js configuration with image rewrites and environment variables.\n *\n * @param nextConfig A Next.js configuration object, as usually exported in `next.config.js` or `next.config.mjs`.\n * @param opinlyOptions Additional options to configure Opinly.\n * @returns The modified config to be exported\n */\nexport const withOpinlyConfig =\n (opinlyOptions: OpinlyOptions) =>\n (nextConfig: NextConfig): NextConfig => {\n validateOpinlyOptions(opinlyOptions);\n\n addEnvVars(nextConfig, opinlyOptions);\n\n processRewrites(nextConfig, opinlyOptions);\n\n return nextConfig;\n };\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,iBAAkB;AAelB,MAAM,sBAAsB,aAAE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Y;AACpC,UAAM,gBAAgB;AAAA,MACpB,QAAQ,GAAG,cAAc,UAAU;AAAA,MACnC,aAAa,GAAG,cAAc,aAAa,uBAAuB,IAChE,cAAc,YAChB;AAAA,IACF;AAEA,UAAM,cAAc,CAAC,aAAa;AAElC,QAAI,cAAc,aAAa;AAC7B,kBAAY,KAAK;AAAA,QACf,QAAQ;AAAA,QACR,aAAa;AAAA,MACf,CAAC;AAAA,IACH;AAEA,QAAI,OAAO,qBAAqB,YAAY;AAC1C,aAAO;AAAA,IACT;AAEA,UAAM,mBAAmB,MAAM,iBAAiB;AAEhD,QAAI,MAAM,QAAQ,gBAAgB,GAAG;AACnC,aAAO,CAAC,GAAG,kBAAkB,aAAa;AAAA,IAC5C,OAAO;AACL,aAAO;AAAA,QACL,GAAG;AAAA,QACH,aAAa,CAAC,GAAI,iBAAiB,eAAe,CAAC,GAAI,GAAG,WAAW;AAAA,MACvE;AAAA,IACF;AAAA,EACF;AACF;AAEA,SAAS,WAAW,gBAA4B,eAA8B;AAC5E,QAAM,gBAA+B;AAAA,IACnC,sBAAsB,cAAc;AAAA,IACpC,oBAAoB,cAAc;AAAA,IAClC,kBAAkB,cAAc;AAAA,IAChC,iBAAiB,cAAc;AAAA,IAC/B,2BAA2B,cAAc,oBACrC,SACA;AAAA,IACJ,qBAAqB,cAAc,cAAc,SAAS;AAAA,EAC5D;AAEA,iBAAe,MAAM;AAAA,IACnB,GAAI,eAAe,OAAO,CAAC;AAAA,IAC3B,GAAG;AAAA,EACL;AACF;AASO,MAAM,mBACX,CAAC,kBACD,CAAC,eAAuC;AACtC,wBAAsB,aAAa;AAEnC,aAAW,YAAY,aAAa;AAEpC,kBAAgB,YAAY,aAAa;AAEzC,SAAO;AACT;","names":[]}
@@ -9,6 +9,7 @@ declare const opinlyOptionsSchema: z.ZodObject<{
9
9
  siteUrl: z.ZodString;
10
10
  unoptimizedImages: z.ZodOptional<z.ZodBoolean>;
11
11
  cdnDomain: z.ZodOptional<z.ZodString>;
12
+ pagesRouter: z.ZodOptional<z.ZodBoolean>;
12
13
  }, "strip", z.ZodTypeAny, {
13
14
  imagesPath: string;
14
15
  blogPath: string;
@@ -17,6 +18,7 @@ declare const opinlyOptionsSchema: z.ZodObject<{
17
18
  siteUrl: string;
18
19
  unoptimizedImages?: boolean | undefined;
19
20
  cdnDomain?: string | undefined;
21
+ pagesRouter?: boolean | undefined;
20
22
  }, {
21
23
  imagesPath: string;
22
24
  blogPath: string;
@@ -25,6 +27,7 @@ declare const opinlyOptionsSchema: z.ZodObject<{
25
27
  siteUrl: string;
26
28
  unoptimizedImages?: boolean | undefined;
27
29
  cdnDomain?: string | undefined;
30
+ pagesRouter?: boolean | undefined;
28
31
  }>;
29
32
  type OpinlyOptions = z.infer<typeof opinlyOptionsSchema>;
30
33
  /**
@@ -9,6 +9,7 @@ declare const opinlyOptionsSchema: z.ZodObject<{
9
9
  siteUrl: z.ZodString;
10
10
  unoptimizedImages: z.ZodOptional<z.ZodBoolean>;
11
11
  cdnDomain: z.ZodOptional<z.ZodString>;
12
+ pagesRouter: z.ZodOptional<z.ZodBoolean>;
12
13
  }, "strip", z.ZodTypeAny, {
13
14
  imagesPath: string;
14
15
  blogPath: string;
@@ -17,6 +18,7 @@ declare const opinlyOptionsSchema: z.ZodObject<{
17
18
  siteUrl: string;
18
19
  unoptimizedImages?: boolean | undefined;
19
20
  cdnDomain?: string | undefined;
21
+ pagesRouter?: boolean | undefined;
20
22
  }, {
21
23
  imagesPath: string;
22
24
  blogPath: string;
@@ -25,6 +27,7 @@ declare const opinlyOptionsSchema: z.ZodObject<{
25
27
  siteUrl: string;
26
28
  unoptimizedImages?: boolean | undefined;
27
29
  cdnDomain?: string | undefined;
30
+ pagesRouter?: boolean | undefined;
28
31
  }>;
29
32
  type OpinlyOptions = z.infer<typeof opinlyOptionsSchema>;
30
33
  /**
@@ -22,7 +22,8 @@ const opinlyOptionsSchema = z.object({
22
22
  description: "INTERNAL USE ONLY: The domain of the CDN. If not provided, the default domain will be used."
23
23
  }).url({
24
24
  message: "cdnDomain must be a valid URL"
25
- }).optional()
25
+ }).optional(),
26
+ pagesRouter: z.boolean().optional()
26
27
  });
27
28
  const validateOpinlyOptions = (opinlyOptions) => {
28
29
  if (!opinlyOptions) {
@@ -51,9 +52,15 @@ const processRewrites = (userNextConfig, opinlyOptions) => {
51
52
  source: `${opinlyOptions.imagesPath}/:path*`,
52
53
  destination: `${opinlyOptions.cdnDomain || "https://cdn.opinly.ai"}/${opinlyOptions.cdnNamespace}/:path*`
53
54
  };
54
- console.log("opinlyRewrite", opinlyRewrite);
55
+ const newRewrites = [opinlyRewrite];
56
+ if (opinlyOptions.pagesRouter) {
57
+ newRewrites.push({
58
+ source: "/sitemap.xml",
59
+ destination: "/sitemap"
60
+ });
61
+ }
55
62
  if (typeof originalRewrites !== "function") {
56
- return [opinlyRewrite];
63
+ return newRewrites;
57
64
  }
58
65
  const resolvedRewrites = await originalRewrites();
59
66
  if (Array.isArray(resolvedRewrites)) {
@@ -61,7 +68,7 @@ const processRewrites = (userNextConfig, opinlyOptions) => {
61
68
  } else {
62
69
  return {
63
70
  ...resolvedRewrites,
64
- beforeFiles: [...resolvedRewrites.beforeFiles || [], opinlyRewrite]
71
+ beforeFiles: [...resolvedRewrites.beforeFiles || [], ...newRewrites]
65
72
  };
66
73
  }
67
74
  };
@@ -72,7 +79,8 @@ function addEnvVars(userNextConfig, opinlyOptions) {
72
79
  OPINLY_BLOG_PREFIX: opinlyOptions.blogPath,
73
80
  OPINLY_SITE_NAME: opinlyOptions.companyName,
74
81
  OPINLY_SITE_URL: opinlyOptions.siteUrl,
75
- OPINLY_UNOPTIMIZED_IMAGES: opinlyOptions.unoptimizedImages ? "true" : void 0
82
+ OPINLY_UNOPTIMIZED_IMAGES: opinlyOptions.unoptimizedImages ? "true" : void 0,
83
+ OPINLY_PAGES_ROUTER: opinlyOptions.pagesRouter ? "true" : void 0
76
84
  };
77
85
  userNextConfig.env = {
78
86
  ...userNextConfig.env || {},
@@ -88,4 +96,4 @@ const withOpinlyConfig = (opinlyOptions) => (nextConfig) => {
88
96
  export {
89
97
  withOpinlyConfig
90
98
  };
91
- //# sourceMappingURL=with-opinly-config.js.map
99
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/config.ts"],"sourcesContent":["import { NextConfig } from \"next\";\nimport { Rewrite } from \"next/dist/lib/load-custom-routes\";\nimport type { OpinlyEnvVars } from \"./utils/sdk-config\";\nimport { z } from \"zod\";\n\ninterface WithOpinlyOptions {\n imagesPath: `/${string}`;\n blogPath: `/${string}`;\n companyName: string;\n cdnNamespace: string;\n siteUrl: string;\n unoptimizedImages?: boolean;\n}\n\ntype ResolvedRewrites = ReturnType<\n NonNullable<Awaited<NextConfig[\"rewrites\"]>>\n>;\n\nconst opinlyOptionsSchema = z.object({\n imagesPath: z\n .string({})\n .refine(\n (val) => val.startsWith(\"/\") || z.string().url().safeParse(val).success,\n {\n message: \"imagesPath must start with a leading slash (e.g. '/images')\",\n }\n ),\n blogPath: z.string({}).startsWith(\"/\", {\n message: \"blogPath must start with a leading slash i.e. `/blog`\",\n }),\n companyName: z.string({\n required_error: \"companyName is required\",\n invalid_type_error: \"companyName must be a string\",\n }),\n cdnNamespace: z\n .string()\n .min(21, \"CDN namespace must be 21 characters long\")\n .max(21, \"CDN namespace must be 21 characters long\"),\n siteUrl: z.string().url({\n message: \"siteUrl must be a valid URL\",\n }),\n unoptimizedImages: z.boolean().optional(),\n cdnDomain: z\n .string({\n description:\n \"INTERNAL USE ONLY: The domain of the CDN. If not provided, the default domain will be used.\",\n })\n .url({\n message: \"cdnDomain must be a valid URL\",\n })\n .optional(),\n pagesRouter: z.boolean().optional(),\n});\n\ntype OpinlyOptions = z.infer<typeof opinlyOptionsSchema>;\n\nconst validateOpinlyOptions = (opinlyOptions: OpinlyOptions) => {\n if (!opinlyOptions) {\n throw new Error(\n \"[@opinly/next] `opts` is required. Please provide the options object.\"\n );\n }\n\n const parsedOpinlyOptions = opinlyOptionsSchema.safeParse(opinlyOptions);\n\n if (!parsedOpinlyOptions.success) {\n throw new Error(\n `[@opinly/next] Invalid options provided in next.config.js: ${parsedOpinlyOptions.error.message}`\n );\n }\n};\n\nconst processRewrites = (\n userNextConfig: NextConfig,\n opinlyOptions: OpinlyOptions\n): void => {\n const imagesPath = opinlyOptions.imagesPath;\n\n if (!imagesPath.startsWith(\"/\")) {\n console.warn(\n `[@opinly/next] You have provided a url for imagesPath. This is only valid for internal testing and rewrites will be skipped.`\n );\n\n return;\n }\n\n const originalRewrites = userNextConfig.rewrites;\n\n userNextConfig.rewrites = async () => {\n const opinlyRewrite = {\n source: `${opinlyOptions.imagesPath}/:path*`,\n destination: `${opinlyOptions.cdnDomain || \"https://cdn.opinly.ai\"}/${\n opinlyOptions.cdnNamespace\n }/:path*`,\n };\n\n const newRewrites = [opinlyRewrite];\n\n if (opinlyOptions.pagesRouter) {\n newRewrites.push({\n source: \"/sitemap.xml\",\n destination: \"/sitemap\",\n });\n }\n\n if (typeof originalRewrites !== \"function\") {\n return newRewrites;\n }\n\n const resolvedRewrites = await originalRewrites();\n\n if (Array.isArray(resolvedRewrites)) {\n return [...resolvedRewrites, opinlyRewrite];\n } else {\n return {\n ...resolvedRewrites,\n beforeFiles: [...(resolvedRewrites.beforeFiles || []), ...newRewrites],\n };\n }\n };\n};\n\nfunction addEnvVars(userNextConfig: NextConfig, opinlyOptions: OpinlyOptions) {\n const opinlyEnvVars: OpinlyEnvVars = {\n OPINLY_IMAGES_PREFIX: opinlyOptions.imagesPath,\n OPINLY_BLOG_PREFIX: opinlyOptions.blogPath,\n OPINLY_SITE_NAME: opinlyOptions.companyName,\n OPINLY_SITE_URL: opinlyOptions.siteUrl,\n OPINLY_UNOPTIMIZED_IMAGES: opinlyOptions.unoptimizedImages\n ? \"true\"\n : undefined,\n OPINLY_PAGES_ROUTER: opinlyOptions.pagesRouter ? \"true\" : undefined,\n };\n\n userNextConfig.env = {\n ...(userNextConfig.env || {}),\n ...opinlyEnvVars,\n };\n}\n\n/**\n * Modifies the passed in Next.js configuration with image rewrites and environment variables.\n *\n * @param nextConfig A Next.js configuration object, as usually exported in `next.config.js` or `next.config.mjs`.\n * @param opinlyOptions Additional options to configure Opinly.\n * @returns The modified config to be exported\n */\nexport const withOpinlyConfig =\n (opinlyOptions: OpinlyOptions) =>\n (nextConfig: NextConfig): NextConfig => {\n validateOpinlyOptions(opinlyOptions);\n\n addEnvVars(nextConfig, opinlyOptions);\n\n processRewrites(nextConfig, opinlyOptions);\n\n return nextConfig;\n };\n"],"mappings":"AAGA,SAAS,SAAS;AAelB,MAAM,sBAAsB,EAAE,OAAO;AAAA,EACnC,YAAY,EACT,OAAO,CAAC,CAAC,EACT;AAAA,IACC,CAAC,QAAQ,IAAI,WAAW,GAAG,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,UAAU,GAAG,EAAE;AAAA,IAChE;AAAA,MACE,SAAS;AAAA,IACX;AAAA,EACF;AAAA,EACF,UAAU,EAAE,OAAO,CAAC,CAAC,EAAE,WAAW,KAAK;AAAA,IACrC,SAAS;AAAA,EACX,CAAC;AAAA,EACD,aAAa,EAAE,OAAO;AAAA,IACpB,gBAAgB;AAAA,IAChB,oBAAoB;AAAA,EACtB,CAAC;AAAA,EACD,cAAc,EACX,OAAO,EACP,IAAI,IAAI,0CAA0C,EAClD,IAAI,IAAI,0CAA0C;AAAA,EACrD,SAAS,EAAE,OAAO,EAAE,IAAI;AAAA,IACtB,SAAS;AAAA,EACX,CAAC;AAAA,EACD,mBAAmB,EAAE,QAAQ,EAAE,SAAS;AAAA,EACxC,WAAW,EACR,OAAO;AAAA,IACN,aACE;AAAA,EACJ,CAAC,EACA,IAAI;AAAA,IACH,SAAS;AAAA,EACX,CAAC,EACA,SAAS;AAAA,EACZ,aAAa,EAAE,QAAQ,EAAE,SAAS;AACpC,CAAC;AAID,MAAM,wBAAwB,CAAC,kBAAiC;AAC9D,MAAI,CAAC,eAAe;AAClB,UAAM,IAAI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S;AAAA,EAC5D;AAEA,iBAAe,MAAM;AAAA,IACnB,GAAI,eAAe,OAAO,CAAC;AAAA,IAC3B,GAAG;AAAA,EACL;AACF;AASO,MAAM,mBACX,CAAC,kBACD,CAAC,eAAuC;AACtC,wBAAsB,aAAa;AAEnC,aAAW,YAAY,aAAa;AAEpC,kBAAgB,YAAY,aAAa;AAEzC,SAAO;AACT;","names":[]}
package/dist/index.cjs CHANGED
@@ -16,10 +16,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
16
16
  var index_exports = {};
17
17
  module.exports = __toCommonJS(index_exports);
18
18
  __reExport(index_exports, require("./components/opinly-blog"), module.exports);
19
- __reExport(index_exports, require("./utils/with-opinly-config"), module.exports);
20
19
  // Annotate the CommonJS export names for ESM import in node:
21
20
  0 && (module.exports = {
22
- ...require("./components/opinly-blog"),
23
- ...require("./utils/with-opinly-config")
21
+ ...require("./components/opinly-blog")
24
22
  });
25
23
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["export * from \"./components/opinly-blog\";\n\nexport * from \"./utils/with-opinly-config\";\n"],"mappings":";;;;;;;;;;;;;;;AAAA;AAAA;AAAA,0BAAc,qCAAd;AAEA,0BAAc,uCAFd;","names":[]}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["export * from \"./components/opinly-blog\";\n"],"mappings":";;;;;;;;;;;;;;;AAAA;AAAA;AAAA,0BAAc,qCAAd;","names":[]}
package/dist/index.d.cts CHANGED
@@ -1,6 +1,3 @@
1
1
  export { OpinlyBlog } from './components/opinly-blog.cjs';
2
- export { withOpinlyConfig } from './utils/with-opinly-config.cjs';
3
2
  import 'react/jsx-runtime';
4
3
  import '@opinly/backend';
5
- import 'next';
6
- import 'zod';
package/dist/index.d.ts CHANGED
@@ -1,6 +1,3 @@
1
1
  export { OpinlyBlog } from './components/opinly-blog.js';
2
- export { withOpinlyConfig } from './utils/with-opinly-config.js';
3
2
  import 'react/jsx-runtime';
4
3
  import '@opinly/backend';
5
- import 'next';
6
- import 'zod';
package/dist/index.js CHANGED
@@ -1,3 +1,2 @@
1
1
  export * from "./components/opinly-blog";
2
- export * from "./utils/with-opinly-config";
3
2
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["export * from \"./components/opinly-blog\";\n\nexport * from \"./utils/with-opinly-config\";\n"],"mappings":"AAAA,cAAc;AAEd,cAAc;","names":[]}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["export * from \"./components/opinly-blog\";\n"],"mappings":"AAAA,cAAc;","names":[]}
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
15
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
16
+ var pages_exports = {};
17
+ module.exports = __toCommonJS(pages_exports);
18
+ __reExport(pages_exports, require("./opinly-blog-pages"), module.exports);
19
+ // Annotate the CommonJS export names for ESM import in node:
20
+ 0 && (module.exports = {
21
+ ...require("./opinly-blog-pages")
22
+ });
23
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/pages/index.tsx"],"sourcesContent":["export * from \"./opinly-blog-pages\";\n"],"mappings":";;;;;;;;;;;;;;;AAAA;AAAA;AAAA,0BAAc,gCAAd;","names":[]}
@@ -0,0 +1,3 @@
1
+ export { OpinlyBlogPages } from './opinly-blog-pages.cjs';
2
+ import 'react/jsx-runtime';
3
+ import '@opinly/backend';
@@ -0,0 +1,3 @@
1
+ export { OpinlyBlogPages } from './opinly-blog-pages.js';
2
+ import 'react/jsx-runtime';
3
+ import '@opinly/backend';
@@ -0,0 +1,2 @@
1
+ export * from "./opinly-blog-pages";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/pages/index.tsx"],"sourcesContent":["export * from \"./opinly-blog-pages\";\n"],"mappings":"AAAA,cAAc;","names":[]}
@@ -0,0 +1,128 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var opinly_blog_pages_exports = {};
20
+ __export(opinly_blog_pages_exports, {
21
+ OpinlyBlogPages: () => OpinlyBlogPages
22
+ });
23
+ module.exports = __toCommonJS(opinly_blog_pages_exports);
24
+ var import_jsx_runtime = require("react/jsx-runtime");
25
+ var import_blog_post = require("../components/blog-post");
26
+ var import_folder_page = require("../components/folder-page");
27
+ var import_home_page = require("../components/home-page");
28
+ var import_author_page = require("../components/author-page");
29
+ var import_authors_page = require("../components/authors-page");
30
+ var import_next_seo = require("next-seo");
31
+ var import_sdk_config = require("../utils/sdk-config");
32
+ const OpinlyBlogPages = ({ blog }) => {
33
+ if (blog.type === "not-found") {
34
+ console.error(
35
+ "[@opinly/next] Received not-found result in blog path, this means that get server side props is not returning 'not-found' properly. Nothing will be rendered."
36
+ );
37
+ return null;
38
+ }
39
+ if (blog.type === "home") {
40
+ console.log("returning home page");
41
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
42
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
43
+ import_next_seo.NextSeo,
44
+ {
45
+ title: `${import_sdk_config.opinlyConfig.siteName} Blog`,
46
+ description: `Explore the latest articles from the ${import_sdk_config.opinlyConfig.siteName} Blog`,
47
+ openGraph: {
48
+ title: `${import_sdk_config.opinlyConfig.siteName} Blog`,
49
+ description: `Explore the latest articles from the ${import_sdk_config.opinlyConfig.siteName} Blog`
50
+ }
51
+ }
52
+ ),
53
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_home_page.HomePage, { data: blog.data }),
54
+ ";"
55
+ ] });
56
+ }
57
+ if (blog.type === "post") {
58
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
59
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
60
+ import_next_seo.NextSeo,
61
+ {
62
+ title: blog.data.title,
63
+ openGraph: {
64
+ title: blog.data.title,
65
+ description: blog.data.description
66
+ },
67
+ description: blog.data.description
68
+ }
69
+ ),
70
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_blog_post.BlogPost, { post: blog.data }),
71
+ ";"
72
+ ] });
73
+ }
74
+ if (blog.type === "author") {
75
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
76
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
77
+ import_next_seo.NextSeo,
78
+ {
79
+ title: `${import_sdk_config.opinlyConfig.siteName} Blog - ${blog.data.name}`,
80
+ description: blog.data.bio || void 0,
81
+ openGraph: {
82
+ title: `${import_sdk_config.opinlyConfig.siteName} Blog - ${blog.data.name}`,
83
+ description: blog.data.bio || void 0
84
+ }
85
+ }
86
+ ),
87
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_author_page.AuthorPage, { author: blog.data }),
88
+ ";"
89
+ ] });
90
+ }
91
+ if (blog.type === "authors") {
92
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
93
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
94
+ import_next_seo.NextSeo,
95
+ {
96
+ title: `${import_sdk_config.opinlyConfig.siteName} Blog - Authors`,
97
+ description: `Explore the authors of the ${import_sdk_config.opinlyConfig.siteName} Blog`,
98
+ openGraph: {
99
+ title: `${import_sdk_config.opinlyConfig.siteName} Blog - Authors`,
100
+ description: `Explore the authors of the ${import_sdk_config.opinlyConfig.siteName} Blog`
101
+ }
102
+ }
103
+ ),
104
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_authors_page.AuthorsPage, { authors: blog.data }),
105
+ ";"
106
+ ] });
107
+ }
108
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
109
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
110
+ import_next_seo.NextSeo,
111
+ {
112
+ title: `${import_sdk_config.opinlyConfig.siteName} Blog - Folder: ${blog.data.name}`,
113
+ description: blog.data.description || void 0,
114
+ openGraph: {
115
+ title: `${import_sdk_config.opinlyConfig.siteName} Blog - Folder: ${blog.data.name}`,
116
+ description: blog.data.description || void 0
117
+ }
118
+ }
119
+ ),
120
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_folder_page.FolderPage, { folder: blog.data }),
121
+ ";"
122
+ ] });
123
+ };
124
+ // Annotate the CommonJS export names for ESM import in node:
125
+ 0 && (module.exports = {
126
+ OpinlyBlogPages
127
+ });
128
+ //# sourceMappingURL=opinly-blog-pages.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/pages/opinly-blog-pages.tsx"],"sourcesContent":["import { BlogPost } from \"../components/blog-post\";\nimport { FolderPage } from \"../components/folder-page\";\nimport { Opinly } from \"@opinly/backend\";\nimport { HomePage } from \"../components/home-page\";\nimport { AuthorPage } from \"../components/author-page\";\nimport { AuthorsPage } from \"../components/authors-page\";\nimport { NextSeo } from \"next-seo\";\nimport { opinlyConfig } from \"../utils/sdk-config\";\n\ntype OpinlyBlogRes = Awaited<ReturnType<Opinly[\"content\"][\"blog\"]>>;\n\nexport const OpinlyBlogPages = ({ blog }: { blog: OpinlyBlogRes }) => {\n if (blog.type === \"not-found\") {\n // This should never happen as it will be handled by getServerSideProps\n console.error(\n \"[@opinly/next] Received not-found result in blog path, this means that get server side props is not returning 'not-found' properly. Nothing will be rendered.\"\n );\n return null;\n }\n\n if (blog.type === \"home\") {\n console.log(\"returning home page\");\n return (\n <>\n <NextSeo\n title={`${opinlyConfig.siteName} Blog`}\n description={`Explore the latest articles from the ${opinlyConfig.siteName} Blog`}\n openGraph={{\n title: `${opinlyConfig.siteName} Blog`,\n description: `Explore the latest articles from the ${opinlyConfig.siteName} Blog`,\n }}\n />\n <HomePage data={blog.data} />;\n </>\n );\n }\n\n if (blog.type === \"post\") {\n return (\n <>\n <NextSeo\n title={blog.data.title}\n openGraph={{\n title: blog.data.title,\n description: blog.data.description,\n }}\n description={blog.data.description}\n />\n <BlogPost post={blog.data} />;\n </>\n );\n }\n\n if (blog.type === \"author\") {\n return (\n <>\n <NextSeo\n title={`${opinlyConfig.siteName} Blog - ${blog.data.name}`}\n description={blog.data.bio || undefined}\n openGraph={{\n title: `${opinlyConfig.siteName} Blog - ${blog.data.name}`,\n description: blog.data.bio || undefined,\n }}\n />\n <AuthorPage author={blog.data} />;\n </>\n );\n }\n\n if (blog.type === \"authors\") {\n return (\n <>\n <NextSeo\n title={`${opinlyConfig.siteName} Blog - Authors`}\n description={`Explore the authors of the ${opinlyConfig.siteName} Blog`}\n openGraph={{\n title: `${opinlyConfig.siteName} Blog - Authors`,\n description: `Explore the authors of the ${opinlyConfig.siteName} Blog`,\n }}\n />\n <AuthorsPage authors={blog.data} />;\n </>\n );\n }\n\n return (\n <>\n <NextSeo\n title={`${opinlyConfig.siteName} Blog - Folder: ${blog.data.name}`}\n description={blog.data.description || undefined}\n openGraph={{\n title: `${opinlyConfig.siteName} Blog - Folder: ${blog.data.name}`,\n description: blog.data.description || undefined,\n }}\n />\n <FolderPage folder={blog.data} />;\n </>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAuBM;AAvBN,uBAAyB;AACzB,yBAA2B;AAE3B,uBAAyB;AACzB,yBAA2B;AAC3B,0BAA4B;AAC5B,sBAAwB;AACxB,wBAA6B;AAItB,MAAM,kBAAkB,CAAC,EAAE,KAAK,MAA+B;AACpE,MAAI,KAAK,SAAS,aAAa;AAE7B,YAAQ;AAAA,MACN;AAAA,IACF;AACA,WAAO;AAAA,EACT;AAEA,MAAI,KAAK,SAAS,QAAQ;AACxB,YAAQ,IAAI,qBAAqB;AACjC,WACE,4EACE;AAAA;AAAA,QAAC;AAAA;AAAA,UACC,OAAO,GAAG,+BAAa,QAAQ;AAAA,UAC/B,aAAa,wCAAwC,+BAAa,QAAQ;AAAA,UAC1E,WAAW;AAAA,YACT,OAAO,GAAG,+BAAa,QAAQ;AAAA,YAC/B,aAAa,wCAAwC,+BAAa,QAAQ;AAAA,UAC5E;AAAA;AAAA,MACF;AAAA,MACA,4CAAC,6BAAS,MAAM,KAAK,MAAM;AAAA,MAAE;AAAA,OAC/B;AAAA,EAEJ;AAEA,MAAI,KAAK,SAAS,QAAQ;AACxB,WACE,4EACE;AAAA;AAAA,QAAC;AAAA;AAAA,UACC,OAAO,KAAK,KAAK;AAAA,UACjB,WAAW;AAA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A,IACF;AAAA,IACA,4CAAC,iCAAW,QAAQ,KAAK,MAAM;AAAA,IAAE;AAAA,KACnC;AAEJ;","names":[]}
@@ -0,0 +1,9 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { Opinly } from '@opinly/backend';
3
+
4
+ type OpinlyBlogRes = Awaited<ReturnType<Opinly["content"]["blog"]>>;
5
+ declare const OpinlyBlogPages: ({ blog }: {
6
+ blog: OpinlyBlogRes;
7
+ }) => react_jsx_runtime.JSX.Element | null;
8
+
9
+ export { OpinlyBlogPages };
@@ -0,0 +1,9 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { Opinly } from '@opinly/backend';
3
+
4
+ type OpinlyBlogRes = Awaited<ReturnType<Opinly["content"]["blog"]>>;
5
+ declare const OpinlyBlogPages: ({ blog }: {
6
+ blog: OpinlyBlogRes;
7
+ }) => react_jsx_runtime.JSX.Element | null;
8
+
9
+ export { OpinlyBlogPages };
@@ -0,0 +1,104 @@
1
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
+ import { BlogPost } from "../components/blog-post";
3
+ import { FolderPage } from "../components/folder-page";
4
+ import { HomePage } from "../components/home-page";
5
+ import { AuthorPage } from "../components/author-page";
6
+ import { AuthorsPage } from "../components/authors-page";
7
+ import { NextSeo } from "next-seo";
8
+ import { opinlyConfig } from "../utils/sdk-config";
9
+ const OpinlyBlogPages = ({ blog }) => {
10
+ if (blog.type === "not-found") {
11
+ console.error(
12
+ "[@opinly/next] Received not-found result in blog path, this means that get server side props is not returning 'not-found' properly. Nothing will be rendered."
13
+ );
14
+ return null;
15
+ }
16
+ if (blog.type === "home") {
17
+ console.log("returning home page");
18
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
19
+ /* @__PURE__ */ jsx(
20
+ NextSeo,
21
+ {
22
+ title: `${opinlyConfig.siteName} Blog`,
23
+ description: `Explore the latest articles from the ${opinlyConfig.siteName} Blog`,
24
+ openGraph: {
25
+ title: `${opinlyConfig.siteName} Blog`,
26
+ description: `Explore the latest articles from the ${opinlyConfig.siteName} Blog`
27
+ }
28
+ }
29
+ ),
30
+ /* @__PURE__ */ jsx(HomePage, { data: blog.data }),
31
+ ";"
32
+ ] });
33
+ }
34
+ if (blog.type === "post") {
35
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
36
+ /* @__PURE__ */ jsx(
37
+ NextSeo,
38
+ {
39
+ title: blog.data.title,
40
+ openGraph: {
41
+ title: blog.data.title,
42
+ description: blog.data.description
43
+ },
44
+ description: blog.data.description
45
+ }
46
+ ),
47
+ /* @__PURE__ */ jsx(BlogPost, { post: blog.data }),
48
+ ";"
49
+ ] });
50
+ }
51
+ if (blog.type === "author") {
52
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
53
+ /* @__PURE__ */ jsx(
54
+ NextSeo,
55
+ {
56
+ title: `${opinlyConfig.siteName} Blog - ${blog.data.name}`,
57
+ description: blog.data.bio || void 0,
58
+ openGraph: {
59
+ title: `${opinlyConfig.siteName} Blog - ${blog.data.name}`,
60
+ description: blog.data.bio || void 0
61
+ }
62
+ }
63
+ ),
64
+ /* @__PURE__ */ jsx(AuthorPage, { author: blog.data }),
65
+ ";"
66
+ ] });
67
+ }
68
+ if (blog.type === "authors") {
69
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
70
+ /* @__PURE__ */ jsx(
71
+ NextSeo,
72
+ {
73
+ title: `${opinlyConfig.siteName} Blog - Authors`,
74
+ description: `Explore the authors of the ${opinlyConfig.siteName} Blog`,
75
+ openGraph: {
76
+ title: `${opinlyConfig.siteName} Blog - Authors`,
77
+ description: `Explore the authors of the ${opinlyConfig.siteName} Blog`
78
+ }
79
+ }
80
+ ),
81
+ /* @__PURE__ */ jsx(AuthorsPage, { authors: blog.data }),
82
+ ";"
83
+ ] });
84
+ }
85
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
86
+ /* @__PURE__ */ jsx(
87
+ NextSeo,
88
+ {
89
+ title: `${opinlyConfig.siteName} Blog - Folder: ${blog.data.name}`,
90
+ description: blog.data.description || void 0,
91
+ openGraph: {
92
+ title: `${opinlyConfig.siteName} Blog - Folder: ${blog.data.name}`,
93
+ description: blog.data.description || void 0
94
+ }
95
+ }
96
+ ),
97
+ /* @__PURE__ */ jsx(FolderPage, { folder: blog.data }),
98
+ ";"
99
+ ] });
100
+ };
101
+ export {
102
+ OpinlyBlogPages
103
+ };
104
+ //# sourceMappingURL=opinly-blog-pages.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/pages/opinly-blog-pages.tsx"],"sourcesContent":["import { BlogPost } from \"../components/blog-post\";\nimport { FolderPage } from \"../components/folder-page\";\nimport { Opinly } from \"@opinly/backend\";\nimport { HomePage } from \"../components/home-page\";\nimport { AuthorPage } from \"../components/author-page\";\nimport { AuthorsPage } from \"../components/authors-page\";\nimport { NextSeo } from \"next-seo\";\nimport { opinlyConfig } from \"../utils/sdk-config\";\n\ntype OpinlyBlogRes = Awaited<ReturnType<Opinly[\"content\"][\"blog\"]>>;\n\nexport const OpinlyBlogPages = ({ blog }: { blog: OpinlyBlogRes }) => {\n if (blog.type === \"not-found\") {\n // This should never happen as it will be handled by getServerSideProps\n console.error(\n \"[@opinly/next] Received not-found result in blog path, this means that get server side props is not returning 'not-found' properly. Nothing will be rendered.\"\n );\n return null;\n }\n\n if (blog.type === \"home\") {\n console.log(\"returning home page\");\n return (\n <>\n <NextSeo\n title={`${opinlyConfig.siteName} Blog`}\n description={`Explore the latest articles from the ${opinlyConfig.siteName} Blog`}\n openGraph={{\n title: `${opinlyConfig.siteName} Blog`,\n description: `Explore the latest articles from the ${opinlyConfig.siteName} Blog`,\n }}\n />\n <HomePage data={blog.data} />;\n </>\n );\n }\n\n if (blog.type === \"post\") {\n return (\n <>\n <NextSeo\n title={blog.data.title}\n openGraph={{\n title: blog.data.title,\n description: blog.data.description,\n }}\n description={blog.data.description}\n />\n <BlogPost post={blog.data} />;\n </>\n );\n }\n\n if (blog.type === \"author\") {\n return (\n <>\n <NextSeo\n title={`${opinlyConfig.siteName} Blog - ${blog.data.name}`}\n description={blog.data.bio || undefined}\n openGraph={{\n title: `${opinlyConfig.siteName} Blog - ${blog.data.name}`,\n description: blog.data.bio || undefined,\n }}\n />\n <AuthorPage author={blog.data} />;\n </>\n );\n }\n\n if (blog.type === \"authors\") {\n return (\n <>\n <NextSeo\n title={`${opinlyConfig.siteName} Blog - Authors`}\n description={`Explore the authors of the ${opinlyConfig.siteName} Blog`}\n openGraph={{\n title: `${opinlyConfig.siteName} Blog - Authors`,\n description: `Explore the authors of the ${opinlyConfig.siteName} Blog`,\n }}\n />\n <AuthorsPage authors={blog.data} />;\n </>\n );\n }\n\n return (\n <>\n <NextSeo\n title={`${opinlyConfig.siteName} Blog - Folder: ${blog.data.name}`}\n description={blog.data.description || undefined}\n openGraph={{\n title: `${opinlyConfig.siteName} Blog - Folder: ${blog.data.name}`,\n description: blog.data.description || undefined,\n }}\n />\n <FolderPage folder={blog.data} />;\n </>\n );\n};\n"],"mappings":"AAuBM,mBACE,KADF;AAvBN,SAAS,gBAAgB;AACzB,SAAS,kBAAkB;AAE3B,SAAS,gBAAgB;AACzB,SAAS,kBAAkB;AAC3B,SAAS,mBAAmB;AAC5B,SAAS,eAAe;AACxB,SAAS,oBAAoB;AAItB,MAAM,kBAAkB,CAAC,EAAE,KAAK,MAA+B;AACpE,MAAI,KAAK,SAAS,aAAa;AAE7B,YAAQ;AAAA,MACN;AAAA,IACF;AACA,WAAO;AAAA,EACT;AAEA,MAAI,KAAK,SAAS,QAAQ;AACxB,YAAQ,IAAI,qBAAqB;AACjC,WACE,iCACE;AAAA;AAAA,QAAC;AAAA;AAAA,UACC,OAAO,GAAG,aAAa,QAAQ;AAAA,UAC/B,aAAa,wCAAwC,aAAa,QAAQ;AAAA,UAC1E,WAAW;AAAA,YACT,OAAO,GAAG,aAAa,QAAQ;AAAA,YAC/B,aAAa,wCAAwC,aAAa,QAAQ;AAAA,UAC5E;AAAA;AAAA,MACF;AA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,KAAK,IAAI;AAAA,QAChE,aAAa,KAAK,KAAK,eAAe;AAAA,QACtC,WAAW;AAAA,UACT,OAAO,GAAG,aAAa,QAAQ,mBAAmB,KAAK,KAAK,IAAI;AAAA,UAChE,aAAa,KAAK,KAAK,eAAe;AAAA,QACxC;AAAA;AAAA,IACF;AAAA,IACA,oBAAC,cAAW,QAAQ,KAAK,MAAM;AAAA,IAAE;AAAA,KACnC;AAEJ;","names":[]}
@@ -23,7 +23,7 @@ __export(generate_metadata_exports, {
23
23
  module.exports = __toCommonJS(generate_metadata_exports);
24
24
  var import_sdk_config = require("./sdk-config");
25
25
  const generateOpinlyMetadata = async (client, params, parent) => {
26
- const blog = await client.content.blog({ params: await params });
26
+ const blog = await client.content.blog(params);
27
27
  if (blog.type === "not-found") {
28
28
  return parent;
29
29
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utils/generate-metadata.ts"],"sourcesContent":["import { Opinly } from \"@opinly/backend\";\nimport type { Metadata, ResolvingMetadata } from \"next\";\nimport { opinlyConfig } from \"./sdk-config\";\n\nexport const generateOpinlyMetadata = async (\n client: Opinly,\n params: Promise<{\n slug: string[];\n }>,\n parent: ResolvingMetadata\n): Promise<Metadata> => {\n const blog = await client.content.blog({ params: await params });\n\n if (blog.type === \"not-found\") {\n return parent as Metadata;\n }\n\n const previousImages = (await parent).openGraph?.images || [];\n\n if (blog.type === \"post\") {\n const openGraphImageKey = blog.data?.titleFile?.fileKey;\n\n const images = openGraphImageKey\n ? [`${opinlyConfig.imagesPrefix}/${openGraphImageKey}`, ...previousImages]\n : previousImages;\n\n return {\n ...(parent as Metadata),\n title: blog.data.title,\n description: blog.data.description,\n openGraph: {\n images: images,\n type: \"article\",\n authors: blog.data.author && [\n `${opinlyConfig.imagesPrefix}/authors/${blog.data.author.slug}`,\n ],\n title: blog.data.title,\n },\n // keywords: [blog.data.keywords],\n\n authors: blog.data.author && [\n {\n name: blog.data.author.name,\n url: `${opinlyConfig.imagesPrefix}/authors/${blog.data.author.slug}`,\n },\n ],\n other: {},\n };\n }\n\n return parent as Metadata;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,wBAA6B;AAEtB,MAAM,yBAAyB,OACpC,QACA,QAGA,WACsB;AACtB,QAAM,OAAO,MAAM,OAAO,QAAQ,KAAK,EAAE,QAAQ,MAAM,OAAO,CAAC;AAE/D,MAAI,KAAK,SAAS,aAAa;AAC7B,WAAO;AAAA,EACT;AAEA,QAAM,kBAAkB,MAAM,QAAQ,WAAW,UAAU,CAAC;AAE5D,MAAI,KAAK,SAAS,QAAQ;AACxB,UAAM,oBAAoB,KAAK,MAAM,WAAW;AAEhD,UAAM,SAAS,oBACX,CAAC,GAAG,+BAAa,YAAY,IAAI,iBAAiB,IAAI,GAAG,cAAc,IACvE;AAEJ,WAAO;AAAA,MACL,GAAI;AAAA,MACJ,OAAO,KAAK,KAAK;AAAA,MACjB,aAAa,KAAK,KAAK;AAAA,MACvB,WAAW;AAAA,QACT;AAAA,QACA,MAAM;AAAA,QACN,SAAS,KAAK,KAAK,UAAU;AAAA,UAC3B,GAAG,+BAAa,YAAY,YAAY,KAAK,KAAK,OAAO,IAAI;AAAA,QAC/D;AAAA,QACA,OAAO,KAAK,KAAK;AAAA,MACnB;AAAA;AAAA,MAGA,SAAS,KAAK,KAAK,UAAU;AAAA,QAC3B;AAAA,UACE,MAAM,KAAK,KAAK,OAAO;AAAA,UACvB,KAAK,GAAG,+BAAa,YAAY,YAAY,KAAK,KAAK,OAAO,IAAI;AAAA,QACpE;AAAA,MACF;AAAA,MACA,OAAO,CAAC;AAAA,IACV;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}
1
+ {"version":3,"sources":["../../src/utils/generate-metadata.ts"],"sourcesContent":["import { Opinly, OpinlyPagePropsPromisified } from \"@opinly/backend\";\nimport type { Metadata, ResolvingMetadata } from \"next\";\nimport { opinlyConfig } from \"./sdk-config\";\n\nexport const generateOpinlyMetadata = async (\n client: Opinly,\n params: OpinlyPagePropsPromisified,\n parent: ResolvingMetadata\n): Promise<Metadata> => {\n const blog = await client.content.blog(params);\n\n if (blog.type === \"not-found\") {\n return parent as Metadata;\n }\n\n const previousImages = (await parent).openGraph?.images || [];\n\n if (blog.type === \"post\") {\n const openGraphImageKey = blog.data?.titleFile?.fileKey;\n\n const images = openGraphImageKey\n ? [`${opinlyConfig.imagesPrefix}/${openGraphImageKey}`, ...previousImages]\n : previousImages;\n\n return {\n ...(parent as Metadata),\n title: blog.data.title,\n description: blog.data.description,\n openGraph: {\n images: images,\n type: \"article\",\n authors: blog.data.author && [\n `${opinlyConfig.imagesPrefix}/authors/${blog.data.author.slug}`,\n ],\n title: blog.data.title,\n },\n // keywords: [blog.data.keywords],\n\n authors: blog.data.author && [\n {\n name: blog.data.author.name,\n url: `${opinlyConfig.imagesPrefix}/authors/${blog.data.author.slug}`,\n },\n ],\n other: {},\n };\n }\n\n return parent as Metadata;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,wBAA6B;AAEtB,MAAM,yBAAyB,OACpC,QACA,QACA,WACsB;AACtB,QAAM,OAAO,MAAM,OAAO,QAAQ,KAAK,MAAM;AAE7C,MAAI,KAAK,SAAS,aAAa;AAC7B,WAAO;AAAA,EACT;AAEA,QAAM,kBAAkB,MAAM,QAAQ,WAAW,UAAU,CAAC;AAE5D,MAAI,KAAK,SAAS,QAAQ;AACxB,UAAM,oBAAoB,KAAK,MAAM,WAAW;AAEhD,UAAM,SAAS,oBACX,CAAC,GAAG,+BAAa,YAAY,IAAI,iBAAiB,IAAI,GAAG,cAAc,IACvE;AAEJ,WAAO;AAAA,MACL,GAAI;AAAA,MACJ,OAAO,KAAK,KAAK;AAAA,MACjB,aAAa,KAAK,KAAK;AAAA,MACvB,WAAW;AAAA,QACT;AAAA,QACA,MAAM;AAAA,QACN,SAAS,KAAK,KAAK,UAAU;AAAA,UAC3B,GAAG,+BAAa,YAAY,YAAY,KAAK,KAAK,OAAO,IAAI;AAAA,QAC/D;AAAA,QACA,OAAO,KAAK,KAAK;AAAA,MACnB;AAAA;AAAA,MAGA,SAAS,KAAK,KAAK,UAAU;AAAA,QAC3B;AAAA,UACE,MAAM,KAAK,KAAK,OAAO;AAAA,UACvB,KAAK,GAAG,+BAAa,YAAY,YAAY,KAAK,KAAK,OAAO,IAAI;AAAA,QACpE;AAAA,MACF;AAAA,MACA,OAAO,CAAC;AAAA,IACV;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}