-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: SEO improvements - dynamic sitemap, robots.txt, and meta handli…
…ng (#32) - Dynamic sitemap and robots.txt generation for better SEO. #25 - Move metadata generation from layout to pages for flexibility. - Abstract markdown parsing for consistent content handling. - Add dynamic post URLs with Chinese-to-Pinyin slug conversion. #25 - Update `.gitignore` to exclude generated JSON files for posts. - Improve accessibility, fix aria-label, and enforce only one H1 per page. - Refactor: remove custom script support and enhance OpenGraph metadata. - Optimize image loading with priority flag and reduce redundant divs. - Minor fixes: font size, tag keywords, and improved SEO metadata.
- Loading branch information
Showing
29 changed files
with
444 additions
and
251 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,3 +34,6 @@ yarn-error.log* | |
# typescript | ||
*.tsbuildinfo | ||
next-env.d.ts | ||
|
||
# User generated files | ||
public/postsData.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
'use client'; | ||
|
||
// Get the current date | ||
function getCurrentDate() { | ||
const date = new Date(); | ||
const formatNumber = (num) => String(num).padStart(2, '0'); | ||
|
||
const year = date.getFullYear(); | ||
const month = formatNumber(date.getMonth() + 1); | ||
const day = formatNumber(date.getDate()); | ||
const hours = formatNumber(date.getHours()); | ||
const minutes = formatNumber(date.getMinutes()); | ||
const seconds = formatNumber(date.getSeconds()); | ||
|
||
return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`; | ||
} | ||
|
||
// Gray scale filter (only for /) on specific dates | ||
function grayScale() { | ||
// Set the date you want to gray scale | ||
const grayScaleDates = ['04-04', '05-12', '09-18', '11-20', '12-13']; | ||
|
||
// Get the current date | ||
const currentDate = getCurrentDate(); | ||
const currentMonthDay = currentDate | ||
.split(' ')[0] | ||
.split('-') | ||
.slice(1) | ||
.join('-'); | ||
|
||
// Check if the current date is in the gray scale date list | ||
if (grayScaleDates.includes(currentMonthDay)) { | ||
// If is, set the gray scale filter | ||
document.body.style.filter = 'grayscale(100%)'; | ||
} | ||
} | ||
|
||
// Custom console log | ||
// eslint-disable-next-line no-console | ||
console.info( | ||
'%c由ZL Asica制作搭建与运行\nBuilt and Operated by ZL Asica\nhttps://www.zla.app', | ||
'background:#fff;color:#000', | ||
); | ||
|
||
// Check if the current URL path is "/" | ||
if (window.location.pathname === '/') { | ||
grayScale(); | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,36 @@ | ||
import Loading from '@/app/loading'; | ||
import PostLayout from '@/components/layout/PostLayout'; | ||
import { getConfig } from '@/services/config/getConfig'; | ||
import { getPostData } from '@/services/content/posts'; | ||
import { PostData } from '@/types'; | ||
import type { Metadata } from 'next'; | ||
import { Suspense } from 'react'; | ||
|
||
export async function generateMetadata(): Promise<Metadata> { | ||
const config = getConfig(); | ||
return { | ||
title: `About - ${config.title}`, | ||
description: `About page of ${config.title} - ${config.description}`, | ||
openGraph: { | ||
siteName: config.title, | ||
type: 'profile', | ||
username: config.author.name, | ||
title: `About - ${config.title}`, | ||
description: `About page of ${config.title} - ${config.description}`, | ||
images: config.avatar, | ||
url: '/about', | ||
locale: config.lang, | ||
}, | ||
}; | ||
} | ||
|
||
export default async function AboutPage() { | ||
const post: PostData = await getPostData('About', 'About'); | ||
const config = getConfig(); | ||
|
||
return <PostLayout post={post} showThumbnail={config.thumbnailAbout} />; | ||
return ( | ||
<Suspense fallback={<Loading />}> | ||
<PostLayout post={post} showThumbnail={config.thumbnailAbout} /> | ||
</Suspense> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,36 @@ | ||
import Loading from '@/app/loading'; | ||
import PostLayout from '@/components/layout/PostLayout'; | ||
import { getConfig } from '@/services/config/getConfig'; | ||
import { getPostData } from '@/services/content/posts'; | ||
import '@/styles/friendsLinks.css'; | ||
import { PostData } from '@/types'; | ||
import type { Metadata } from 'next'; | ||
import { Suspense } from 'react'; | ||
|
||
export async function generateMetadata(): Promise<Metadata> { | ||
const config = getConfig(); | ||
return { | ||
title: `Friends - ${config.title}`, | ||
description: `Friends page of ${config.title} - ${config.description}`, | ||
openGraph: { | ||
siteName: config.title, | ||
title: `Friends - ${config.title}`, | ||
description: `Friends page of ${config.title} - ${config.description}`, | ||
url: '/friends', | ||
images: config.avatar, | ||
type: 'website', | ||
locale: config.lang, | ||
}, | ||
}; | ||
} | ||
|
||
export default async function FriendsPage() { | ||
const post: PostData = await getPostData('Friends', 'Friends'); | ||
const config = getConfig(); | ||
|
||
return <PostLayout post={post} showThumbnail={config.thumbnailFriends} />; | ||
return ( | ||
<Suspense fallback={<Loading />}> | ||
<PostLayout post={post} showThumbnail={config.thumbnailFriends} /> | ||
</Suspense> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.