Skip to content

Commit d3ec082

Browse files
committed
feat: add canonical link for posts
1 parent 4bc2abf commit d3ec082

File tree

3 files changed

+43
-2
lines changed

3 files changed

+43
-2
lines changed

package-lock.json

Lines changed: 35 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
"@types/node": "^22.10.2",
5151
"@types/react": "^18.3.17",
5252
"@types/react-dom": "^18.3.5",
53+
"@types/react-helmet": "^6.1.11",
5354
"@vitejs/plugin-react": "^4.3.1",
5455
"@vitest/coverage-v8": "^2.1.8",
5556
"@vitest/ui": "^2.1.8",
@@ -61,6 +62,7 @@
6162
"globals": "^15.9.0",
6263
"happy-dom": "^15.11.7",
6364
"postcss": "^8.4.35",
65+
"react-helmet": "^6.1.0",
6466
"tailwindcss": "^3.4.1",
6567
"typescript": "^5.5.3",
6668
"typescript-eslint": "^8.3.0",

src/routes/profile/$handle/post.$postId.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@ import { PostCard } from '../../../components/PostCard';
55
import { BSkyPost } from '../../../lib/bluesky/types/BSkyPost';
66
import { ErrorBoundary } from '../../../components/ErrorBoundary';
77
import { useTranslation } from 'react-i18next';
8+
import { Helmet } from 'react-helmet';
89

910
export const Route = createFileRoute('/profile/$handle/post/$postId')({
10-
component: Profile,
11+
component: Post,
1112
});
1213

13-
function Profile() {
14+
function Post() {
1415
const { handle } = Route.useParams();
1516
const { data: profile, isLoading: isLoadingProfile } = useProfile({ handle });
1617
const params = Route.useParams();
@@ -26,6 +27,9 @@ function Profile() {
2627

2728
return (
2829
<>
30+
<Helmet>
31+
<link rel="canonical" href={`https://bsky.app/profile/${handle}/post/${params.postId}`} />
32+
</Helmet>
2933
<PostCard post={postThread?.post as BSkyPost} />
3034
<ErrorBoundary>
3135
{(postThread?.replies as { post: BSkyPost }[])?.map((reply) => reply.post && <PostCard post={reply.post} />)}

0 commit comments

Comments
 (0)