diff --git a/.eslintrc b/.eslintrc deleted file mode 100644 index e5762ef2..00000000 --- a/.eslintrc +++ /dev/null @@ -1,14 +0,0 @@ -{ - "extends": ["next/core-web-vitals", "prettier"], - "plugins": ["chakra-ui"], - "parserOptions": { - "project": true - }, - "rules": { - "sort-imports": "error", - "@next/next/no-img-element": "off", - "chakra-ui/props-order": "error", - "chakra-ui/props-shorthand": "error", - "chakra-ui/require-specific-component": "error" - } -} diff --git a/.eslintrc.js b/.eslintrc.js new file mode 100644 index 00000000..8412da57 --- /dev/null +++ b/.eslintrc.js @@ -0,0 +1,17 @@ +module.exports = { + extends: ["next/core-web-vitals", "prettier"], + plugins: ["chakra-ui"], + parser: "@typescript-eslint/parser", + parserOptions: { + project: true, + tsconfigRootDir: __dirname, + }, + rules: { + "sort-imports": "error", + "@next/next/no-img-element": "off", + "chakra-ui/props-order": "error", + "chakra-ui/props-shorthand": "error", + "chakra-ui/require-specific-component": "error", + }, + ignorePatterns: [".eslintrc.js"], +}; diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a47a34b6..0d80881d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -39,7 +39,6 @@ jobs: - name: Run build run: | yarn build - yarn export env: NEXT_PUBLIC_BASE_URL: ${{ secrets.BASE_URL }} NEXT_PUBLIC_GOOGLE_ANALYTICS_ID: ${{ secrets.GOOGLE_ANALYTICS_ID }} diff --git a/.stylelintrc b/.stylelintrc index be312d35..c913c419 100644 --- a/.stylelintrc +++ b/.stylelintrc @@ -1,9 +1,5 @@ { - "extends": [ - "stylelint-config-sass-guidelines", - "stylelint-config-recess-order", - "stylelint-config-prettier" - ], + "extends": ["stylelint-config-sass-guidelines", "stylelint-config-recess-order"], "rules": { "order/properties-alphabetical-order": null } diff --git a/next.config.js b/next.config.js new file mode 100644 index 00000000..c9561894 --- /dev/null +++ b/next.config.js @@ -0,0 +1,10 @@ +// @ts-check + +/** + * @type {import('next').NextConfig} + */ +const nextConfig = { + output: "export", +}; + +module.exports = nextConfig; diff --git a/package.json b/package.json index 69f29535..01c9d110 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,6 @@ "dev": "next dev", "build": "next build", "start": "next start", - "export": "next export", "lint:code": "next lint", "lint:code:fix": "next lint --fix", "lint:style": "stylelint 'src/**/*.{css,scss}'", @@ -44,6 +43,7 @@ "@types/node": "^18.11.10", "@types/react": "^18.2.21", "@types/react-test-renderer": "^18.0.0", + "@typescript-eslint/parser": "^6.7.5", "@vitejs/plugin-react": "^3.1.0", "eslint": "8.37.0", "eslint-config-next": "13.5.3", @@ -60,7 +60,6 @@ "react-test-renderer": "^18.2.0", "sass": "^1.62.1", "stylelint": "^15.10.3", - "stylelint-config-prettier": "^9.0.4", "stylelint-config-recess-order": "^4.3.0", "stylelint-config-sass-guidelines": "^10.0.0", "ts-node": "^10.9.1", diff --git a/src/app/blog/[id]/page.tsx b/src/app/blog/[id]/page.tsx new file mode 100644 index 00000000..34806533 --- /dev/null +++ b/src/app/blog/[id]/page.tsx @@ -0,0 +1,20 @@ +import { BlogInfo, BlogInfos, getAllBlogInfos, getBlogFromId } from "../../lib/blog-fetch"; +import { Metadata } from "next"; +import { Post } from "./post"; + +export async function generateMetadata({ params }: { params: BlogInfo }): Promise { + const { title } = await getBlogFromId(params.id); + return { title: `ブログ - ${title}` }; +} + +export async function generateStaticParams(): Promise { + return getAllBlogInfos(); +} + +export default async function Page({ params }: { params?: BlogInfo }) { + if (params == null) { + throw new Error("invalid params"); + } + const post = await getBlogFromId(params.id); + return ; +} diff --git a/src/pages/blog/[id].tsx b/src/app/blog/[id]/post.tsx similarity index 61% rename from src/pages/blog/[id].tsx rename to src/app/blog/[id]/post.tsx index 27faef5c..d9592395 100644 --- a/src/pages/blog/[id].tsx +++ b/src/app/blog/[id]/post.tsx @@ -1,8 +1,8 @@ -import { Blog, BlogInfo, getAllBlogInfos, getBlogFromId } from "../../lib/blog-fetch"; +"use client"; + import { Container, Heading, Link, Text, VStack } from "@chakra-ui/react"; -import type { GetStaticPaths, GetStaticProps, NextPage } from "next"; +import { Blog } from "../../lib/blog-fetch"; import { DateString } from "../../components/date"; -import { Layout } from "../../components/layout"; import MarkdownIt from "markdown-it"; import MarkdownItFootnote from "markdown-it-footnote"; import MarkdownItFrontMatter from "markdown-it-front-matter"; @@ -17,11 +17,11 @@ const md = MarkdownIt({ .use(MarkdownItFrontMatter) .use(MarkdownItFootnote); -type BlogPostPageProps = { +export type BlogPostPageProps = { post: Blog; }; -const BlogPostPage: NextPage = ({ post }) => { +export const Post = ({ post }: BlogPostPageProps) => { const prevNext = ( = ({ post }) => { ); const bodyHtml = md.render(emojify`${post.content}`); return ( - + <> {post.title} @@ -48,26 +48,6 @@ const BlogPostPage: NextPage = ({ post }) => {
{prevNext} - + ); }; - -export const getStaticProps: GetStaticProps = async ({ params }) => { - if (params == null) { - throw new Error("invalid params"); - } - console.dir(params); - const post = await getBlogFromId(params.id); - return { - props: { - post, - }, - }; -}; - -export const getStaticPaths: GetStaticPaths = async () => { - const paths = await getAllBlogInfos(); - return { paths, fallback: false }; -}; - -export default BlogPostPage; diff --git a/src/app/blog/blog.tsx b/src/app/blog/blog.tsx new file mode 100644 index 00000000..c3c10ad8 --- /dev/null +++ b/src/app/blog/blog.tsx @@ -0,0 +1,50 @@ +"use client"; +import { + Avatar, + Button, + Flex, + HStack, + Heading, + Link, + SimpleGrid, + Spacer, + VStack, +} from "@chakra-ui/react"; +import { DateString } from "../components/date"; +import { Metadata } from "../lib/blog-fetch"; +import NextLink from "next/link"; +import { Metadata as NextMetadata } from "next"; +import type { NextPage } from "next"; + +export const metadata: NextMetadata = { + title: "限界開発鯖 - ブログ", +}; + +const BlogCard = ({ id, title, date, author, authorId }: Metadata): JSX.Element => ( + + + + + + {title} + + + + {author} + + + + + + +); + +export const Blog: NextPage<{ blogs: Metadata[] }> = ({ blogs }) => ( + + {blogs.map((blog) => ( + + ))} + +); diff --git a/src/app/blog/page.tsx b/src/app/blog/page.tsx new file mode 100644 index 00000000..0b8e279f --- /dev/null +++ b/src/app/blog/page.tsx @@ -0,0 +1,7 @@ +import { Blog } from "./blog"; +import { getSortedBlogMetadata } from "../lib/blog-fetch"; + +export default async function Page() { + const blogs = await getSortedBlogMetadata(); + return ; +} diff --git a/src/components/__snapshots__/date.test.tsx.snap b/src/app/components/__snapshots__/date.test.tsx.snap similarity index 100% rename from src/components/__snapshots__/date.test.tsx.snap rename to src/app/components/__snapshots__/date.test.tsx.snap diff --git a/src/components/__snapshots__/footer.test.tsx.snap b/src/app/components/__snapshots__/footer.test.tsx.snap similarity index 100% rename from src/components/__snapshots__/footer.test.tsx.snap rename to src/app/components/__snapshots__/footer.test.tsx.snap diff --git a/src/components/__snapshots__/header.test.tsx.snap b/src/app/components/__snapshots__/header.test.tsx.snap similarity index 100% rename from src/components/__snapshots__/header.test.tsx.snap rename to src/app/components/__snapshots__/header.test.tsx.snap diff --git a/src/components/__snapshots__/layout.test.tsx.snap b/src/app/components/__snapshots__/layout.test.tsx.snap similarity index 100% rename from src/components/__snapshots__/layout.test.tsx.snap rename to src/app/components/__snapshots__/layout.test.tsx.snap diff --git a/src/components/__snapshots__/navigation.test.tsx.snap b/src/app/components/__snapshots__/navigation.test.tsx.snap similarity index 100% rename from src/components/__snapshots__/navigation.test.tsx.snap rename to src/app/components/__snapshots__/navigation.test.tsx.snap diff --git a/src/components/__snapshots__/prev-next-link.test.tsx.snap b/src/app/components/__snapshots__/prev-next-link.test.tsx.snap similarity index 100% rename from src/components/__snapshots__/prev-next-link.test.tsx.snap rename to src/app/components/__snapshots__/prev-next-link.test.tsx.snap diff --git a/src/components/__snapshots__/questions.test.tsx.snap b/src/app/components/__snapshots__/questions.test.tsx.snap similarity index 100% rename from src/components/__snapshots__/questions.test.tsx.snap rename to src/app/components/__snapshots__/questions.test.tsx.snap diff --git a/src/components/__snapshots__/sns-link.test.tsx.snap b/src/app/components/__snapshots__/sns-link.test.tsx.snap similarity index 100% rename from src/components/__snapshots__/sns-link.test.tsx.snap rename to src/app/components/__snapshots__/sns-link.test.tsx.snap diff --git a/src/components/__snapshots__/title.test.tsx.snap b/src/app/components/__snapshots__/title.test.tsx.snap similarity index 100% rename from src/components/__snapshots__/title.test.tsx.snap rename to src/app/components/__snapshots__/title.test.tsx.snap diff --git a/src/components/date.test.tsx b/src/app/components/date.test.tsx similarity index 81% rename from src/components/date.test.tsx rename to src/app/components/date.test.tsx index ac5ea27a..e3e717ac 100644 --- a/src/components/date.test.tsx +++ b/src/app/components/date.test.tsx @@ -1,6 +1,6 @@ import { expect, it } from "vitest"; import { DateString } from "./date"; -import { render } from "../utils/react-test"; +import { render } from "../../utils/react-test"; it("renders correctly", () => { const tree = render(); diff --git a/src/components/date.tsx b/src/app/components/date.tsx similarity index 100% rename from src/components/date.tsx rename to src/app/components/date.tsx diff --git a/src/components/footer.test.tsx b/src/app/components/footer.test.tsx similarity index 79% rename from src/components/footer.test.tsx rename to src/app/components/footer.test.tsx index bc62885a..701bcd04 100644 --- a/src/components/footer.test.tsx +++ b/src/app/components/footer.test.tsx @@ -1,6 +1,6 @@ import { expect, it } from "vitest"; import { Footer } from "./footer"; -import { render } from "../utils/react-test"; +import { render } from "../../utils/react-test"; it("renders correctly", () => { const tree = render(