Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions components/Codeblock/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { classNames } from "@/lib/classNames";

type CodeblockProps = Pick<React.JSX.IntrinsicElements["pre"], "children" | "className">;
type CodeblockProps = React.JSX.IntrinsicElements["pre"];

export function Codeblock({ children }: CodeblockProps) {
return <pre className={classNames("Codeblock")}>{children}</pre>;
export function Codeblock({ className, ...props }: CodeblockProps) {
return <pre className={classNames("Codeblock", className)} {...props} />;
}
13 changes: 9 additions & 4 deletions layouts/Post/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { MDXRemote, MDXRemoteSerializeResult } from "next-mdx-remote";
import { MDXClient } from "next-mdx-remote-client";
import { type SerializeResult } from "next-mdx-remote-client/serialize";

import { ApiArticle } from "@/cms/api/ApiArticle";
import { Blockquote } from "@/components/Blockquote";
Expand All @@ -20,12 +21,16 @@ import { Footer } from "./components/Footer";
export interface PostProps {
breadcrumbs: Array<{ label: string; url?: string }>;

mdx: MDXRemoteSerializeResult;
mdx: SerializeResult;

post: ApiArticle;
}

export function Post({ breadcrumbs, mdx, post }: PostProps) {
export function Post({ breadcrumbs, mdx, post }: Readonly<PostProps>) {
if ("error" in mdx) {
throw mdx.error;
}

return (
<>
<Seo post={post} />
Expand All @@ -38,7 +43,7 @@ export function Post({ breadcrumbs, mdx, post }: PostProps) {
<Timestamp date={post.date} />
</header>

<MDXRemote
<MDXClient
components={{
a: Link,
blockquote: Blockquote,
Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
"front-matter": "4.0.2",
"lodash": "4.17.21",
"next": "16.1.0",
"next-mdx-remote": "5.0.0",
"prismjs": "1.30.0",
"next-mdx-remote-client": "^2.1.7",
"react": "19.2.3",
"react-dom": "19.2.3",
"react-icons": "5.5.0",
Expand Down
19 changes: 11 additions & 8 deletions pages/blog/[slug].tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { GetStaticPaths, GetStaticProps } from "next";
import { MDXRemoteSerializeResult } from "next-mdx-remote";
import { serialize } from "next-mdx-remote/serialize";
import { serialize, type SerializeResult } from "next-mdx-remote-client/serialize";
import React from "react";
import rehypeHighligh from "rehype-highlight";
import rehypeHighlight from "rehype-highlight";
import rehypeUnwrapImages from "rehype-unwrap-images";
import remarkGfm from "remark-gfm";

Expand All @@ -13,7 +12,7 @@ import { isDevelopment } from "@/lib/env";

interface ArticleProps {
article: ApiArticle;
mdx: MDXRemoteSerializeResult;
mdx: SerializeResult;
}

export default class Articles extends React.Component<ArticleProps> {
Expand Down Expand Up @@ -47,10 +46,14 @@ export const getStaticProps: GetStaticProps<ArticleProps> = async ({ params }) =
props: {
article: article.toApiArticle({ cover: "https://codecoolture.com/static/articles/cover.jpg" }),

mdx: await serialize(article.getContent(), {
mdxOptions: {
rehypePlugins: [rehypeHighligh, rehypeUnwrapImages],
remarkPlugins: [remarkGfm],
mdx: await serialize({
source: article.getContent(),

options: {
mdxOptions: {
rehypePlugins: [rehypeHighlight, rehypeUnwrapImages],
remarkPlugins: [remarkGfm],
},
},
}),
},
Expand Down
30 changes: 15 additions & 15 deletions pages/notes/[slug].tsx
Original file line number Diff line number Diff line change
@@ -1,25 +1,21 @@
import { GetStaticPaths, GetStaticProps } from "next";
import { MDXRemoteSerializeResult } from "next-mdx-remote";
import { serialize } from "next-mdx-remote/serialize";
import React from "react";
import rehypeHighligh from "rehype-highlight";
import rehypeHighlight from "rehype-highlight";
import rehypeUnwrapImages from "rehype-unwrap-images";
import remarkGfm from "remark-gfm";
import { serialize, type SerializeResult } from "next-mdx-remote-client/serialize";

import { ApiArticle } from "@/cms/api/ApiArticle";
import { getNotesRepository } from "@/cms/repositories";
import { Post } from "@/layouts/Post";
import { isDevelopment } from "@/lib/env";

interface NoteProps {
mdx: MDXRemoteSerializeResult;
type NoteProps = {
mdx: SerializeResult;
note: ApiArticle;
}
};

export default class Notes extends React.Component<NoteProps> {
public render() {
return <Post breadcrumbs={[{ label: "Notes", url: "/notes" }]} mdx={this.props.mdx} post={this.props.note} />;
}
export default function Note(props: Readonly<NoteProps>) {
return <Post breadcrumbs={[{ label: "Notes", url: "/notes" }]} mdx={props.mdx} post={props.note} />;
}

export const getStaticPaths: GetStaticPaths = async () => {
Expand Down Expand Up @@ -47,10 +43,14 @@ export const getStaticProps: GetStaticProps<NoteProps> = async ({ params }) => {
props: {
note: note.toApiArticle({ cover: "https://codecoolture.com/static/notes/cover.jpg" }),

mdx: await serialize(note.getContent(), {
mdxOptions: {
rehypePlugins: [rehypeHighligh, rehypeUnwrapImages],
remarkPlugins: [remarkGfm],
mdx: await serialize({
source: note.getContent(),

options: {
mdxOptions: {
rehypePlugins: [rehypeHighlight, rehypeUnwrapImages],
remarkPlugins: [remarkGfm],
},
},
}),
},
Expand Down
90 changes: 46 additions & 44 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# yarn lockfile v1


"@babel/code-frame@^7.23.5", "@babel/code-frame@^7.27.1":
"@babel/code-frame@^7.27.1":
version "7.27.1"
resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.27.1.tgz#200f715e66d52a23b221a9435534a91cc13ad5be"
integrity sha512-cjQ7ZlQ0Mv3b47hABuTevyTuYN4i+loJKGeV9flcCgIK37cCXRh+L1bd3iBHlynerhQ7BhCkn2BPbQUL+rGqFg==
Expand Down Expand Up @@ -639,7 +639,7 @@
"@mdx-js/mdx" "^3.0.0"
source-map "^0.7.0"

"@mdx-js/mdx@^3.0.0", "@mdx-js/mdx@^3.0.1":
"@mdx-js/mdx@^3.0.0", "@mdx-js/mdx@^3.1.1":
version "3.1.1"
resolved "https://registry.yarnpkg.com/@mdx-js/mdx/-/mdx-3.1.1.tgz#c5ffd991a7536b149e17175eee57a1a2a511c6d1"
integrity sha512-f6ZO2ifpwAQIpzGWaBQT2TXxPv6z3RBzQKpVftEWN78Vl/YweF1uwussDx8ECAXVtr3Rs89fKyG9YlzUs9DyGQ==
Expand Down Expand Up @@ -670,7 +670,7 @@
unist-util-visit "^5.0.0"
vfile "^6.0.0"

"@mdx-js/[email protected]", "@mdx-js/react@^3.0.1":
"@mdx-js/[email protected]", "@mdx-js/react@^3.1.1":
version "3.1.1"
resolved "https://registry.yarnpkg.com/@mdx-js/react/-/react-3.1.1.tgz#24bda7fffceb2fe256f954482123cda1be5f5fef"
integrity sha512-f++rKLQgUVYDAtECQ6fn/is15GkEH9+nZPM3MS0RcxVqoTfawHvDlSCH7JbMhAM6uJ32v3eXLvLmLvjGu7PTQw==
Expand Down Expand Up @@ -976,7 +976,7 @@
dependencies:
marked "*"

"@types/mdast@^4.0.0":
"@types/mdast@^4.0.0", "@types/mdast@^4.0.4":
version "4.0.4"
resolved "https://registry.yarnpkg.com/@types/mdast/-/mdast-4.0.4.tgz#7ccf72edd2f1aa7dd3437e180c64373585804dd6"
integrity sha512-kGaNbPh1k7AFzgpud/gMdvIm5xuECykRR+JnWKQno9TAXVa6WIVCGTPvYGekIDL4uwCZQSYbUxNBSb1aUo79oA==
Expand Down Expand Up @@ -3853,7 +3853,7 @@ mdast-util-mdx@^3.0.0:
mdast-util-mdxjs-esm "^2.0.0"
mdast-util-to-markdown "^2.0.0"

mdast-util-mdxjs-esm@^2.0.0:
mdast-util-mdxjs-esm@^2.0.0, mdast-util-mdxjs-esm@^2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/mdast-util-mdxjs-esm/-/mdast-util-mdxjs-esm-2.0.1.tgz#019cfbe757ad62dd557db35a695e7314bcc9fa97"
integrity sha512-EcmOpxsZ96CvlP03NghtH1EsLtr0n9Tm4lPUJUBccV9RwUOneqSycg19n5HGzCf+10LozMRSObtVr3ee1WoHtg==
Expand Down Expand Up @@ -4351,17 +4351,18 @@ natural-compare@^1.4.0:
resolved "https://registry.yarnpkg.com/natural-compare/-/natural-compare-1.4.0.tgz#4abebfeed7541f2c27acfb29bdbbd15c8d5ba4f7"
integrity sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==

next-mdx-remote@5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/next-mdx-remote/-/next-mdx-remote-5.0.0.tgz#028a2cf5cf7f814d988d7ab11a401bed0f31b4ee"
integrity sha512-RNNbqRpK9/dcIFZs/esQhuLA8jANqlH694yqoDBK8hkVdJUndzzGmnPHa2nyi90N4Z9VmzuSWNRpr5ItT3M7xQ==
next-mdx-remote-client@^2.1.7:
version "2.1.7"
resolved "https://registry.yarnpkg.com/next-mdx-remote-client/-/next-mdx-remote-client-2.1.7.tgz#ef4210138f850c08290c6619545060c95527b000"
integrity sha512-IwGYX3iwZ5UwXYIO3VQV9wE65KWC/pB8PLacmwgjYz65pydRqxIrRf70AXA6mZvR747mh4p6x+E868BhNbpP3A==
dependencies:
"@babel/code-frame" "^7.23.5"
"@mdx-js/mdx" "^3.0.1"
"@mdx-js/react" "^3.0.1"
unist-util-remove "^3.1.0"
vfile "^6.0.1"
vfile-matter "^5.0.0"
"@babel/code-frame" "^7.27.1"
"@mdx-js/mdx" "^3.1.1"
"@mdx-js/react" "^3.1.1"
remark-mdx-remove-esm "^1.2.1"
serialize-error "^12.0.0"
vfile "^6.0.3"
vfile-matter "^5.0.1"

[email protected]:
version "16.1.0"
Expand Down Expand Up @@ -4651,11 +4652,6 @@ pretty-bytes@^5.6.0:
resolved "https://registry.yarnpkg.com/pretty-bytes/-/pretty-bytes-5.6.0.tgz#356256f643804773c82f64723fe78c92c62beaeb"
integrity sha512-FFw039TmrBqFK8ma/7OL3sDz/VytdtJr044/QUJtH0wK9lb9jLq9tJyIxUwtQJHwar2BqtiA4iCWSwo9JLkzFg==

[email protected]:
version "1.30.0"
resolved "https://registry.yarnpkg.com/prismjs/-/prismjs-1.30.0.tgz#d9709969d9d4e16403f6f348c63553b19f0975a9"
integrity sha512-DEvV2ZF2r2/63V+tK8hQvrR2ZGn10srHbXviTlcv7Kpzw8jWiNTqbVgjO3IY8RxrrOUF8VPMQQFysYYYv0YZxw==

process@^0.11.10:
version "0.11.10"
resolved "https://registry.yarnpkg.com/process/-/process-0.11.10.tgz#7332300e840161bda3e69a1d1d91a7d4bc16f182"
Expand Down Expand Up @@ -4847,6 +4843,15 @@ [email protected]:
remark-stringify "^11.0.0"
unified "^11.0.0"

remark-mdx-remove-esm@^1.2.1:
version "1.2.2"
resolved "https://registry.yarnpkg.com/remark-mdx-remove-esm/-/remark-mdx-remove-esm-1.2.2.tgz#6901b691892c89d50abe35ad2fdec6c26af48091"
integrity sha512-YSaUwqiuJuD6S9XTAD6zmO4JJJZJgsRAdsl2drZO8/ssAVv0HXAg4vkSgHZAP46ORh8ERPFQrC7JWlbkwBwu1A==
dependencies:
"@types/mdast" "^4.0.4"
mdast-util-mdxjs-esm "^2.0.1"
unist-util-remove "^4.0.0"

remark-mdx@^3.0.0:
version "3.1.1"
resolved "https://registry.yarnpkg.com/remark-mdx/-/remark-mdx-3.1.1.tgz#047f97038bc7ec387aebb4b0a4fe23779999d845"
Expand Down Expand Up @@ -5041,6 +5046,13 @@ semver@^7.6.0, semver@^7.7.1, semver@^7.7.3:
resolved "https://registry.yarnpkg.com/semver/-/semver-7.7.3.tgz#4b5f4143d007633a8dc671cd0a6ef9147b8bb946"
integrity sha512-SdsKMrI9TdgjdweUSR9MweHA4EJ8YxHn8DFaDisvhVlUOe4BF1tLD7GAj0lIqWVl+dPb/rExr0Btby5loQm20Q==

serialize-error@^12.0.0:
version "12.0.0"
resolved "https://registry.yarnpkg.com/serialize-error/-/serialize-error-12.0.0.tgz#aed3d5abff192c855707513929bf8bf48d712194"
integrity sha512-ZYkZLAvKTKQXWuh5XpBw7CdbSzagarX39WyZ2H07CDLC5/KfsRGlIXV8d4+tfqX1M7916mRqR1QfNHSij+c9Pw==
dependencies:
type-fest "^4.31.0"

set-function-length@^1.2.2:
version "1.2.2"
resolved "https://registry.yarnpkg.com/set-function-length/-/set-function-length-1.2.2.tgz#aac72314198eaed975cf77b2c3b6b880695e5449"
Expand Down Expand Up @@ -5579,6 +5591,11 @@ type-fest@^0.8.0:
resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.8.1.tgz#09e249ebde851d3b1e48d27c105444667f17b83d"
integrity sha512-4dbzIzqvjtgiM5rw1k5rEHtBANKmdudhGyBEajN01fEyhaAIhsoKNy6y7+IN93IfpFtwY9iqi7kD+xwKhQsNJA==

type-fest@^4.31.0:
version "4.41.0"
resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-4.41.0.tgz#6ae1c8e5731273c2bf1f58ad39cbae2c91a46c58"
integrity sha512-TeTSQ6H5YHvpqVwBRcnLDCBnDOHWYu7IvGbHT6N8AOymcr9PJGjc1GTtiWZTYg0NCgYwvnYWEkVChQAr9bjfwA==

typed-array-buffer@^1.0.3:
version "1.0.3"
resolved "https://registry.yarnpkg.com/typed-array-buffer/-/typed-array-buffer-1.0.3.tgz#a72395450a4869ec033fd549371b47af3a2ee536"
Expand Down Expand Up @@ -5675,13 +5692,6 @@ unist-util-find-after@^5.0.0:
"@types/unist" "^3.0.0"
unist-util-is "^6.0.0"

unist-util-is@^5.0.0:
version "5.2.1"
resolved "https://registry.yarnpkg.com/unist-util-is/-/unist-util-is-5.2.1.tgz#b74960e145c18dcb6226bc57933597f5486deae9"
integrity sha512-u9njyyfEh43npf1M+yGKDGVPbY/JWEemg5nH05ncKPfi+kBbKBJoTdsogMu33uhytuLlv9y0O7GH7fEdwLdLQw==
dependencies:
"@types/unist" "^2.0.0"

unist-util-is@^6.0.0:
version "6.0.1"
resolved "https://registry.yarnpkg.com/unist-util-is/-/unist-util-is-6.0.1.tgz#d0a3f86f2dd0db7acd7d8c2478080b5c67f9c6a9"
Expand All @@ -5703,14 +5713,14 @@ unist-util-position@^5.0.0:
dependencies:
"@types/unist" "^3.0.0"

unist-util-remove@^3.1.0:
version "3.1.1"
resolved "https://registry.yarnpkg.com/unist-util-remove/-/unist-util-remove-3.1.1.tgz#8bfa181aff916bd32a4ed30b3ed76d0c21c077df"
integrity sha512-kfCqZK5YVY5yEa89tvpl7KnBBHu2c6CzMkqHUrlOqaRgGOMp0sMvwWOVrbAtj03KhovQB7i96Gda72v/EFE0vw==
unist-util-remove@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/unist-util-remove/-/unist-util-remove-4.0.0.tgz#94b7d6bbd24e42d2f841e947ed087be5c82b222e"
integrity sha512-b4gokeGId57UVRX/eVKej5gXqGlc9+trkORhFJpu9raqZkZhU0zm8Doi05+HaiBsMEIJowL+2WtQ5ItjsngPXg==
dependencies:
"@types/unist" "^2.0.0"
unist-util-is "^5.0.0"
unist-util-visit-parents "^5.0.0"
"@types/unist" "^3.0.0"
unist-util-is "^6.0.0"
unist-util-visit-parents "^6.0.0"

unist-util-stringify-position@^4.0.0:
version "4.0.0"
Expand All @@ -5719,14 +5729,6 @@ unist-util-stringify-position@^4.0.0:
dependencies:
"@types/unist" "^3.0.0"

unist-util-visit-parents@^5.0.0:
version "5.1.3"
resolved "https://registry.yarnpkg.com/unist-util-visit-parents/-/unist-util-visit-parents-5.1.3.tgz#b4520811b0ca34285633785045df7a8d6776cfeb"
integrity sha512-x6+y8g7wWMyQhL1iZfhIPhDAs7Xwbn9nRosDXl7qoPTSCy0yNxnKc+hWokFifWQIDGi154rdUqKvbCa4+1kLhg==
dependencies:
"@types/unist" "^2.0.0"
unist-util-is "^5.0.0"

unist-util-visit-parents@^6.0.0:
version "6.0.2"
resolved "https://registry.yarnpkg.com/unist-util-visit-parents/-/unist-util-visit-parents-6.0.2.tgz#777df7fb98652ce16b4b7cd999d0a1a40efa3a02"
Expand Down Expand Up @@ -5810,7 +5812,7 @@ [email protected]:
core-util-is "1.0.2"
extsprintf "^1.2.0"

vfile-matter@^5.0.0:
vfile-matter@^5.0.1:
version "5.0.1"
resolved "https://registry.yarnpkg.com/vfile-matter/-/vfile-matter-5.0.1.tgz#3f701840dde13c68d72d5c5ebd9cf233dff84419"
integrity sha512-o6roP82AiX0XfkyTHyRCMXgHfltUNlXSEqCIS80f+mbAyiQBE2fxtDVMtseyytGx75sihiJFo/zR6r/4LTs2Cw==
Expand All @@ -5826,7 +5828,7 @@ vfile-message@^4.0.0:
"@types/unist" "^3.0.0"
unist-util-stringify-position "^4.0.0"

vfile@^6.0.0, vfile@^6.0.1:
vfile@^6.0.0, vfile@^6.0.3:
version "6.0.3"
resolved "https://registry.yarnpkg.com/vfile/-/vfile-6.0.3.tgz#3652ab1c496531852bf55a6bac57af981ebc38ab"
integrity sha512-KzIbH/9tXat2u30jf+smMwFCsno4wHVdNmzFyL+T/L3UGqqk6JKfVqOFOZEpZSHADH1k40ab6NUIXZq422ov3Q==
Expand Down
Loading