@opinly/next 0.1.2 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +24 -29
- package/dist/index.d.cts +17 -0
- package/dist/index.js +21 -26
- package/package.json +8 -2
- package/.turbo/turbo-lint.log +0 -14
- package/CHANGELOG.md +0 -21
- package/src/components/author-page/_helpers/json-ld.ts +0 -0
- package/src/components/author-page/index.tsx +0 -62
- package/src/components/authors-page/index.tsx +0 -90
- package/src/components/blog-post/_components/content.tsx +0 -141
- package/src/components/blog-post/_components/faq.tsx +0 -18
- package/src/components/blog-post/_components/share.tsx +0 -48
- package/src/components/blog-post/_components/table-of-contents.tsx +0 -63
- package/src/components/blog-post/_helpers/calc-reading-time.ts +0 -0
- package/src/components/blog-post/_helpers/extract-headings.ts +0 -25
- package/src/components/blog-post/_helpers/json-ld.ts +0 -176
- package/src/components/blog-post/_helpers/reading-time.ts +0 -28
- package/src/components/blog-post/_types/blog-post.ts +0 -6
- package/src/components/blog-post/_types/class-names.ts +0 -10
- package/src/components/blog-post/index.tsx +0 -126
- package/src/components/bread-crumbs.tsx +0 -48
- package/src/components/folder-page/index.tsx +0 -50
- package/src/components/home-page.tsx +0 -65
- package/src/components/not-found.tsx +0 -36
- package/src/components/opinly-blog.tsx +0 -37
- package/src/components/post-preview.tsx +0 -73
- package/src/index.ts +0 -2
- package/src/sdk-config.ts +0 -37
- package/src/utils/dates.ts +0 -6
- package/src/utils/generate-metadata.ts +0 -54
- package/src/utils/images.ts +0 -7
- package/src/utils/merge.ts +0 -6
- package/sst-env.d.ts +0 -9
- package/tsconfig.json +0 -19
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import Link from "next/link";
|
|
2
|
-
|
|
3
|
-
export const OpinlyNotFound = () => {
|
|
4
|
-
return (
|
|
5
|
-
<>
|
|
6
|
-
<div className="bg-orange-600 py-10">
|
|
7
|
-
<div className="max-w-7xl mx-auto px-4">
|
|
8
|
-
<h1 className="text-4xl font-bold mb-2 leading-tight text-white">
|
|
9
|
-
Post Not Found
|
|
10
|
-
</h1>
|
|
11
|
-
<div className="text-sm mb-4 text-orange-100">
|
|
12
|
-
The post you're looking for doesn't exist or has been removed.
|
|
13
|
-
</div>
|
|
14
|
-
</div>
|
|
15
|
-
</div>
|
|
16
|
-
|
|
17
|
-
<div className="flex max-w-7xl mx-auto mt-10 gap-12">
|
|
18
|
-
<article className="w-2/3">
|
|
19
|
-
<div className="prose max-w-none">
|
|
20
|
-
<p className="text-gray-600">You can try:</p>
|
|
21
|
-
<ul className="list-disc pl-6 my-4">
|
|
22
|
-
<li>Checking the URL for typos</li>
|
|
23
|
-
<li>
|
|
24
|
-
Returning to the{" "}
|
|
25
|
-
<Link href="/blog" className="text-blue-600 underline">
|
|
26
|
-
blog homepage
|
|
27
|
-
</Link>
|
|
28
|
-
</li>
|
|
29
|
-
<li>Using the search function to find what you're looking for</li>
|
|
30
|
-
</ul>
|
|
31
|
-
</div>
|
|
32
|
-
</article>
|
|
33
|
-
</div>
|
|
34
|
-
</>
|
|
35
|
-
);
|
|
36
|
-
};
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { BlogPost } from "./blog-post";
|
|
2
|
-
import { FolderPage } from "./folder-page";
|
|
3
|
-
import { Opinly } from "@opinly/backend";
|
|
4
|
-
import { HomePage } from "./home-page";
|
|
5
|
-
import { AuthorPage } from "./author-page";
|
|
6
|
-
import { OpinlyNotFound } from "./not-found";
|
|
7
|
-
import { AuthorsPage } from "./authors-page";
|
|
8
|
-
|
|
9
|
-
export const OpinlyBlog = ({
|
|
10
|
-
blog,
|
|
11
|
-
page,
|
|
12
|
-
}: {
|
|
13
|
-
blog: Awaited<ReturnType<Opinly["content"]["blog"]>>;
|
|
14
|
-
page: number | null | undefined;
|
|
15
|
-
}) => {
|
|
16
|
-
if (blog.type === "not-found") {
|
|
17
|
-
return <OpinlyNotFound />;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
if (blog.type === "home") {
|
|
21
|
-
return <HomePage homePage={blog.data} page={page} />;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
if (blog.type === "post") {
|
|
25
|
-
return <BlogPost post={blog.data} />;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
if (blog.type === "author") {
|
|
29
|
-
return <AuthorPage author={blog.data} />;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
if (blog.type === "authors") {
|
|
33
|
-
return <AuthorsPage authors={blog.data} />;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
return <FolderPage folder={blog.data} />;
|
|
37
|
-
};
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import { Opinly } from "@opinly/backend";
|
|
2
|
-
import Link from "next/link";
|
|
3
|
-
import Image from "next/image";
|
|
4
|
-
import { opinlyConfig } from "../sdk-config";
|
|
5
|
-
import { replaceImageNameSpace } from "../utils/images";
|
|
6
|
-
import { formatDate } from "../utils/dates";
|
|
7
|
-
|
|
8
|
-
export const PostPreview = ({
|
|
9
|
-
post,
|
|
10
|
-
}: {
|
|
11
|
-
post: Extract<
|
|
12
|
-
Awaited<ReturnType<Opinly["content"]["blog"]>>,
|
|
13
|
-
{ type: "home" }
|
|
14
|
-
>["data"]["posts"][number];
|
|
15
|
-
}) => {
|
|
16
|
-
const postSlug = `${opinlyConfig.blogPrefix}/${post.folder?.slug ? `${post.folder.slug}/` : ""}${post.slug}`;
|
|
17
|
-
|
|
18
|
-
return (
|
|
19
|
-
<div>
|
|
20
|
-
{post.image?.fileKey && (
|
|
21
|
-
<Link key={post.slug} href={postSlug} className="group">
|
|
22
|
-
<div className="relative w-full h-48 mb-4">
|
|
23
|
-
<Image
|
|
24
|
-
src={`${opinlyConfig.imagesPrefix}/${replaceImageNameSpace(post.image.fileKey)}`}
|
|
25
|
-
alt={post.title}
|
|
26
|
-
fill
|
|
27
|
-
className="object-cover rounded-lg"
|
|
28
|
-
/>
|
|
29
|
-
</div>
|
|
30
|
-
</Link>
|
|
31
|
-
)}
|
|
32
|
-
<div className="text-sm text-muted-foreground mb-1">
|
|
33
|
-
{post.folder?.name && (
|
|
34
|
-
<>
|
|
35
|
-
<Link
|
|
36
|
-
href={`${opinlyConfig.blogPrefix}/${post.folder.slug}`}
|
|
37
|
-
className="hover:underline"
|
|
38
|
-
>
|
|
39
|
-
{post.folder.name}
|
|
40
|
-
</Link>
|
|
41
|
-
<span className="mx-1">·</span>
|
|
42
|
-
</>
|
|
43
|
-
)}{" "}
|
|
44
|
-
{formatDate(post.firstPublishedAt as string)}
|
|
45
|
-
</div>
|
|
46
|
-
<Link key={post.slug} href={postSlug} className="group">
|
|
47
|
-
<h2 className="text-lg font-semibold leading-snug group-hover:underline">
|
|
48
|
-
{post.title}
|
|
49
|
-
</h2>
|
|
50
|
-
</Link>
|
|
51
|
-
|
|
52
|
-
{post.description && (
|
|
53
|
-
<p className="text-sm text-gray-600 mt-1 line-clamp-2">
|
|
54
|
-
{post.description}
|
|
55
|
-
</p>
|
|
56
|
-
)}
|
|
57
|
-
<div className="text-xs text-gray-500 mt-2">
|
|
58
|
-
{post.author && (
|
|
59
|
-
<>
|
|
60
|
-
<Link
|
|
61
|
-
href={`${opinlyConfig.blogPrefix}/authors/${post.author.slug}`}
|
|
62
|
-
className="font-medium hover:underline"
|
|
63
|
-
>
|
|
64
|
-
{post.author?.name}
|
|
65
|
-
</Link>{" "}
|
|
66
|
-
<span className="mx-1">·</span>
|
|
67
|
-
</>
|
|
68
|
-
)}{" "}
|
|
69
|
-
{formatDate(post.firstPublishedAt as string)}
|
|
70
|
-
</div>
|
|
71
|
-
</div>
|
|
72
|
-
);
|
|
73
|
-
};
|
package/src/index.ts
DELETED
package/src/sdk-config.ts
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
const siteUrl = process.env.OPINLY_SITE_URL;
|
|
2
|
-
|
|
3
|
-
const opinlyEnvVars = {
|
|
4
|
-
OPINLY_IMAGES_PREFIX: process.env.OPINLY_IMAGES_PREFIX as string,
|
|
5
|
-
OPINLY_SITE_URL: process.env.OPINLY_SITE_URL as string,
|
|
6
|
-
OPINLY_BLOG_PREFIX: process.env.OPINLY_BLOG_PREFIX as string,
|
|
7
|
-
OPINLY_CDN_URL: process.env.OPINLY_CDN_URL as string,
|
|
8
|
-
OPINLY_SITE_NAME: process.env.OPINLY_SITE_NAME as string,
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
Object.entries(opinlyEnvVars).forEach(([key, value]) => {
|
|
12
|
-
if (!value) {
|
|
13
|
-
throw new Error(`OPINLY ERROR: env var ${key} is not set`);
|
|
14
|
-
}
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
export let opinlyConfig: {
|
|
18
|
-
cdnUrl: string;
|
|
19
|
-
imagesPrefix: string;
|
|
20
|
-
imagesUrl: string;
|
|
21
|
-
siteUrl: string;
|
|
22
|
-
blogPrefix: string;
|
|
23
|
-
blogUrl: string;
|
|
24
|
-
siteName: string;
|
|
25
|
-
} = {
|
|
26
|
-
cdnUrl: process.env.OPINLY_CDN_URL || "https://cdn.opinly.ai",
|
|
27
|
-
siteUrl: process.env.OPINLY_SITE_URL as string,
|
|
28
|
-
imagesPrefix: process.env.OPINLY_IMAGES_PREFIX as string,
|
|
29
|
-
imagesUrl: `${process.env.OPINLY_SITE_URL as string}${process.env.OPINLY_IMAGES_PREFIX as string}`,
|
|
30
|
-
blogPrefix: process.env.OPINLY_BLOG_PREFIX as string,
|
|
31
|
-
blogUrl: `${process.env.OPINLY_SITE_URL as string}${process.env.OPINLY_BLOG_PREFIX as string}`,
|
|
32
|
-
siteName: process.env.OPINLY_SITE_NAME as string,
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
export function setOpinlyConfig(newConfig: typeof opinlyConfig) {
|
|
36
|
-
opinlyConfig = { ...opinlyConfig, ...newConfig };
|
|
37
|
-
}
|
package/src/utils/dates.ts
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { Opinly, OpinlyApiOutput, OpinlyPageProps } from "@opinly/backend";
|
|
2
|
-
import type { Metadata, ResolvingMetadata } from "next";
|
|
3
|
-
import { opinlyConfig } from "../sdk-config";
|
|
4
|
-
|
|
5
|
-
type BlogPost = Extract<
|
|
6
|
-
OpinlyApiOutput["content"]["postOrFolder"],
|
|
7
|
-
{ type: "post" }
|
|
8
|
-
>["data"];
|
|
9
|
-
|
|
10
|
-
export const generateMetadata = async (
|
|
11
|
-
client: Opinly,
|
|
12
|
-
params: OpinlyPageProps,
|
|
13
|
-
parent: ResolvingMetadata
|
|
14
|
-
): Promise<Metadata> => {
|
|
15
|
-
const blog = await client.content.blog(params);
|
|
16
|
-
|
|
17
|
-
if (blog.type === "not-found") {
|
|
18
|
-
return parent as Metadata;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
const previousImages = (await parent).openGraph?.images || [];
|
|
22
|
-
|
|
23
|
-
if (blog.type === "post") {
|
|
24
|
-
const openGraphImageKey = blog.data?.titleFile?.fileKey;
|
|
25
|
-
|
|
26
|
-
const images = openGraphImageKey
|
|
27
|
-
? [`${opinlyConfig.imagesUrl}/${openGraphImageKey}`, ...previousImages]
|
|
28
|
-
: previousImages;
|
|
29
|
-
|
|
30
|
-
return {
|
|
31
|
-
...(parent as Metadata),
|
|
32
|
-
title: blog.data.title,
|
|
33
|
-
|
|
34
|
-
openGraph: {
|
|
35
|
-
images: images,
|
|
36
|
-
type: "article",
|
|
37
|
-
authors: blog.data.author && [
|
|
38
|
-
`${opinlyConfig.blogUrl}/authors/${blog.data.author.slug}`,
|
|
39
|
-
],
|
|
40
|
-
},
|
|
41
|
-
|
|
42
|
-
// keywords: [blog.data.keywords],
|
|
43
|
-
authors: blog.data.author && [
|
|
44
|
-
{
|
|
45
|
-
name: blog.data.author.name,
|
|
46
|
-
url: `${opinlyConfig.blogUrl}/authors/${blog.data.author.slug}`,
|
|
47
|
-
},
|
|
48
|
-
],
|
|
49
|
-
other: {},
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
return parent as Metadata;
|
|
54
|
-
};
|
package/src/utils/images.ts
DELETED
package/src/utils/merge.ts
DELETED
package/sst-env.d.ts
DELETED
package/tsconfig.json
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": ["../../tsconfig.base.json", "@tsconfig/next/tsconfig.json"],
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"moduleResolution": "bundler",
|
|
5
|
-
"jsx": "react-jsx",
|
|
6
|
-
"lib": ["dom", "dom.iterable", "esnext"],
|
|
7
|
-
"allowJs": true,
|
|
8
|
-
"skipLibCheck": true,
|
|
9
|
-
"strict": true,
|
|
10
|
-
"forceConsistentCasingInFileNames": true,
|
|
11
|
-
"noEmit": true,
|
|
12
|
-
"esModuleInterop": true,
|
|
13
|
-
"resolveJsonModule": true,
|
|
14
|
-
"isolatedModules": true,
|
|
15
|
-
"incremental": false
|
|
16
|
-
},
|
|
17
|
-
"include": ["src/**/*"],
|
|
18
|
-
"exclude": ["node_modules"]
|
|
19
|
-
}
|