Skip to content

Commit ea192fa

Browse files
authored
Some seo improvements (codesandbox#3839)
* add some SEO * add rel
1 parent 3bd0095 commit ea192fa

File tree

10 files changed

+75
-26
lines changed

10 files changed

+75
-26
lines changed

packages/app/src/app/pages/Sandbox/Editor/Workspace/screens/Comments/Comment.tsx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,15 @@ export const Comment = React.memo<{
7878
? comment.references[0].metadata.path
7979
: 'General'}
8080
</Link>
81-
<Stack align="flex-start" justify="space-between" marginBottom={4}>
81+
<Stack
82+
as="article"
83+
itemprop="comment"
84+
itemscope=""
85+
itemtype="http://schema.org/Comment"
86+
align="flex-start"
87+
justify="space-between"
88+
marginBottom={4}
89+
>
8290
<AvatarBlock comment={comment} />
8391
<Stack align="center">
8492
{comment.isResolved && (
@@ -129,10 +137,10 @@ export const Comment = React.memo<{
129137
borderColor: 'sideBar.border',
130138
})}
131139
>
132-
<Text block css={truncateText} marginBottom={2}>
140+
<Text itemprop="text" block css={truncateText} marginBottom={2}>
133141
{comment.content}
134142
</Text>
135-
<Text variant="muted" size={2}>
143+
<Text variant="muted" size={2} itemprop="commentCount">
136144
{getRepliesString(comment.comments.length)}
137145
</Text>
138146
</Element>

packages/app/src/app/pages/Sandbox/Editor/Workspace/screens/Comments/Dialog/Markdown/Link.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export const LinkElement = ({ href, children, ...props }) => {
3030

3131
if (!href.includes('codesandbox')) {
3232
return (
33-
<Link target="_blank" rel="noopener noreferrer" {...props}>
33+
<Link target="_blank" rel="noopener noreferrer ugc" {...props}>
3434
{children}
3535
</Link>
3636
);

packages/app/src/app/pages/Sandbox/Editor/Workspace/screens/Comments/Dialog/Reply.tsx

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,16 @@ export const Reply = ({ reply }: ReplyProps) => {
2929
},
3030
}}
3131
>
32-
<Element key={id} marginLeft={4} marginRight={2} paddingTop={6}>
32+
<Element
33+
as="article"
34+
itemprop="comment"
35+
itemscope=""
36+
itemtype="http://schema.org/Comment"
37+
key={id}
38+
marginLeft={4}
39+
marginRight={2}
40+
paddingTop={6}
41+
>
3342
<Stack align="flex-start" justify="space-between" marginBottom={4}>
3443
<AvatarBlock comment={reply} />
3544
{state.user.id === user.id && (
@@ -65,7 +74,9 @@ export const Reply = ({ reply }: ReplyProps) => {
6574
})}
6675
>
6776
{!editing ? (
68-
<Markdown source={content} />
77+
<Element itemprop="text">
78+
<Markdown source={content} />
79+
</Element>
6980
) : (
7081
<EditComment
7182
initialValue={reply.content}

packages/app/src/app/pages/Sandbox/Editor/Workspace/screens/Comments/Dialog/index.tsx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,14 @@ const DialogAddComment: React.FC<{
188188
marginRight={2}
189189
>
190190
<Stack gap={2} align="center">
191-
<Avatar user={comment.user} />
192-
<Text size={3} weight="bold" variant="body">
191+
<Element
192+
itemprop="author"
193+
itemscope=""
194+
itemtype="http://schema.org/Person"
195+
>
196+
<Avatar user={comment.user} />
197+
</Element>
198+
<Text size={3} weight="bold" variant="body" itemprop="name">
193199
{comment.user.username}
194200
</Text>
195201
</Stack>
@@ -347,7 +353,9 @@ const CommentBody = ({ comment, editing, setEditing, hasReplies }) => {
347353
})}
348354
>
349355
{!editing ? (
350-
<Markdown source={comment.content} />
356+
<Element itemprop="text">
357+
<Markdown source={comment.content} />
358+
</Element>
351359
) : (
352360
<EditComment
353361
initialValue={comment.content}

packages/app/src/app/pages/Sandbox/Editor/Workspace/screens/Comments/components/AvatarBlock.tsx

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Avatar, Stack, Text } from '@codesandbox/components';
1+
import { Avatar, Stack, Text, Element } from '@codesandbox/components';
22
import { CommentFragment } from 'app/graphql/types';
33
import { formatDistance } from 'date-fns';
44
import { zonedTimeToUtc } from 'date-fns-tz';
@@ -8,12 +8,19 @@ export const AvatarBlock: React.FC<{ comment: CommentFragment }> = ({
88
comment,
99
}) => (
1010
<Stack gap={2} align="center">
11-
<Avatar user={comment.user} />
11+
<Element itemprop="author" itemscope="" itemtype="http://schema.org/Person">
12+
<Avatar user={comment.user} />
13+
</Element>
1214
<Stack direction="vertical" justify="center" gap={1}>
13-
<Text size={3} weight="bold" variant="body">
15+
<Text itemprop="name" size={3} weight="bold" variant="body">
1416
{comment.user.username}
1517
</Text>
16-
<Text size={2} variant="muted">
18+
<Text
19+
size={2}
20+
variant="muted"
21+
itemprop="dateCreated"
22+
datetime={comment.insertedAt.toString()}
23+
>
1724
{formatDistance(
1825
zonedTimeToUtc(comment.insertedAt, 'Etc/UTC'),
1926
new Date(),

packages/app/src/app/pages/Sandbox/Editor/Workspace/screens/Comments/components/MultiComment.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ export const MultiComment = ({ x, y, ids }: MultiCommentProps) => {
133133
size={2}
134134
weight="bold"
135135
paddingRight={2}
136+
itemprop="name"
136137
css={css({
137138
color: 'sideBar.foreground',
138139
})}

packages/app/src/app/pages/Sandbox/Editor/Workspace/screens/Comments/index.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,9 @@ export const Comments: React.FC = () => {
110110

111111
{currentComments.length ? (
112112
<List
113+
itemprop="mainEntity"
114+
itemscope=""
115+
itemtype="http://schema.org/Conversation"
113116
ref={scrollRef}
114117
marginTop={4}
115118
css={{

packages/components/src/components/Element/index.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ export interface IElementProps {
1616
paddingTop?: number;
1717
paddingLeft?: number;
1818
paddingRight?: number;
19+
itemprop?: string;
20+
itemscope?: string;
21+
itemtype?: string;
1922
css?: Object;
2023
}
2124

packages/components/src/components/List/index.tsx

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@ import css from '@styled-system/css';
33
import { Element } from '../Element';
44
import { Stack } from '../Stack';
55

6+
type ListActionProps = {
7+
disabled?: boolean;
8+
itemprop?: string;
9+
itemscope?: string;
10+
itemtype?: string;
11+
};
12+
613
export const List = styled(Element).attrs({ as: 'ul' })(
714
css({
815
listStyle: 'none',
@@ -22,17 +29,16 @@ export const ListItem = styled(Stack).attrs({
2229
})
2330
);
2431

25-
export const ListAction = styled(ListItem)<{ disabled?: boolean }>(
26-
({ disabled }) =>
27-
css({
28-
':hover, &[aria-selected="true"]': {
29-
cursor: !disabled ? 'pointer' : 'disabled',
30-
color: !disabled ? 'list.hoverForeground' : 'inherit',
31-
backgroundColor: !disabled ? 'list.hoverBackground' : 'inherit',
32-
},
33-
':focus-within': {
34-
color: !disabled ? 'list.hoverForeground' : 'inherit',
35-
backgroundColor: !disabled ? 'list.hoverBackground' : 'inherit',
36-
},
37-
})
32+
export const ListAction = styled(ListItem)<ListActionProps>(({ disabled }) =>
33+
css({
34+
':hover, &[aria-selected="true"]': {
35+
cursor: !disabled ? 'pointer' : 'disabled',
36+
color: !disabled ? 'list.hoverForeground' : 'inherit',
37+
backgroundColor: !disabled ? 'list.hoverBackground' : 'inherit',
38+
},
39+
':focus-within': {
40+
color: !disabled ? 'list.hoverForeground' : 'inherit',
41+
backgroundColor: !disabled ? 'list.hoverBackground' : 'inherit',
42+
},
43+
})
3844
);

packages/components/src/components/Text/index.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ export interface ITextProps extends React.HTMLAttributes<HTMLSpanElement> {
2121
block?: boolean;
2222
maxWidth?: number | string;
2323
variant?: 'body' | 'muted' | 'danger';
24+
itemprop?: string;
25+
datetime?: string;
2426
}
2527

2628
export const Text = styled(Element).attrs({ as: 'span' })<ITextProps>(

0 commit comments

Comments
 (0)