Skip to content

Commit 4b667d2

Browse files
committed
chore: code polish and social preview optimization
1 parent 4e0cf0d commit 4b667d2

File tree

2 files changed

+25
-3
lines changed

2 files changed

+25
-3
lines changed

src/components/Meta.tsx

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,34 @@ export function Meta(props: MetaProps) {
4747
return null;
4848
}
4949

50+
/**
51+
* Common meta tag presets for convenience.
52+
*/
5053
/**
5154
* Common meta tag presets for convenience.
5255
*/
5356
export const MetaPresets = {
57+
/**
58+
* Standard SEO description.
59+
* @param content - Page description (recommended: 50-160 chars)
60+
*/
5461
description: (content: string) => <Meta name="description" content={content} />,
62+
63+
/**
64+
* Viewport configuration for responsive design.
65+
* @param content - default: "width=device-width, initial-scale=1"
66+
*/
5567
viewport: (content = "width=device-width, initial-scale=1") => <Meta name="viewport" content={content} />,
68+
69+
/**
70+
* Character encoding declaration.
71+
* @param charset - default: "UTF-8"
72+
*/
5673
charset: (charset = "UTF-8") => <Meta charset={charset} />,
74+
75+
/**
76+
* Robots indexing directives.
77+
* @param content - e.g., "index, follow" or "noindex"
78+
*/
5779
robots: (content: string) => <Meta name="robots" content={content} />,
5880
};

src/components/SocialPreview/index.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
'use client';
2-
import { useSyncExternalStore, useState } from 'react';
2+
import { useSyncExternalStore, useState, memo } from 'react';
33

44
interface PreviewData {
55
title: string;
@@ -71,7 +71,7 @@ export interface SocialPreviewProps {
7171
forceVisible?: boolean;
7272
}
7373

74-
export function SocialPreview({ forceVisible }: SocialPreviewProps) {
74+
export const SocialPreview = memo(function SocialPreview({ forceVisible }: SocialPreviewProps) {
7575
// Safety guard: only run in development unless forced
7676
if (process.env.NODE_ENV !== 'development' && !forceVisible) {
7777
return null;
@@ -137,4 +137,4 @@ export function SocialPreview({ forceVisible }: SocialPreviewProps) {
137137
</div>
138138
</div>
139139
);
140-
}
140+
});

0 commit comments

Comments
 (0)