Skip to content
This repository has been archived by the owner on Mar 30, 2024. It is now read-only.

Commit

Permalink
Merge pull request #9 from paveg/seo
Browse files Browse the repository at this point in the history
♻️ Update seo settings
  • Loading branch information
paveg authored Mar 17, 2024
2 parents 6336b56 + e2e6b26 commit de26f63
Show file tree
Hide file tree
Showing 7 changed files with 104 additions and 2 deletions.
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
enable-pre-post-scripts=true
15 changes: 15 additions & 0 deletions app/[...slug]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { notFound } from 'next/navigation';
import { Metadata } from 'next';
import { ArticleJsonLd } from 'next-seo';
import { allPages } from 'contentlayer/generated';

import { Mdx } from '@/components/mdx-components';
import { cfg } from '@/utils/constants';

interface PageProps {
params: {
Expand Down Expand Up @@ -43,14 +45,27 @@ export async function generateStaticParams(): Promise<PageProps['params'][]> {
}

export default async function PagePage({ params }: PageProps) {
const pagePublishedDate = '2024-03-17'
const page = await getPageFromParams(params);

if (!page) {
notFound();
}

const fullUrl = [cfg.siteURL, page.slugAsParams].join('/');

return (
<article className="prose py-6 dark:prose-invert">
<ArticleJsonLd
useAppDir={true}
url={fullUrl}
title={page.title}
images={[]}
datePublished={pagePublishedDate}
authorName={cfg.author}
description={page?.description ?? ''}
/>

<h1>{page.title}</h1>
{page.description && <p className="text-xl">{page.description}</p>}
<hr />
Expand Down
11 changes: 11 additions & 0 deletions app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,19 @@ const fontSans = FontSans({
});

export const metadata = {
metadataBase: new URL(cfg.siteURL),
url: cfg.siteURL,
title: cfg.siteTitle,
description: cfg.siteDescription,
openGraph: {
siteName: cfg.siteTitle,
title: cfg.siteTitle,
description: 'The logs of a software engineer whose name is Funai.',
locale: 'ja_JP',
type: 'website',
url: cfg.siteURL,
images: [],
},
};

interface RootLayoutProps {
Expand Down
18 changes: 16 additions & 2 deletions app/posts/[...slug]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import '@/styles/codes/prism-dracula.css';
import { notFound } from 'next/navigation';
import { Metadata } from 'next';
import { ArticleJsonLd } from 'next-seo';
import { allPosts } from 'contentlayer/generated';

import { Mdx } from '@/components/mdx-components';
import { TableOfContents } from '@/components/table-of-contents';
import '@/styles/codes/prism-dracula.css';
import { cfg } from '@/utils/constants';

interface PostProps {
params: {
Expand Down Expand Up @@ -61,10 +62,23 @@ export default async function PostPage({ params }: PostProps) {
notFound();
}

const fullUrl = cfg.siteURL + post.slug;

// TODO: Improve tailwindCSS
// TODO: Add post date and the hero image
return (
<article className="prose py-6 transition-colors dark:prose-invert">
<ArticleJsonLd
useAppDir={true}
url={fullUrl}
title={post.title}
images={[]}
// TODO: update published and revised
datePublished={post.date}
dateModified={post.date}
authorName={cfg.author}
description={post?.description ?? ''}
/>
<h1 className="mb-4">{post.title}</h1>
{post.date && (
<p className="text-sm text-slate-700 dark:text-slate-200">
Expand Down
6 changes: 6 additions & 0 deletions next-sitemap.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/** @type {import('next-sitemap').IConfig} */
module.exports = {
siteUrl: 'https://www.funailog.com',
generateRobotsTxt: true,
sitemapSize: 5000,
};
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"scripts": {
"dev": "next dev",
"build": "next build",
"postbuild": "next-sitemap --config next-sitemap.config.js",
"preview": "next build && next start",
"start": "next start",
"lint": "next lint --config .eslintrc.json",
Expand All @@ -30,6 +31,8 @@
"github-slugger": "^2.0.0",
"next": "14.0.4",
"next-contentlayer": "^0.3.4",
"next-seo": "^6.5.0",
"next-sitemap": "^4.2.3",
"next-themes": "^0.2.1",
"postcss": "8.4.23",
"react": "18.2.0",
Expand Down
52 changes: 52 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit de26f63

Please sign in to comment.