@opinly/next 1.1.0 → 1.3.0
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/config.cjs +3 -1
- package/dist/config.cjs.map +1 -1
- package/dist/config.d.cts +3 -0
- package/dist/config.d.ts +3 -0
- package/dist/config.js +3 -1
- package/dist/config.js.map +1 -1
- package/dist/pixel.cjs +58 -0
- package/dist/pixel.cjs.map +1 -0
- package/dist/pixel.d.cts +9 -0
- package/dist/pixel.d.ts +9 -0
- package/dist/pixel.js +25 -0
- package/dist/pixel.js.map +1 -0
- package/dist/utils/generate-metadata.cjs +2 -1
- package/dist/utils/generate-metadata.cjs.map +1 -1
- package/dist/utils/generate-metadata.js +2 -1
- package/dist/utils/generate-metadata.js.map +1 -1
- package/dist/utils/sdk-config.cjs +4 -2
- package/dist/utils/sdk-config.cjs.map +1 -1
- package/dist/utils/sdk-config.d.cts +2 -0
- package/dist/utils/sdk-config.d.ts +2 -0
- package/dist/utils/sdk-config.js +4 -2
- package/dist/utils/sdk-config.js.map +1 -1
- package/package.json +8 -3
package/dist/config.cjs
CHANGED
|
@@ -43,6 +43,7 @@ const opinlyOptionsSchema = import_zod.z.object({
|
|
|
43
43
|
unoptimizedImages: import_zod.z.boolean().optional(),
|
|
44
44
|
categoryPrefix: import_zod.z.string().optional(),
|
|
45
45
|
authorPrefix: import_zod.z.string().optional(),
|
|
46
|
+
tagPrefix: import_zod.z.string().optional(),
|
|
46
47
|
cdnDomain: import_zod.z.string({
|
|
47
48
|
description: "INTERNAL USE ONLY: The domain of the CDN. If not provided, the default domain will be used."
|
|
48
49
|
}).url({
|
|
@@ -107,7 +108,8 @@ function addEnvVars(userNextConfig, opinlyOptions) {
|
|
|
107
108
|
OPINLY_UNOPTIMIZED_IMAGES: opinlyOptions.unoptimizedImages ? "true" : void 0,
|
|
108
109
|
OPINLY_PAGES_ROUTER: opinlyOptions.pagesRouter ? "true" : void 0,
|
|
109
110
|
OPINLY_CATEGORY_PREFIX: opinlyOptions.categoryPrefix,
|
|
110
|
-
OPINLY_AUTHOR_PREFIX: opinlyOptions.authorPrefix
|
|
111
|
+
OPINLY_AUTHOR_PREFIX: opinlyOptions.authorPrefix,
|
|
112
|
+
OPINLY_TAG_PREFIX: opinlyOptions.tagPrefix
|
|
111
113
|
};
|
|
112
114
|
userNextConfig.env = {
|
|
113
115
|
...userNextConfig.env || {},
|
package/dist/config.cjs.map
CHANGED
|
@@ -1 +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 /** URL segment categories live under (relative to blogPath). Default: bare. */\n categoryPrefix?: string;\n /** URL segment authors live under (relative to blogPath). Default: \"authors\". */\n authorPrefix?: string;\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 categoryPrefix: z.string().optional(),\n authorPrefix: z.string().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 OPINLY_CATEGORY_PREFIX: opinlyOptions.categoryPrefix,\n OPINLY_AUTHOR_PREFIX: opinlyOptions.authorPrefix,\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 // Generic over the config type so this composes with any Next version's\n // `NextConfig` (the consumer's next may differ from the one this package was\n // built against). We only read/write `env` and `rewrites` internally.\n <T extends object>(nextConfig: T): T => {\n validateOpinlyOptions(opinlyOptions);\n\n addEnvVars(nextConfig as NextConfig, opinlyOptions);\n\n processRewrites(nextConfig as NextConfig, opinlyOptions);\n\n return nextConfig;\n };\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,iBAAkB;
|
|
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 /** URL segment categories live under (relative to blogPath). Default: bare. */\n categoryPrefix?: string;\n /** URL segment authors live under (relative to blogPath). Default: \"authors\". */\n authorPrefix?: string;\n /** URL segment tags live under (relative to blogPath). Default: \"tag\". */\n tagPrefix?: string;\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 categoryPrefix: z.string().optional(),\n authorPrefix: z.string().optional(),\n tagPrefix: z.string().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 OPINLY_CATEGORY_PREFIX: opinlyOptions.categoryPrefix,\n OPINLY_AUTHOR_PREFIX: opinlyOptions.authorPrefix,\n OPINLY_TAG_PREFIX: opinlyOptions.tagPrefix,\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 // Generic over the config type so this composes with any Next version's\n // `NextConfig` (the consumer's next may differ from the one this package was\n // built against). We only read/write `env` and `rewrites` internally.\n <T extends object>(nextConfig: T): T => {\n validateOpinlyOptions(opinlyOptions);\n\n addEnvVars(nextConfig as NextConfig, opinlyOptions);\n\n processRewrites(nextConfig as NextConfig, opinlyOptions);\n\n return nextConfig;\n };\n"],"mappings":"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","names":[]}
|
package/dist/config.d.cts
CHANGED
|
@@ -9,6 +9,7 @@ declare const opinlyOptionsSchema: z.ZodObject<{
|
|
|
9
9
|
unoptimizedImages: z.ZodOptional<z.ZodBoolean>;
|
|
10
10
|
categoryPrefix: z.ZodOptional<z.ZodString>;
|
|
11
11
|
authorPrefix: z.ZodOptional<z.ZodString>;
|
|
12
|
+
tagPrefix: z.ZodOptional<z.ZodString>;
|
|
12
13
|
cdnDomain: z.ZodOptional<z.ZodString>;
|
|
13
14
|
pagesRouter: z.ZodOptional<z.ZodBoolean>;
|
|
14
15
|
}, "strip", z.ZodTypeAny, {
|
|
@@ -20,6 +21,7 @@ declare const opinlyOptionsSchema: z.ZodObject<{
|
|
|
20
21
|
unoptimizedImages?: boolean | undefined;
|
|
21
22
|
categoryPrefix?: string | undefined;
|
|
22
23
|
authorPrefix?: string | undefined;
|
|
24
|
+
tagPrefix?: string | undefined;
|
|
23
25
|
cdnDomain?: string | undefined;
|
|
24
26
|
pagesRouter?: boolean | undefined;
|
|
25
27
|
}, {
|
|
@@ -31,6 +33,7 @@ declare const opinlyOptionsSchema: z.ZodObject<{
|
|
|
31
33
|
unoptimizedImages?: boolean | undefined;
|
|
32
34
|
categoryPrefix?: string | undefined;
|
|
33
35
|
authorPrefix?: string | undefined;
|
|
36
|
+
tagPrefix?: string | undefined;
|
|
34
37
|
cdnDomain?: string | undefined;
|
|
35
38
|
pagesRouter?: boolean | undefined;
|
|
36
39
|
}>;
|
package/dist/config.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ declare const opinlyOptionsSchema: z.ZodObject<{
|
|
|
9
9
|
unoptimizedImages: z.ZodOptional<z.ZodBoolean>;
|
|
10
10
|
categoryPrefix: z.ZodOptional<z.ZodString>;
|
|
11
11
|
authorPrefix: z.ZodOptional<z.ZodString>;
|
|
12
|
+
tagPrefix: z.ZodOptional<z.ZodString>;
|
|
12
13
|
cdnDomain: z.ZodOptional<z.ZodString>;
|
|
13
14
|
pagesRouter: z.ZodOptional<z.ZodBoolean>;
|
|
14
15
|
}, "strip", z.ZodTypeAny, {
|
|
@@ -20,6 +21,7 @@ declare const opinlyOptionsSchema: z.ZodObject<{
|
|
|
20
21
|
unoptimizedImages?: boolean | undefined;
|
|
21
22
|
categoryPrefix?: string | undefined;
|
|
22
23
|
authorPrefix?: string | undefined;
|
|
24
|
+
tagPrefix?: string | undefined;
|
|
23
25
|
cdnDomain?: string | undefined;
|
|
24
26
|
pagesRouter?: boolean | undefined;
|
|
25
27
|
}, {
|
|
@@ -31,6 +33,7 @@ declare const opinlyOptionsSchema: z.ZodObject<{
|
|
|
31
33
|
unoptimizedImages?: boolean | undefined;
|
|
32
34
|
categoryPrefix?: string | undefined;
|
|
33
35
|
authorPrefix?: string | undefined;
|
|
36
|
+
tagPrefix?: string | undefined;
|
|
34
37
|
cdnDomain?: string | undefined;
|
|
35
38
|
pagesRouter?: boolean | undefined;
|
|
36
39
|
}>;
|
package/dist/config.js
CHANGED
|
@@ -20,6 +20,7 @@ const opinlyOptionsSchema = z.object({
|
|
|
20
20
|
unoptimizedImages: z.boolean().optional(),
|
|
21
21
|
categoryPrefix: z.string().optional(),
|
|
22
22
|
authorPrefix: z.string().optional(),
|
|
23
|
+
tagPrefix: z.string().optional(),
|
|
23
24
|
cdnDomain: z.string({
|
|
24
25
|
description: "INTERNAL USE ONLY: The domain of the CDN. If not provided, the default domain will be used."
|
|
25
26
|
}).url({
|
|
@@ -84,7 +85,8 @@ function addEnvVars(userNextConfig, opinlyOptions) {
|
|
|
84
85
|
OPINLY_UNOPTIMIZED_IMAGES: opinlyOptions.unoptimizedImages ? "true" : void 0,
|
|
85
86
|
OPINLY_PAGES_ROUTER: opinlyOptions.pagesRouter ? "true" : void 0,
|
|
86
87
|
OPINLY_CATEGORY_PREFIX: opinlyOptions.categoryPrefix,
|
|
87
|
-
OPINLY_AUTHOR_PREFIX: opinlyOptions.authorPrefix
|
|
88
|
+
OPINLY_AUTHOR_PREFIX: opinlyOptions.authorPrefix,
|
|
89
|
+
OPINLY_TAG_PREFIX: opinlyOptions.tagPrefix
|
|
88
90
|
};
|
|
89
91
|
userNextConfig.env = {
|
|
90
92
|
...userNextConfig.env || {},
|
package/dist/config.js.map
CHANGED
|
@@ -1 +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 /** URL segment categories live under (relative to blogPath). Default: bare. */\n categoryPrefix?: string;\n /** URL segment authors live under (relative to blogPath). Default: \"authors\". */\n authorPrefix?: string;\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 categoryPrefix: z.string().optional(),\n authorPrefix: z.string().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 OPINLY_CATEGORY_PREFIX: opinlyOptions.categoryPrefix,\n OPINLY_AUTHOR_PREFIX: opinlyOptions.authorPrefix,\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 // Generic over the config type so this composes with any Next version's\n // `NextConfig` (the consumer's next may differ from the one this package was\n // built against). We only read/write `env` and `rewrites` internally.\n <T extends object>(nextConfig: T): T => {\n validateOpinlyOptions(opinlyOptions);\n\n addEnvVars(nextConfig as NextConfig, opinlyOptions);\n\n processRewrites(nextConfig as NextConfig, opinlyOptions);\n\n return nextConfig;\n };\n"],"mappings":"AAGA,SAAS,SAAS;
|
|
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 /** URL segment categories live under (relative to blogPath). Default: bare. */\n categoryPrefix?: string;\n /** URL segment authors live under (relative to blogPath). Default: \"authors\". */\n authorPrefix?: string;\n /** URL segment tags live under (relative to blogPath). Default: \"tag\". */\n tagPrefix?: string;\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 categoryPrefix: z.string().optional(),\n authorPrefix: z.string().optional(),\n tagPrefix: z.string().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 OPINLY_CATEGORY_PREFIX: opinlyOptions.categoryPrefix,\n OPINLY_AUTHOR_PREFIX: opinlyOptions.authorPrefix,\n OPINLY_TAG_PREFIX: opinlyOptions.tagPrefix,\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 // Generic over the config type so this composes with any Next version's\n // `NextConfig` (the consumer's next may differ from the one this package was\n // built against). We only read/write `env` and `rewrites` internally.\n <T extends object>(nextConfig: T): T => {\n validateOpinlyOptions(opinlyOptions);\n\n addEnvVars(nextConfig as NextConfig, opinlyOptions);\n\n processRewrites(nextConfig as NextConfig, opinlyOptions);\n\n return nextConfig;\n };\n"],"mappings":"AAGA,SAAS,SAAS;AAqBlB,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,gBAAgB,EAAE,OAAO,EAAE,SAAS;AAAA,EACpC,cAAc,EAAE,OAAO,EAAE,SAAS;AAAA,EAClC,WAAW,EAAE,OAAO,EAAE,SAAS;AAAA,EAC/B,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;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAEA,QAAM,sBAAsB,oBAAoB,UAAU,aAAa;AAEvE,MAAI,CAAC,oBAAoB,SAAS;AAChC,UAAM,IAAI;AAAA,MACR,8DAA8D,oBAAoB,MAAM,OAAO;AAAA,IACjG;AAAA,EACF;AACF;AAEA,MAAM,kBAAkB,CACtB,gBACA,kBACS;AACT,QAAM,aAAa,cAAc;AAEjC,MAAI,CAAC,WAAW,WAAW,GAAG,GAAG;AAC/B,YAAQ;AAAA,MACN;AAAA,IACF;AAEA;AAAA,EACF;AAEA,QAAM,mBAAmB,eAAe;AAExC,iBAAe,WAAW,YAAY;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,IAC1D,wBAAwB,cAAc;AAAA,IACtC,sBAAsB,cAAc;AAAA,IACpC,mBAAmB,cAAc;AAAA,EACnC;AAEA,iBAAe,MAAM;AAAA,IACnB,GAAI,eAAe,OAAO,CAAC;AAAA,IAC3B,GAAG;AAAA,EACL;AACF;AASO,MAAM,mBACX,CAAC;AAAA;AAAA;AAAA;AAAA,EAID,CAAmB,eAAqB;AACtC,0BAAsB,aAAa;AAEnC,eAAW,YAA0B,aAAa;AAElD,oBAAgB,YAA0B,aAAa;AAEvD,WAAO;AAAA,EACT;AAAA;","names":[]}
|
package/dist/pixel.cjs
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __export = (target, all) => {
|
|
10
|
+
for (var name in all)
|
|
11
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from))
|
|
16
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
17
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
|
+
}
|
|
19
|
+
return to;
|
|
20
|
+
};
|
|
21
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
+
mod
|
|
28
|
+
));
|
|
29
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
|
+
var pixel_exports = {};
|
|
31
|
+
__export(pixel_exports, {
|
|
32
|
+
OpinlyPixel: () => OpinlyPixel,
|
|
33
|
+
useOpinly: () => useOpinly
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(pixel_exports);
|
|
36
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
37
|
+
var import_script = __toESM(require("next/script"), 1);
|
|
38
|
+
var import_pixel = require("@opinly/shared/pixel");
|
|
39
|
+
function OpinlyPixel({ writeKey, host }) {
|
|
40
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
41
|
+
import_script.default,
|
|
42
|
+
{
|
|
43
|
+
id: "opinly-pixel",
|
|
44
|
+
src: `${host.replace(/\/+$/, "")}/p.js`,
|
|
45
|
+
"data-key": writeKey,
|
|
46
|
+
strategy: "afterInteractive"
|
|
47
|
+
}
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
function useOpinly() {
|
|
51
|
+
return (0, import_pixel.getOpinlyPixel)();
|
|
52
|
+
}
|
|
53
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
54
|
+
0 && (module.exports = {
|
|
55
|
+
OpinlyPixel,
|
|
56
|
+
useOpinly
|
|
57
|
+
});
|
|
58
|
+
//# sourceMappingURL=pixel.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/pixel.tsx"],"sourcesContent":["\"use client\";\nimport Script from \"next/script\";\nimport {\n getOpinlyPixel,\n type Opinly,\n type OpinlyPixelConfig,\n} from \"@opinly/shared/pixel\";\n\nexport type { Opinly } from \"@opinly/shared/pixel\";\nexport type OpinlyPixelProps = OpinlyPixelConfig;\n\nexport function OpinlyPixel({ writeKey, host }: OpinlyPixelProps) {\n return (\n <Script\n id=\"opinly-pixel\"\n src={`${host.replace(/\\/+$/, \"\")}/p.js`}\n data-key={writeKey}\n strategy=\"afterInteractive\"\n />\n );\n}\n\nexport function useOpinly(): Opinly {\n return getOpinlyPixel();\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAaI;AAZJ,oBAAmB;AACnB,mBAIO;AAKA,SAAS,YAAY,EAAE,UAAU,KAAK,GAAqB;AAChE,SACE;AAAA,IAAC,cAAAA;AAAA,IAAA;AAAA,MACC,IAAG;AAAA,MACH,KAAK,GAAG,KAAK,QAAQ,QAAQ,EAAE,CAAC;AAAA,MAChC,YAAU;AAAA,MACV,UAAS;AAAA;AAAA,EACX;AAEJ;AAEO,SAAS,YAAoB;AAClC,aAAO,6BAAe;AACxB;","names":["Script"]}
|
package/dist/pixel.d.cts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { OpinlyPixelConfig, Opinly } from '@opinly/shared/pixel';
|
|
3
|
+
export { Opinly } from '@opinly/shared/pixel';
|
|
4
|
+
|
|
5
|
+
type OpinlyPixelProps = OpinlyPixelConfig;
|
|
6
|
+
declare function OpinlyPixel({ writeKey, host }: OpinlyPixelProps): react_jsx_runtime.JSX.Element;
|
|
7
|
+
declare function useOpinly(): Opinly;
|
|
8
|
+
|
|
9
|
+
export { OpinlyPixel, type OpinlyPixelProps, useOpinly };
|
package/dist/pixel.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { OpinlyPixelConfig, Opinly } from '@opinly/shared/pixel';
|
|
3
|
+
export { Opinly } from '@opinly/shared/pixel';
|
|
4
|
+
|
|
5
|
+
type OpinlyPixelProps = OpinlyPixelConfig;
|
|
6
|
+
declare function OpinlyPixel({ writeKey, host }: OpinlyPixelProps): react_jsx_runtime.JSX.Element;
|
|
7
|
+
declare function useOpinly(): Opinly;
|
|
8
|
+
|
|
9
|
+
export { OpinlyPixel, type OpinlyPixelProps, useOpinly };
|
package/dist/pixel.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import Script from "next/script";
|
|
4
|
+
import {
|
|
5
|
+
getOpinlyPixel
|
|
6
|
+
} from "@opinly/shared/pixel";
|
|
7
|
+
function OpinlyPixel({ writeKey, host }) {
|
|
8
|
+
return /* @__PURE__ */ jsx(
|
|
9
|
+
Script,
|
|
10
|
+
{
|
|
11
|
+
id: "opinly-pixel",
|
|
12
|
+
src: `${host.replace(/\/+$/, "")}/p.js`,
|
|
13
|
+
"data-key": writeKey,
|
|
14
|
+
strategy: "afterInteractive"
|
|
15
|
+
}
|
|
16
|
+
);
|
|
17
|
+
}
|
|
18
|
+
function useOpinly() {
|
|
19
|
+
return getOpinlyPixel();
|
|
20
|
+
}
|
|
21
|
+
export {
|
|
22
|
+
OpinlyPixel,
|
|
23
|
+
useOpinly
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=pixel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/pixel.tsx"],"sourcesContent":["\"use client\";\nimport Script from \"next/script\";\nimport {\n getOpinlyPixel,\n type Opinly,\n type OpinlyPixelConfig,\n} from \"@opinly/shared/pixel\";\n\nexport type { Opinly } from \"@opinly/shared/pixel\";\nexport type OpinlyPixelProps = OpinlyPixelConfig;\n\nexport function OpinlyPixel({ writeKey, host }: OpinlyPixelProps) {\n return (\n <Script\n id=\"opinly-pixel\"\n src={`${host.replace(/\\/+$/, \"\")}/p.js`}\n data-key={writeKey}\n strategy=\"afterInteractive\"\n />\n );\n}\n\nexport function useOpinly(): Opinly {\n return getOpinlyPixel();\n}\n"],"mappings":";AAaI;AAZJ,OAAO,YAAY;AACnB;AAAA,EACE;AAAA,OAGK;AAKA,SAAS,YAAY,EAAE,UAAU,KAAK,GAAqB;AAChE,SACE;AAAA,IAAC;AAAA;AAAA,MACC,IAAG;AAAA,MACH,KAAK,GAAG,KAAK,QAAQ,QAAQ,EAAE,CAAC;AAAA,MAChC,YAAU;AAAA,MACV,UAAS;AAAA;AAAA,EACX;AAEJ;AAEO,SAAS,YAAoB;AAClC,SAAO,eAAe;AACxB;","names":[]}
|
|
@@ -31,7 +31,8 @@ const generateOpinlyMetadata = async (resolved, parent) => {
|
|
|
31
31
|
blogPrefix: import_sdk_config.opinlyConfig.blogPrefix,
|
|
32
32
|
siteName: import_sdk_config.opinlyConfig.siteName,
|
|
33
33
|
categoryPrefix: import_sdk_config.opinlyConfig.categoryPrefix,
|
|
34
|
-
authorPrefix: import_sdk_config.opinlyConfig.authorPrefix
|
|
34
|
+
authorPrefix: import_sdk_config.opinlyConfig.authorPrefix,
|
|
35
|
+
tagPrefix: import_sdk_config.opinlyConfig.tagPrefix
|
|
35
36
|
});
|
|
36
37
|
return {
|
|
37
38
|
...base,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/generate-metadata.ts"],"sourcesContent":["import type { Metadata, ResolvingMetadata } from \"next\";\nimport { buildMetadata, type SeoResolved } from \"@opinly/shared\";\nimport { opinlyConfig } from \"./sdk-config\";\n\n/**\n * Build Next.js metadata for a blog route from already-resolved content.\n *\n * The consumer resolves the route once (e.g. `opinly.lookup(slug)` /\n * `opinly.author(slug)`) — for both rendering and metadata — and passes the\n * result here as a `SeoResolved` (`{ type, data }`). Shared extraction lives in\n * @opinly/shared's `buildMetadata`; this only reshapes the neutral `OpinlyMeta`\n * into a Next `Metadata` object. Avoids a second fetch in `generateMetadata`.\n */\nexport const generateOpinlyMetadata = async (\n resolved: SeoResolved,\n parent: ResolvingMetadata,\n): Promise<Metadata> => {\n const base = (await parent) as Metadata;\n const meta = buildMetadata(resolved, {\n imagesPrefix: opinlyConfig.imagesPrefix,\n siteUrl: opinlyConfig.siteUrl,\n blogPrefix: opinlyConfig.blogPrefix,\n siteName: opinlyConfig.siteName,\n categoryPrefix: opinlyConfig.categoryPrefix,\n authorPrefix: opinlyConfig.authorPrefix,\n });\n\n return {\n ...base,\n title: meta.title,\n description: meta.description,\n openGraph: {\n title: meta.title,\n description: meta.description,\n type: meta.ogType ?? \"website\",\n images: meta.ogImage ? [meta.ogImage] : undefined,\n },\n ...(meta.authors ? { authors: meta.authors } : {}),\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,oBAAgD;AAChD,wBAA6B;AAWtB,MAAM,yBAAyB,OACpC,UACA,WACsB;AACtB,QAAM,OAAQ,MAAM;AACpB,QAAM,WAAO,6BAAc,UAAU;AAAA,IACnC,cAAc,+BAAa;AAAA,IAC3B,SAAS,+BAAa;AAAA,IACtB,YAAY,+BAAa;AAAA,IACzB,UAAU,+BAAa;AAAA,IACvB,gBAAgB,+BAAa;AAAA,IAC7B,cAAc,+BAAa;AAAA,
|
|
1
|
+
{"version":3,"sources":["../../src/utils/generate-metadata.ts"],"sourcesContent":["import type { Metadata, ResolvingMetadata } from \"next\";\nimport { buildMetadata, type SeoResolved } from \"@opinly/shared\";\nimport { opinlyConfig } from \"./sdk-config\";\n\n/**\n * Build Next.js metadata for a blog route from already-resolved content.\n *\n * The consumer resolves the route once (e.g. `opinly.lookup(slug)` /\n * `opinly.author(slug)`) — for both rendering and metadata — and passes the\n * result here as a `SeoResolved` (`{ type, data }`). Shared extraction lives in\n * @opinly/shared's `buildMetadata`; this only reshapes the neutral `OpinlyMeta`\n * into a Next `Metadata` object. Avoids a second fetch in `generateMetadata`.\n */\nexport const generateOpinlyMetadata = async (\n resolved: SeoResolved,\n parent: ResolvingMetadata,\n): Promise<Metadata> => {\n const base = (await parent) as Metadata;\n const meta = buildMetadata(resolved, {\n imagesPrefix: opinlyConfig.imagesPrefix,\n siteUrl: opinlyConfig.siteUrl,\n blogPrefix: opinlyConfig.blogPrefix,\n siteName: opinlyConfig.siteName,\n categoryPrefix: opinlyConfig.categoryPrefix,\n authorPrefix: opinlyConfig.authorPrefix,\n tagPrefix: opinlyConfig.tagPrefix,\n });\n\n return {\n ...base,\n title: meta.title,\n description: meta.description,\n openGraph: {\n title: meta.title,\n description: meta.description,\n type: meta.ogType ?? \"website\",\n images: meta.ogImage ? [meta.ogImage] : undefined,\n },\n ...(meta.authors ? { authors: meta.authors } : {}),\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,oBAAgD;AAChD,wBAA6B;AAWtB,MAAM,yBAAyB,OACpC,UACA,WACsB;AACtB,QAAM,OAAQ,MAAM;AACpB,QAAM,WAAO,6BAAc,UAAU;AAAA,IACnC,cAAc,+BAAa;AAAA,IAC3B,SAAS,+BAAa;AAAA,IACtB,YAAY,+BAAa;AAAA,IACzB,UAAU,+BAAa;AAAA,IACvB,gBAAgB,+BAAa;AAAA,IAC7B,cAAc,+BAAa;AAAA,IAC3B,WAAW,+BAAa;AAAA,EAC1B,CAAC;AAED,SAAO;AAAA,IACL,GAAG;AAAA,IACH,OAAO,KAAK;AAAA,IACZ,aAAa,KAAK;AAAA,IAClB,WAAW;AAAA,MACT,OAAO,KAAK;AAAA,MACZ,aAAa,KAAK;AAAA,MAClB,MAAM,KAAK,UAAU;AAAA,MACrB,QAAQ,KAAK,UAAU,CAAC,KAAK,OAAO,IAAI;AAAA,IAC1C;AAAA,IACA,GAAI,KAAK,UAAU,EAAE,SAAS,KAAK,QAAQ,IAAI,CAAC;AAAA,EAClD;AACF;","names":[]}
|
|
@@ -8,7 +8,8 @@ const generateOpinlyMetadata = async (resolved, parent) => {
|
|
|
8
8
|
blogPrefix: opinlyConfig.blogPrefix,
|
|
9
9
|
siteName: opinlyConfig.siteName,
|
|
10
10
|
categoryPrefix: opinlyConfig.categoryPrefix,
|
|
11
|
-
authorPrefix: opinlyConfig.authorPrefix
|
|
11
|
+
authorPrefix: opinlyConfig.authorPrefix,
|
|
12
|
+
tagPrefix: opinlyConfig.tagPrefix
|
|
12
13
|
});
|
|
13
14
|
return {
|
|
14
15
|
...base,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/generate-metadata.ts"],"sourcesContent":["import type { Metadata, ResolvingMetadata } from \"next\";\nimport { buildMetadata, type SeoResolved } from \"@opinly/shared\";\nimport { opinlyConfig } from \"./sdk-config\";\n\n/**\n * Build Next.js metadata for a blog route from already-resolved content.\n *\n * The consumer resolves the route once (e.g. `opinly.lookup(slug)` /\n * `opinly.author(slug)`) — for both rendering and metadata — and passes the\n * result here as a `SeoResolved` (`{ type, data }`). Shared extraction lives in\n * @opinly/shared's `buildMetadata`; this only reshapes the neutral `OpinlyMeta`\n * into a Next `Metadata` object. Avoids a second fetch in `generateMetadata`.\n */\nexport const generateOpinlyMetadata = async (\n resolved: SeoResolved,\n parent: ResolvingMetadata,\n): Promise<Metadata> => {\n const base = (await parent) as Metadata;\n const meta = buildMetadata(resolved, {\n imagesPrefix: opinlyConfig.imagesPrefix,\n siteUrl: opinlyConfig.siteUrl,\n blogPrefix: opinlyConfig.blogPrefix,\n siteName: opinlyConfig.siteName,\n categoryPrefix: opinlyConfig.categoryPrefix,\n authorPrefix: opinlyConfig.authorPrefix,\n });\n\n return {\n ...base,\n title: meta.title,\n description: meta.description,\n openGraph: {\n title: meta.title,\n description: meta.description,\n type: meta.ogType ?? \"website\",\n images: meta.ogImage ? [meta.ogImage] : undefined,\n },\n ...(meta.authors ? { authors: meta.authors } : {}),\n };\n};\n"],"mappings":"AACA,SAAS,qBAAuC;AAChD,SAAS,oBAAoB;AAWtB,MAAM,yBAAyB,OACpC,UACA,WACsB;AACtB,QAAM,OAAQ,MAAM;AACpB,QAAM,OAAO,cAAc,UAAU;AAAA,IACnC,cAAc,aAAa;AAAA,IAC3B,SAAS,aAAa;AAAA,IACtB,YAAY,aAAa;AAAA,IACzB,UAAU,aAAa;AAAA,IACvB,gBAAgB,aAAa;AAAA,IAC7B,cAAc,aAAa;AAAA,
|
|
1
|
+
{"version":3,"sources":["../../src/utils/generate-metadata.ts"],"sourcesContent":["import type { Metadata, ResolvingMetadata } from \"next\";\nimport { buildMetadata, type SeoResolved } from \"@opinly/shared\";\nimport { opinlyConfig } from \"./sdk-config\";\n\n/**\n * Build Next.js metadata for a blog route from already-resolved content.\n *\n * The consumer resolves the route once (e.g. `opinly.lookup(slug)` /\n * `opinly.author(slug)`) — for both rendering and metadata — and passes the\n * result here as a `SeoResolved` (`{ type, data }`). Shared extraction lives in\n * @opinly/shared's `buildMetadata`; this only reshapes the neutral `OpinlyMeta`\n * into a Next `Metadata` object. Avoids a second fetch in `generateMetadata`.\n */\nexport const generateOpinlyMetadata = async (\n resolved: SeoResolved,\n parent: ResolvingMetadata,\n): Promise<Metadata> => {\n const base = (await parent) as Metadata;\n const meta = buildMetadata(resolved, {\n imagesPrefix: opinlyConfig.imagesPrefix,\n siteUrl: opinlyConfig.siteUrl,\n blogPrefix: opinlyConfig.blogPrefix,\n siteName: opinlyConfig.siteName,\n categoryPrefix: opinlyConfig.categoryPrefix,\n authorPrefix: opinlyConfig.authorPrefix,\n tagPrefix: opinlyConfig.tagPrefix,\n });\n\n return {\n ...base,\n title: meta.title,\n description: meta.description,\n openGraph: {\n title: meta.title,\n description: meta.description,\n type: meta.ogType ?? \"website\",\n images: meta.ogImage ? [meta.ogImage] : undefined,\n },\n ...(meta.authors ? { authors: meta.authors } : {}),\n };\n};\n"],"mappings":"AACA,SAAS,qBAAuC;AAChD,SAAS,oBAAoB;AAWtB,MAAM,yBAAyB,OACpC,UACA,WACsB;AACtB,QAAM,OAAQ,MAAM;AACpB,QAAM,OAAO,cAAc,UAAU;AAAA,IACnC,cAAc,aAAa;AAAA,IAC3B,SAAS,aAAa;AAAA,IACtB,YAAY,aAAa;AAAA,IACzB,UAAU,aAAa;AAAA,IACvB,gBAAgB,aAAa;AAAA,IAC7B,cAAc,aAAa;AAAA,IAC3B,WAAW,aAAa;AAAA,EAC1B,CAAC;AAED,SAAO;AAAA,IACL,GAAG;AAAA,IACH,OAAO,KAAK;AAAA,IACZ,aAAa,KAAK;AAAA,IAClB,WAAW;AAAA,MACT,OAAO,KAAK;AAAA,MACZ,aAAa,KAAK;AAAA,MAClB,MAAM,KAAK,UAAU;AAAA,MACrB,QAAQ,KAAK,UAAU,CAAC,KAAK,OAAO,IAAI;AAAA,IAC1C;AAAA,IACA,GAAI,KAAK,UAAU,EAAE,SAAS,KAAK,QAAQ,IAAI,CAAC;AAAA,EAClD;AACF;","names":[]}
|
|
@@ -31,7 +31,8 @@ const opinlyEnvVars = {
|
|
|
31
31
|
OPINLY_UNOPTIMIZED_IMAGES: process.env.OPINLY_UNOPTIMIZED_IMAGES,
|
|
32
32
|
OPINLY_PAGES_ROUTER: process.env.OPINLY_PAGES_ROUTER,
|
|
33
33
|
OPINLY_CATEGORY_PREFIX: process.env.OPINLY_CATEGORY_PREFIX,
|
|
34
|
-
OPINLY_AUTHOR_PREFIX: process.env.OPINLY_AUTHOR_PREFIX
|
|
34
|
+
OPINLY_AUTHOR_PREFIX: process.env.OPINLY_AUTHOR_PREFIX,
|
|
35
|
+
OPINLY_TAG_PREFIX: process.env.OPINLY_TAG_PREFIX
|
|
35
36
|
};
|
|
36
37
|
let opinlyConfig = {
|
|
37
38
|
cdnUrl: process.env.OPINLY_CDN_URL || "https://cdn.opinly.ai",
|
|
@@ -44,7 +45,8 @@ let opinlyConfig = {
|
|
|
44
45
|
unoptimizedImages: process.env.OPINLY_UNOPTIMIZED_IMAGES === "true" ? true : void 0,
|
|
45
46
|
pagesRouter: process.env.OPINLY_PAGES_ROUTER === "true" ? true : false,
|
|
46
47
|
categoryPrefix: process.env.OPINLY_CATEGORY_PREFIX || void 0,
|
|
47
|
-
authorPrefix: process.env.OPINLY_AUTHOR_PREFIX || void 0
|
|
48
|
+
authorPrefix: process.env.OPINLY_AUTHOR_PREFIX || void 0,
|
|
49
|
+
tagPrefix: process.env.OPINLY_TAG_PREFIX || void 0
|
|
48
50
|
};
|
|
49
51
|
function setOpinlyConfig(newConfig) {
|
|
50
52
|
opinlyConfig = { ...opinlyConfig, ...newConfig };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/sdk-config.ts"],"sourcesContent":["const siteUrl = process.env.OPINLY_SITE_URL;\n\nconst opinlyEnvVars = {\n OPINLY_IMAGES_PREFIX: process.env.OPINLY_IMAGES_PREFIX as string,\n OPINLY_SITE_URL: process.env.OPINLY_SITE_URL as string,\n OPINLY_BLOG_PREFIX: process.env.OPINLY_BLOG_PREFIX as string,\n OPINLY_SITE_NAME: process.env.OPINLY_SITE_NAME as string,\n OPINLY_UNOPTIMIZED_IMAGES: process.env.OPINLY_UNOPTIMIZED_IMAGES as\n | string\n | undefined,\n OPINLY_PAGES_ROUTER: process.env.OPINLY_PAGES_ROUTER,\n OPINLY_CATEGORY_PREFIX: process.env.OPINLY_CATEGORY_PREFIX as\n | string\n | undefined,\n OPINLY_AUTHOR_PREFIX: process.env.OPINLY_AUTHOR_PREFIX as string | undefined,\n};\n\nexport type OpinlyEnvVars = typeof opinlyEnvVars;\n\nexport let opinlyConfig: {\n cdnUrl: string;\n imagesPrefix: string;\n imagesUrl: string;\n siteUrl: string;\n blogPrefix: string;\n blogUrl: string;\n siteName: string;\n unoptimizedImages?: boolean;\n pagesRouter: boolean;\n categoryPrefix?: string;\n authorPrefix?: string;\n} = {\n cdnUrl: process.env.OPINLY_CDN_URL || \"https://cdn.opinly.ai\",\n siteUrl: process.env.OPINLY_SITE_URL as string,\n imagesPrefix: process.env.OPINLY_IMAGES_PREFIX as string,\n imagesUrl: process.env.OPINLY_IMAGES_PREFIX?.startsWith(\"/\")\n ? `${process.env.OPINLY_SITE_URL as string}${\n process.env.OPINLY_IMAGES_PREFIX as string\n }`\n : (process.env.OPINLY_IMAGES_PREFIX as string),\n blogPrefix: process.env.OPINLY_BLOG_PREFIX as string,\n blogUrl: `${process.env.OPINLY_SITE_URL as string}${\n process.env.OPINLY_BLOG_PREFIX as string\n }`,\n siteName: process.env.OPINLY_SITE_NAME as string,\n unoptimizedImages:\n process.env.OPINLY_UNOPTIMIZED_IMAGES === \"true\" ? true : undefined,\n pagesRouter: process.env.OPINLY_PAGES_ROUTER === \"true\" ? true : false,\n categoryPrefix: process.env.OPINLY_CATEGORY_PREFIX || undefined,\n authorPrefix: process.env.OPINLY_AUTHOR_PREFIX || undefined,\n};\n\nexport function setOpinlyConfig(newConfig: typeof opinlyConfig) {\n opinlyConfig = { ...opinlyConfig, ...newConfig };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAAM,UAAU,QAAQ,IAAI;AAE5B,MAAM,gBAAgB;AAAA,EACpB,sBAAsB,QAAQ,IAAI;AAAA,EAClC,iBAAiB,QAAQ,IAAI;AAAA,EAC7B,oBAAoB,QAAQ,IAAI;AAAA,EAChC,kBAAkB,QAAQ,IAAI;AAAA,EAC9B,2BAA2B,QAAQ,IAAI;AAAA,EAGvC,qBAAqB,QAAQ,IAAI;AAAA,EACjC,wBAAwB,QAAQ,IAAI;AAAA,EAGpC,sBAAsB,QAAQ,IAAI;
|
|
1
|
+
{"version":3,"sources":["../../src/utils/sdk-config.ts"],"sourcesContent":["const siteUrl = process.env.OPINLY_SITE_URL;\n\nconst opinlyEnvVars = {\n OPINLY_IMAGES_PREFIX: process.env.OPINLY_IMAGES_PREFIX as string,\n OPINLY_SITE_URL: process.env.OPINLY_SITE_URL as string,\n OPINLY_BLOG_PREFIX: process.env.OPINLY_BLOG_PREFIX as string,\n OPINLY_SITE_NAME: process.env.OPINLY_SITE_NAME as string,\n OPINLY_UNOPTIMIZED_IMAGES: process.env.OPINLY_UNOPTIMIZED_IMAGES as\n | string\n | undefined,\n OPINLY_PAGES_ROUTER: process.env.OPINLY_PAGES_ROUTER,\n OPINLY_CATEGORY_PREFIX: process.env.OPINLY_CATEGORY_PREFIX as\n | string\n | undefined,\n OPINLY_AUTHOR_PREFIX: process.env.OPINLY_AUTHOR_PREFIX as string | undefined,\n OPINLY_TAG_PREFIX: process.env.OPINLY_TAG_PREFIX as string | undefined,\n};\n\nexport type OpinlyEnvVars = typeof opinlyEnvVars;\n\nexport let opinlyConfig: {\n cdnUrl: string;\n imagesPrefix: string;\n imagesUrl: string;\n siteUrl: string;\n blogPrefix: string;\n blogUrl: string;\n siteName: string;\n unoptimizedImages?: boolean;\n pagesRouter: boolean;\n categoryPrefix?: string;\n authorPrefix?: string;\n tagPrefix?: string;\n} = {\n cdnUrl: process.env.OPINLY_CDN_URL || \"https://cdn.opinly.ai\",\n siteUrl: process.env.OPINLY_SITE_URL as string,\n imagesPrefix: process.env.OPINLY_IMAGES_PREFIX as string,\n imagesUrl: process.env.OPINLY_IMAGES_PREFIX?.startsWith(\"/\")\n ? `${process.env.OPINLY_SITE_URL as string}${\n process.env.OPINLY_IMAGES_PREFIX as string\n }`\n : (process.env.OPINLY_IMAGES_PREFIX as string),\n blogPrefix: process.env.OPINLY_BLOG_PREFIX as string,\n blogUrl: `${process.env.OPINLY_SITE_URL as string}${\n process.env.OPINLY_BLOG_PREFIX as string\n }`,\n siteName: process.env.OPINLY_SITE_NAME as string,\n unoptimizedImages:\n process.env.OPINLY_UNOPTIMIZED_IMAGES === \"true\" ? true : undefined,\n pagesRouter: process.env.OPINLY_PAGES_ROUTER === \"true\" ? true : false,\n categoryPrefix: process.env.OPINLY_CATEGORY_PREFIX || undefined,\n authorPrefix: process.env.OPINLY_AUTHOR_PREFIX || undefined,\n tagPrefix: process.env.OPINLY_TAG_PREFIX || undefined,\n};\n\nexport function setOpinlyConfig(newConfig: typeof opinlyConfig) {\n opinlyConfig = { ...opinlyConfig, ...newConfig };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAAM,UAAU,QAAQ,IAAI;AAE5B,MAAM,gBAAgB;AAAA,EACpB,sBAAsB,QAAQ,IAAI;AAAA,EAClC,iBAAiB,QAAQ,IAAI;AAAA,EAC7B,oBAAoB,QAAQ,IAAI;AAAA,EAChC,kBAAkB,QAAQ,IAAI;AAAA,EAC9B,2BAA2B,QAAQ,IAAI;AAAA,EAGvC,qBAAqB,QAAQ,IAAI;AAAA,EACjC,wBAAwB,QAAQ,IAAI;AAAA,EAGpC,sBAAsB,QAAQ,IAAI;AAAA,EAClC,mBAAmB,QAAQ,IAAI;AACjC;AAIO,IAAI,eAaP;AAAA,EACF,QAAQ,QAAQ,IAAI,kBAAkB;AAAA,EACtC,SAAS,QAAQ,IAAI;AAAA,EACrB,cAAc,QAAQ,IAAI;AAAA,EAC1B,WAAW,QAAQ,IAAI,sBAAsB,WAAW,GAAG,IACvD,GAAG,QAAQ,IAAI,eAAyB,GACtC,QAAQ,IAAI,oBACd,KACC,QAAQ,IAAI;AAAA,EACjB,YAAY,QAAQ,IAAI;AAAA,EACxB,SAAS,GAAG,QAAQ,IAAI,eAAyB,GAC/C,QAAQ,IAAI,kBACd;AAAA,EACA,UAAU,QAAQ,IAAI;AAAA,EACtB,mBACE,QAAQ,IAAI,8BAA8B,SAAS,OAAO;AAAA,EAC5D,aAAa,QAAQ,IAAI,wBAAwB,SAAS,OAAO;AAAA,EACjE,gBAAgB,QAAQ,IAAI,0BAA0B;AAAA,EACtD,cAAc,QAAQ,IAAI,wBAAwB;AAAA,EAClD,WAAW,QAAQ,IAAI,qBAAqB;AAC9C;AAEO,SAAS,gBAAgB,WAAgC;AAC9D,iBAAe,EAAE,GAAG,cAAc,GAAG,UAAU;AACjD;","names":[]}
|
|
@@ -7,6 +7,7 @@ declare const opinlyEnvVars: {
|
|
|
7
7
|
OPINLY_PAGES_ROUTER: string | undefined;
|
|
8
8
|
OPINLY_CATEGORY_PREFIX: string | undefined;
|
|
9
9
|
OPINLY_AUTHOR_PREFIX: string | undefined;
|
|
10
|
+
OPINLY_TAG_PREFIX: string | undefined;
|
|
10
11
|
};
|
|
11
12
|
type OpinlyEnvVars = typeof opinlyEnvVars;
|
|
12
13
|
declare let opinlyConfig: {
|
|
@@ -21,6 +22,7 @@ declare let opinlyConfig: {
|
|
|
21
22
|
pagesRouter: boolean;
|
|
22
23
|
categoryPrefix?: string;
|
|
23
24
|
authorPrefix?: string;
|
|
25
|
+
tagPrefix?: string;
|
|
24
26
|
};
|
|
25
27
|
declare function setOpinlyConfig(newConfig: typeof opinlyConfig): void;
|
|
26
28
|
|
|
@@ -7,6 +7,7 @@ declare const opinlyEnvVars: {
|
|
|
7
7
|
OPINLY_PAGES_ROUTER: string | undefined;
|
|
8
8
|
OPINLY_CATEGORY_PREFIX: string | undefined;
|
|
9
9
|
OPINLY_AUTHOR_PREFIX: string | undefined;
|
|
10
|
+
OPINLY_TAG_PREFIX: string | undefined;
|
|
10
11
|
};
|
|
11
12
|
type OpinlyEnvVars = typeof opinlyEnvVars;
|
|
12
13
|
declare let opinlyConfig: {
|
|
@@ -21,6 +22,7 @@ declare let opinlyConfig: {
|
|
|
21
22
|
pagesRouter: boolean;
|
|
22
23
|
categoryPrefix?: string;
|
|
23
24
|
authorPrefix?: string;
|
|
25
|
+
tagPrefix?: string;
|
|
24
26
|
};
|
|
25
27
|
declare function setOpinlyConfig(newConfig: typeof opinlyConfig): void;
|
|
26
28
|
|
package/dist/utils/sdk-config.js
CHANGED
|
@@ -7,7 +7,8 @@ const opinlyEnvVars = {
|
|
|
7
7
|
OPINLY_UNOPTIMIZED_IMAGES: process.env.OPINLY_UNOPTIMIZED_IMAGES,
|
|
8
8
|
OPINLY_PAGES_ROUTER: process.env.OPINLY_PAGES_ROUTER,
|
|
9
9
|
OPINLY_CATEGORY_PREFIX: process.env.OPINLY_CATEGORY_PREFIX,
|
|
10
|
-
OPINLY_AUTHOR_PREFIX: process.env.OPINLY_AUTHOR_PREFIX
|
|
10
|
+
OPINLY_AUTHOR_PREFIX: process.env.OPINLY_AUTHOR_PREFIX,
|
|
11
|
+
OPINLY_TAG_PREFIX: process.env.OPINLY_TAG_PREFIX
|
|
11
12
|
};
|
|
12
13
|
let opinlyConfig = {
|
|
13
14
|
cdnUrl: process.env.OPINLY_CDN_URL || "https://cdn.opinly.ai",
|
|
@@ -20,7 +21,8 @@ let opinlyConfig = {
|
|
|
20
21
|
unoptimizedImages: process.env.OPINLY_UNOPTIMIZED_IMAGES === "true" ? true : void 0,
|
|
21
22
|
pagesRouter: process.env.OPINLY_PAGES_ROUTER === "true" ? true : false,
|
|
22
23
|
categoryPrefix: process.env.OPINLY_CATEGORY_PREFIX || void 0,
|
|
23
|
-
authorPrefix: process.env.OPINLY_AUTHOR_PREFIX || void 0
|
|
24
|
+
authorPrefix: process.env.OPINLY_AUTHOR_PREFIX || void 0,
|
|
25
|
+
tagPrefix: process.env.OPINLY_TAG_PREFIX || void 0
|
|
24
26
|
};
|
|
25
27
|
function setOpinlyConfig(newConfig) {
|
|
26
28
|
opinlyConfig = { ...opinlyConfig, ...newConfig };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/sdk-config.ts"],"sourcesContent":["const siteUrl = process.env.OPINLY_SITE_URL;\n\nconst opinlyEnvVars = {\n OPINLY_IMAGES_PREFIX: process.env.OPINLY_IMAGES_PREFIX as string,\n OPINLY_SITE_URL: process.env.OPINLY_SITE_URL as string,\n OPINLY_BLOG_PREFIX: process.env.OPINLY_BLOG_PREFIX as string,\n OPINLY_SITE_NAME: process.env.OPINLY_SITE_NAME as string,\n OPINLY_UNOPTIMIZED_IMAGES: process.env.OPINLY_UNOPTIMIZED_IMAGES as\n | string\n | undefined,\n OPINLY_PAGES_ROUTER: process.env.OPINLY_PAGES_ROUTER,\n OPINLY_CATEGORY_PREFIX: process.env.OPINLY_CATEGORY_PREFIX as\n | string\n | undefined,\n OPINLY_AUTHOR_PREFIX: process.env.OPINLY_AUTHOR_PREFIX as string | undefined,\n};\n\nexport type OpinlyEnvVars = typeof opinlyEnvVars;\n\nexport let opinlyConfig: {\n cdnUrl: string;\n imagesPrefix: string;\n imagesUrl: string;\n siteUrl: string;\n blogPrefix: string;\n blogUrl: string;\n siteName: string;\n unoptimizedImages?: boolean;\n pagesRouter: boolean;\n categoryPrefix?: string;\n authorPrefix?: string;\n} = {\n cdnUrl: process.env.OPINLY_CDN_URL || \"https://cdn.opinly.ai\",\n siteUrl: process.env.OPINLY_SITE_URL as string,\n imagesPrefix: process.env.OPINLY_IMAGES_PREFIX as string,\n imagesUrl: process.env.OPINLY_IMAGES_PREFIX?.startsWith(\"/\")\n ? `${process.env.OPINLY_SITE_URL as string}${\n process.env.OPINLY_IMAGES_PREFIX as string\n }`\n : (process.env.OPINLY_IMAGES_PREFIX as string),\n blogPrefix: process.env.OPINLY_BLOG_PREFIX as string,\n blogUrl: `${process.env.OPINLY_SITE_URL as string}${\n process.env.OPINLY_BLOG_PREFIX as string\n }`,\n siteName: process.env.OPINLY_SITE_NAME as string,\n unoptimizedImages:\n process.env.OPINLY_UNOPTIMIZED_IMAGES === \"true\" ? true : undefined,\n pagesRouter: process.env.OPINLY_PAGES_ROUTER === \"true\" ? true : false,\n categoryPrefix: process.env.OPINLY_CATEGORY_PREFIX || undefined,\n authorPrefix: process.env.OPINLY_AUTHOR_PREFIX || undefined,\n};\n\nexport function setOpinlyConfig(newConfig: typeof opinlyConfig) {\n opinlyConfig = { ...opinlyConfig, ...newConfig };\n}\n"],"mappings":"AAAA,MAAM,UAAU,QAAQ,IAAI;AAE5B,MAAM,gBAAgB;AAAA,EACpB,sBAAsB,QAAQ,IAAI;AAAA,EAClC,iBAAiB,QAAQ,IAAI;AAAA,EAC7B,oBAAoB,QAAQ,IAAI;AAAA,EAChC,kBAAkB,QAAQ,IAAI;AAAA,EAC9B,2BAA2B,QAAQ,IAAI;AAAA,EAGvC,qBAAqB,QAAQ,IAAI;AAAA,EACjC,wBAAwB,QAAQ,IAAI;AAAA,EAGpC,sBAAsB,QAAQ,IAAI;
|
|
1
|
+
{"version":3,"sources":["../../src/utils/sdk-config.ts"],"sourcesContent":["const siteUrl = process.env.OPINLY_SITE_URL;\n\nconst opinlyEnvVars = {\n OPINLY_IMAGES_PREFIX: process.env.OPINLY_IMAGES_PREFIX as string,\n OPINLY_SITE_URL: process.env.OPINLY_SITE_URL as string,\n OPINLY_BLOG_PREFIX: process.env.OPINLY_BLOG_PREFIX as string,\n OPINLY_SITE_NAME: process.env.OPINLY_SITE_NAME as string,\n OPINLY_UNOPTIMIZED_IMAGES: process.env.OPINLY_UNOPTIMIZED_IMAGES as\n | string\n | undefined,\n OPINLY_PAGES_ROUTER: process.env.OPINLY_PAGES_ROUTER,\n OPINLY_CATEGORY_PREFIX: process.env.OPINLY_CATEGORY_PREFIX as\n | string\n | undefined,\n OPINLY_AUTHOR_PREFIX: process.env.OPINLY_AUTHOR_PREFIX as string | undefined,\n OPINLY_TAG_PREFIX: process.env.OPINLY_TAG_PREFIX as string | undefined,\n};\n\nexport type OpinlyEnvVars = typeof opinlyEnvVars;\n\nexport let opinlyConfig: {\n cdnUrl: string;\n imagesPrefix: string;\n imagesUrl: string;\n siteUrl: string;\n blogPrefix: string;\n blogUrl: string;\n siteName: string;\n unoptimizedImages?: boolean;\n pagesRouter: boolean;\n categoryPrefix?: string;\n authorPrefix?: string;\n tagPrefix?: string;\n} = {\n cdnUrl: process.env.OPINLY_CDN_URL || \"https://cdn.opinly.ai\",\n siteUrl: process.env.OPINLY_SITE_URL as string,\n imagesPrefix: process.env.OPINLY_IMAGES_PREFIX as string,\n imagesUrl: process.env.OPINLY_IMAGES_PREFIX?.startsWith(\"/\")\n ? `${process.env.OPINLY_SITE_URL as string}${\n process.env.OPINLY_IMAGES_PREFIX as string\n }`\n : (process.env.OPINLY_IMAGES_PREFIX as string),\n blogPrefix: process.env.OPINLY_BLOG_PREFIX as string,\n blogUrl: `${process.env.OPINLY_SITE_URL as string}${\n process.env.OPINLY_BLOG_PREFIX as string\n }`,\n siteName: process.env.OPINLY_SITE_NAME as string,\n unoptimizedImages:\n process.env.OPINLY_UNOPTIMIZED_IMAGES === \"true\" ? true : undefined,\n pagesRouter: process.env.OPINLY_PAGES_ROUTER === \"true\" ? true : false,\n categoryPrefix: process.env.OPINLY_CATEGORY_PREFIX || undefined,\n authorPrefix: process.env.OPINLY_AUTHOR_PREFIX || undefined,\n tagPrefix: process.env.OPINLY_TAG_PREFIX || undefined,\n};\n\nexport function setOpinlyConfig(newConfig: typeof opinlyConfig) {\n opinlyConfig = { ...opinlyConfig, ...newConfig };\n}\n"],"mappings":"AAAA,MAAM,UAAU,QAAQ,IAAI;AAE5B,MAAM,gBAAgB;AAAA,EACpB,sBAAsB,QAAQ,IAAI;AAAA,EAClC,iBAAiB,QAAQ,IAAI;AAAA,EAC7B,oBAAoB,QAAQ,IAAI;AAAA,EAChC,kBAAkB,QAAQ,IAAI;AAAA,EAC9B,2BAA2B,QAAQ,IAAI;AAAA,EAGvC,qBAAqB,QAAQ,IAAI;AAAA,EACjC,wBAAwB,QAAQ,IAAI;AAAA,EAGpC,sBAAsB,QAAQ,IAAI;AAAA,EAClC,mBAAmB,QAAQ,IAAI;AACjC;AAIO,IAAI,eAaP;AAAA,EACF,QAAQ,QAAQ,IAAI,kBAAkB;AAAA,EACtC,SAAS,QAAQ,IAAI;AAAA,EACrB,cAAc,QAAQ,IAAI;AAAA,EAC1B,WAAW,QAAQ,IAAI,sBAAsB,WAAW,GAAG,IACvD,GAAG,QAAQ,IAAI,eAAyB,GACtC,QAAQ,IAAI,oBACd,KACC,QAAQ,IAAI;AAAA,EACjB,YAAY,QAAQ,IAAI;AAAA,EACxB,SAAS,GAAG,QAAQ,IAAI,eAAyB,GAC/C,QAAQ,IAAI,kBACd;AAAA,EACA,UAAU,QAAQ,IAAI;AAAA,EACtB,mBACE,QAAQ,IAAI,8BAA8B,SAAS,OAAO;AAAA,EAC5D,aAAa,QAAQ,IAAI,wBAAwB,SAAS,OAAO;AAAA,EACjE,gBAAgB,QAAQ,IAAI,0BAA0B;AAAA,EACtD,cAAc,QAAQ,IAAI,wBAAwB;AAAA,EAClD,WAAW,QAAQ,IAAI,qBAAqB;AAC9C;AAEO,SAAS,gBAAgB,WAAgC;AAC9D,iBAAe,EAAE,GAAG,cAAc,GAAG,UAAU;AACjD;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opinly/next",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"private": false,
|
|
6
6
|
"main": "dist/index.cjs",
|
|
@@ -27,8 +27,8 @@
|
|
|
27
27
|
"schema-dts": "^1.1.5",
|
|
28
28
|
"tailwind-merge": "^1.14.0",
|
|
29
29
|
"zod": "^3.25.67",
|
|
30
|
-
"@opinly/
|
|
31
|
-
"@opinly/
|
|
30
|
+
"@opinly/backend": "1.3.0",
|
|
31
|
+
"@opinly/shared": "1.3.0"
|
|
32
32
|
},
|
|
33
33
|
"engines": {
|
|
34
34
|
"node": ">=16"
|
|
@@ -45,6 +45,11 @@
|
|
|
45
45
|
"import": "./dist/index.js",
|
|
46
46
|
"require": "./dist/index.cjs"
|
|
47
47
|
},
|
|
48
|
+
"./pixel": {
|
|
49
|
+
"types": "./dist/pixel.d.ts",
|
|
50
|
+
"import": "./dist/pixel.js",
|
|
51
|
+
"require": "./dist/pixel.cjs"
|
|
52
|
+
},
|
|
48
53
|
"./config": {
|
|
49
54
|
"import": "./dist/config.js",
|
|
50
55
|
"require": "./dist/config.cjs"
|