Skip to content

Commit

Permalink
feat: Add more meta tags for SEO
Browse files Browse the repository at this point in the history
  • Loading branch information
OXeu committed Jun 8, 2024
1 parent 4defbd8 commit 554af74
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 6 deletions.
14 changes: 12 additions & 2 deletions client/src/page/feeds.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import { useContext, useEffect, useRef, useState } from "react"
import { Helmet } from 'react-helmet'
import { Link, useSearch } from "wouter"
import { FeedCard } from "../components/feed_card"
import { Waiting } from "../components/loading"
import { client } from "../main"
import { ProfileContext } from "../state/profile"
import { headersWithAuth } from "../utils/auth"
import { siteName } from "../utils/constants"

function tryInt(defaultValue: number, ...args: (string | number | undefined | null)[]): number {
for (const v of args) {
Expand Down Expand Up @@ -74,8 +76,16 @@ export function FeedsPage() {
}, [query.get("page"), query.get("type")])
return (
<>
<Helmet>
<title>{`${"文章"} - ${process.env.NAME}`}</title>
<meta property="og:site_name" content={siteName} />
<meta property="og:title" content={"文章"} />
<meta property="og:image" content={process.env.AVATAR} />
<meta property="og:type" content="article" />
<meta property="og:url" content={document.URL} />
</Helmet>
<Waiting wait={feeds[listState].size > 0 || status === 'idle'}>
<div className="w-full flex flex-col justify-center items-center mb-8">
<main className="w-full flex flex-col justify-center items-center mb-8">
<div className="wauto text-start text-black dark:text-white p-4 text-4xl font-bold">
<p>
{listState === 'draft' ? "草稿箱" : listState === 'normal' ? "文章" : "未列出"}
Expand Down Expand Up @@ -116,7 +126,7 @@ export function FeedsPage() {
}
</div>
</Waiting>
</div>
</main>
</Waiting>
</>
)
Expand Down
14 changes: 12 additions & 2 deletions client/src/page/friends.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import { client } from "../main"
import { ProfileContext } from "../state/profile"
import { shuffleArray } from "../utils/array"
import { headersWithAuth } from "../utils/auth"
import { Helmet } from 'react-helmet'
import { siteName } from "../utils/constants"


type FriendItem = {
Expand Down Expand Up @@ -79,8 +81,16 @@ export function FriendsPage() {
const friends_unavaliable = friends?.filter(({ health }) => health.length > 0) || []
shuffleArray(friends_unavaliable)
return (<>
<Helmet>
<title>{`${"朋友们"} - ${process.env.NAME}`}</title>
<meta property="og:site_name" content={siteName} />
<meta property="og:title" content={"朋友们"} />
<meta property="og:image" content={process.env.AVATAR} />
<meta property="og:type" content="article" />
<meta property="og:url" content={document.URL} />
</Helmet>
<Waiting wait={friends}>
<div className="w-full flex flex-col justify-center items-center mb-8 t-primary">
<main className="w-full flex flex-col justify-center items-center mb-8 t-primary">
{friends_avaliable.length > 0 &&
<>
<div className="wauto text-start py-4 text-4xl font-bold">
Expand Down Expand Up @@ -130,7 +140,7 @@ export function FriendsPage() {
</div>
</div>
}
</div>
</main>
</Waiting>
</>)
}
Expand Down
14 changes: 12 additions & 2 deletions client/src/page/timeline.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { useEffect, useRef, useState } from "react"
import { Helmet } from 'react-helmet'
import { Link } from "wouter"
import { Waiting } from "../components/loading"
import { client } from "../main"
import { headersWithAuth } from "../utils/auth"
import { siteName } from "../utils/constants"

export function TimelinePage() {
const [feeds, setFeeds] = useState<Partial<Record<number, { id: number; title: string | null; createdAt: Date; }[]>>>()
Expand All @@ -26,8 +28,16 @@ export function TimelinePage() {
}, [])
return (
<>
<Helmet>
<title>{`${"时间线"} - ${process.env.NAME}`}</title>
<meta property="og:site_name" content={siteName} />
<meta property="og:title" content={"时间线"} />
<meta property="og:image" content={process.env.AVATAR} />
<meta property="og:type" content="article" />
<meta property="og:url" content={document.URL} />
</Helmet>
<Waiting wait={feeds}>
<div className="w-full flex flex-col justify-center items-center mb-8 px-4">
<main className="w-full flex flex-col justify-center items-center mb-8 px-4">
<div className="wauto text-start text-black dark:text-white py-4 text-4xl font-bold">
<p>
时间轴
Expand All @@ -53,7 +63,7 @@ export function TimelinePage() {
</div>
</div>
))}
</div>
</main>
</Waiting>
</>
)
Expand Down
10 changes: 10 additions & 0 deletions client/src/page/writing.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import { Checkbox, Input } from '../components/input';
import { Padding } from '../components/padding';
import { client } from '../main';
import { headersWithAuth } from '../utils/auth';
import { Helmet } from 'react-helmet'
import { siteName } from "../utils/constants";

async function publish({ title, alias, listed, content, summary, tags, draft }: { title: string, listed: boolean, content: string, summary: string, tags: string[], draft: boolean, alias?: string }) {
const { data, error } = await client.feed.index.post({
Expand Down Expand Up @@ -177,6 +179,14 @@ export function WritingPage({ id }: { id?: number }) {

return (
<Padding>
<Helmet>
<title>{`${"写作"} - ${process.env.NAME}`}</title>
<meta property="og:site_name" content={siteName} />
<meta property="og:title" content={"写作"} />
<meta property="og:image" content={process.env.AVATAR} />
<meta property="og:type" content="article" />
<meta property="og:url" content={document.URL} />
</Helmet>
<div onDragOver={e => { e.preventDefault() }} onDragLeave={e => { e.preventDefault() }} onDrop={e => {
e.preventDefault()
for (let i = 0; i < e.dataTransfer.files.length; i++) {
Expand Down

0 comments on commit 554af74

Please sign in to comment.