Skip to content

Commit

Permalink
Merge pull request #88 from KaoruMuta/feature/#86
Browse files Browse the repository at this point in the history
refactor(#86): expand clickable area of blog title and refine sources
  • Loading branch information
KaoruMuta authored Jan 3, 2025
2 parents 1ffd136 + 0b67dc7 commit ffd9bf1
Show file tree
Hide file tree
Showing 11 changed files with 55 additions and 52 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mysite",
"version": "2.0.0",
"version": "2.1.0",
"private": true,
"scripts": {
"dev": "NODE_OPTIONS='--inspect' next dev",
Expand Down
26 changes: 26 additions & 0 deletions src/components/BlogPostList.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import Link from 'next/link';
import { PostPropsType } from 'types/PostPropsType';
import Description from './Description';

const BlogPostList = ({ posts }: { posts: PostPropsType[] }) => {
return (
<>
{posts.map((post) => {
const { id, title, date, categories } = post;
return (
<>
<section className="py-4" key={id}>
<Link href={`/blog/posts/${id}`}>
<h2 className="font-semibold text-xl xl:text-2xl xl:hover:opacity-hover">{title}</h2>
</Link>
<Description date={date} categories={categories} />
</section>
<hr />
</>
);
})}
</>
);
};

export default BlogPostList;
23 changes: 0 additions & 23 deletions src/components/Gallery.tsx

This file was deleted.

4 changes: 2 additions & 2 deletions src/components/Layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import Header from './Header';

const Layout = ({ children }: { children?: ReactNode }) => {
return (
<div id="layoutContainer" className="flex flex-col font-sans mx-4 sm:mx-16 md:mx-56 h-screen">
<section id="layoutContainer" className="flex flex-col font-sans mx-4 sm:mx-16 md:mx-56 h-screen">
<Header />
<main className="flex-grow">{children}</main>
<Footer />
</div>
</section>
);
};

Expand Down
5 changes: 5 additions & 0 deletions src/components/PageTitle.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const PageTitle = ({ name }: { name: string }) => {
return <h1 className="font-bold text-3xl xl:text-4xl">{name}</h1>;
};

export default PageTitle;
5 changes: 0 additions & 5 deletions src/components/Title.tsx

This file was deleted.

8 changes: 3 additions & 5 deletions src/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,9 @@ const MyApp: NextPage<AppProps> = ({ Component, pageProps }) => {
}, [router.events]);

return (
<>
<Layout>
<Component {...pageProps} />
</Layout>
</>
<Layout>
<Component {...pageProps} />
</Layout>
);
};
export default MyApp;
11 changes: 6 additions & 5 deletions src/pages/blog/categories/[category].tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Gallery from 'components/Gallery';
import Title from 'components/Title';
import BlogPostList from 'components/BlogPostList';
import PageTitle from 'components/PageTitle';
import { loadAllCategories, loadSortedPostsForCategoryByDate } from 'lib/posts';
import { InferGetStaticPropsType, NextPage } from 'next';
import Head from 'next/head';
Expand Down Expand Up @@ -28,9 +28,10 @@ const Category: NextPage<InferGetStaticPropsType<typeof getStaticProps>> = ({ ca
<Head>
<title>{category}</title>
</Head>
<section className="divide-y my-16">
<Title name={`# ${category}`} />
<Gallery posts={posts} />
<section className="my-16">
<PageTitle name={`# ${category}`} />
<hr className="mt-4" />
<BlogPostList posts={posts} />
</section>
</>
);
Expand Down
8 changes: 4 additions & 4 deletions src/pages/blog/posts/[id].tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Ads from 'components/Ads';
import Description from 'components/Description';
import PageTitle from 'components/PageTitle';
import Share from 'components/Share';
import Title from 'components/Title';
import { loadAllPostIds, loadPostById } from 'lib/posts';
import { InferGetStaticPropsType, NextPage } from 'next';
import Head from 'next/head';
Expand Down Expand Up @@ -38,14 +38,14 @@ const Post: NextPage<InferGetStaticPropsType<typeof getStaticProps>> = ({ post }
<title>{post.title}</title>
</Head>
<article className="my-16 break-all">
<Title name={post.title} />
<PageTitle name={post.title} />
<Description date={post.date} categories={post.categories} />
<hr className="mt-4"></hr>
<hr className="mt-4" />
<article
className="py-4 max-w-none prose prose-indigo xl:prose-lg"
dangerouslySetInnerHTML={{ __html: post.content }}
/>
<hr className="mb-4"></hr>
<hr className="mb-4" />
<Share url={`${process.env.HOST}/blog/posts/${post.id}`} title={post.title} />
<Ads />
</article>
Expand Down
11 changes: 6 additions & 5 deletions src/pages/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Gallery from 'components/Gallery';
import Title from 'components/Title';
import BlogPostList from 'components/BlogPostList';
import PageTitle from 'components/PageTitle';
import { loadAllSortedPostsByDate } from 'lib/posts';
import { InferGetStaticPropsType, NextPage } from 'next';
import Head from 'next/head';
Expand All @@ -23,9 +23,10 @@ const Blog: NextPage<InferGetStaticPropsType<typeof getStaticProps>> = ({ allSor
/>
<title>tionblog</title>
</Head>
<section className="divide-y my-16">
<Title name="tionblog" />
<Gallery posts={allSortedPostsByDate} />
<section className="my-16">
<PageTitle name="tionblog" />
<hr className="mt-4" />
<BlogPostList posts={allSortedPostsByDate} />
</section>
</>
);
Expand Down
4 changes: 2 additions & 2 deletions src/pages/privacy.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Title from 'components/Title';
import PageTitle from 'components/PageTitle';
import { NextPage } from 'next';
import Head from 'next/head';

Expand All @@ -9,7 +9,7 @@ const Privacy: NextPage = () => {
<title>Privacy Policy</title>
</Head>
<article className="prose prose-indigo max-w-none my-16">
<Title name="Privacy Policy" />
<PageTitle name="Privacy Policy" />
<h2>個人情報の利用目的</h2>
<p>
当サイトでは、お問い合わせの際、名前やメールアドレス等の個人情報を取得することがあります。
Expand Down

0 comments on commit ffd9bf1

Please sign in to comment.