Skip to content

Commit

Permalink
fix: fix client side exception
Browse files Browse the repository at this point in the history
mdx에 한글 포함될 시 swcMinify 켜면 한글 제대로 처리 못함..
  • Loading branch information
ooooorobo committed Nov 16, 2023
1 parent 65e4ec4 commit da0fec4
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 30 deletions.
14 changes: 2 additions & 12 deletions next.config.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,15 @@
/** @type {import('next').NextConfig} */

const nextConfig = {
swcMinify: true,
swcMinify: false,
reactStrictMode: true,
pageExtensions: ["js", "jsx", "ts", "tsx", "md", "mdx"],
compiler: {
styledComponents: true,
},
};

// eslint-disable-next-line @typescript-eslint/no-var-requires
const withMdx = require("@next/mdx")({
extension: /\.mdx?$/,
options: {
remarkPlugins: [],
rehypePlugins: [],
providerImportSource: "@mdx-js/react",
},
});

// eslint-disable-next-line @typescript-eslint/no-var-requires
const { withContentlayer } = require("next-contentlayer");

module.exports = withContentlayer(withMdx(nextConfig));
module.exports = withContentlayer(nextConfig);
45 changes: 27 additions & 18 deletions src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,9 @@ import { PostListElement } from "@src/model/post";
import Profile from "@src/components/main/Profile";
import PostList from "@src/components/main/PostList";

const Home: NextPage = () => {
const posts = allPosts
.sort((a, b) => compareDesc(new Date(a.date), new Date(b.date)))
.map(
(meta) =>
({
slug: meta.url,
meta: {
index: meta.id,
title: meta.title,
description: meta.description || "",
postedAt: meta.date,
category: "",
series: "",
tags: [] as string[],
},
} as PostListElement)
);
type HomeProps = { posts: PostListElement[] };

const Home: NextPage<HomeProps> = ({ posts }: HomeProps) => {
useEffect(() => {
const scroll = parseInt(sessionStorage.getItem("mainscroll") ?? "0");
window.scrollTo({ top: scroll, behavior: "auto" });
Expand Down Expand Up @@ -58,6 +42,31 @@ const Home: NextPage = () => {
);
};

export const getStaticProps = () => {
const posts = allPosts
.sort((a, b) => {
const compareByDate = compareDesc(new Date(a.date), new Date(b.date));
if (compareByDate !== 0) return compareByDate;
return b.id - a.id;
})
.map(
(meta) =>
({
slug: meta.url,
meta: {
index: meta.id,
title: meta.title,
description: meta.description || "",
postedAt: meta.date,
category: "",
series: "",
tags: [] as string[],
},
} as PostListElement)
);
return { props: { posts } };
};

export default Home;

const Wrapper = styled.div`
Expand Down

1 comment on commit da0fec4

@vercel
Copy link

@vercel vercel bot commented on da0fec4 Nov 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.