Skip to content

Commit

Permalink
fix: 포스트 경로 문제 해결
Browse files Browse the repository at this point in the history
  • Loading branch information
XionWCFM committed Dec 6, 2024
1 parent 825e37f commit 51e590c
Show file tree
Hide file tree
Showing 8 changed files with 412 additions and 35 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ node_modules
.env.test.local
.env.production.local

storybook-static

# Testing
coverage

Expand Down Expand Up @@ -40,3 +42,5 @@ yarn-error.log*
# Misc
.DS_Store
*.pem

*storybook.log
1 change: 1 addition & 0 deletions apps/blog/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"devDependencies": {
"@repo/tailwindcss-config": "workspace:^",
"@repo/typescript-config": "workspace:*",
"@storybook/react": "^8.4.7",
"@testing-library/jest-dom": "^6.6.3",
"@testing-library/react": "^16.0.1",
"@testing-library/user-event": "^14.5.2",
Expand Down
5 changes: 3 additions & 2 deletions apps/blog/src/entities/post/model/post.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ import { env } from "@repo/env";
import { compileMDX } from "next-mdx-remote/rsc";
import { getKoreanToday } from "~/shared/utils/date/get-korean-today";
import type { FrontmatterType, PostType, PostWithFrontmatterType } from "./post.model";

const POST_REPOSITORY_FOLDER_NAME = "posts";

const getPostsDirectory = () => {
return path.join(process.cwd(), POST_REPOSITORY_FOLDER_NAME);
};

const MDX_REGEX = /\.mdx$/;
const SLASH_REGEX = /^\/+/;

const readDirectory = (directory: string): Pick<PostType, "filePath">[] => {
const postsDirectory = getPostsDirectory();
Expand All @@ -23,7 +23,8 @@ const readDirectory = (directory: string): Pick<PostType, "filePath">[] => {
return posts.concat(readDirectory(fullPath));
}
if (file.isFile() && path.extname(file.name) === ".mdx") {
const filePath = fullPath.replace(MDX_REGEX, "").replace(SLASH_REGEX, "").replace(postsDirectory, "").split("/");
const relativePath = path.relative(postsDirectory, fullPath);
const filePath = relativePath.replace(MDX_REGEX, "").split("/");
posts.push({ filePath });
}
return posts;
Expand Down
4 changes: 2 additions & 2 deletions apps/blog/src/page/PostDetailPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ export default function PostDetailPage({ post }: PostPageProps) {
<PostDetailAuthorAndDate date={post.releaseDate} />
</Box>
<Separate />
<Spacing h={"16"} w={undefined} />
<Spacing h={"16"} />
<MdxRemote source={post.content} />
<Box my="40">
<PostDetailAuthorWithChar />
</Box>
<Separate />
<Spacing h={"40"} w={undefined} />
<Spacing h={"40"} />
</Stack>
);
}
15 changes: 15 additions & 0 deletions apps/blog/src/shared/ui/common/MainXionWcfm.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import type { Meta, StoryObj } from "@storybook/react";
import { MainXionWcfm } from "./MainXionWcfm";

const meta = {
title: "Blog/Main",
component: MainXionWcfm,
parameters: {
layout: "fullscreen",
},
} satisfies Meta<typeof MainXionWcfm>;

export default meta;
type Story = StoryObj<typeof meta>;

export const LoggedOut: Story = {};
3 changes: 2 additions & 1 deletion apps/blog/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
"~/shared/*": ["./src/shared/*"],
"~/apps/*": ["./src/apps/*"],
"@repo/*": ["../../packages/*"]
}
},
"types": ["vitest/globals"]
},
"include": ["**/*.ts", "**/*.tsx", "next-env.d.ts", ".next/types/**/*.ts", "vitest.config.mts"],
"exclude": ["node_modules"]
Expand Down
4 changes: 3 additions & 1 deletion packages/env/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ export const env = createEnv({
NEXT_PUBLIC_SUPABASE_ANON_KEY: z.string().min(1),
},
server: {
NODE_ENV: z.enum(["development", "production", "test"]),
NEXT_SUPABASE_SERVICE_ROLE: z.string().min(1),
},
shared: {
NODE_ENV: z.enum(["development", "production", "test"]),
},
runtimeEnv: {
NEXT_PUBLIC_GA_ID: process.env.NEXT_PUBLIC_GA_ID,
NEXT_PUBLIC_GTM_ID: process.env.NEXT_PUBLIC_GTM_ID,
Expand Down
Loading

0 comments on commit 51e590c

Please sign in to comment.