(false);
const getCommentAuthor = () => {
return comment.author.url ? (
{comment.author.name}
) : (
{comment.author.name}
);
};
const getLocaleDate = () => {
const date = getFormattedDate(comment.date, locale);
const time = new Date(comment.date)
.toLocaleTimeString(locale, {
hour: 'numeric',
minute: 'numeric',
})
.replace(':', 'h');
return intl.formatMessage(
{
defaultMessage: '{date} at {time}',
description: 'Comment: publication date',
},
{
date,
time,
}
);
};
const getApprovedComment = () => {
return (
<>
{shouldOpenForm && (
)}
{comment.replies.length > 0 && (
{comment.replies.map((reply) => {
return (
);
})}
)}
>
);
};
const getCommentStatus = () => {
return (
{intl.formatMessage({
defaultMessage: 'This comment is awaiting moderation.',
description: 'Comment: awaiting moderation message',
})}
);
};
const schemaJsonLd: WithContext = {
'@context': 'https://schema.org',
'@id': `${settings.url}/#comment-${comment.databaseId}`,
'@type': 'Comment',
parentItem: isNested
? { '@id': `${settings.url}/#comment-${comment.parentDatabaseId}` }
: undefined,
about: { '@type': 'Article', '@id': `${settings.url}/#article` },
author: {
'@type': 'Person',
name: comment.author.name,
image: comment.author.gravatarUrl,
url: comment.author.url,
},
creator: {
'@type': 'Person',
name: comment.author.name,
image: comment.author.gravatarUrl,
url: comment.author.url,
},
dateCreated: comment.date,
datePublished: comment.date,
text: comment.content,
};
return (
<>
{comment.approved ? getApprovedComment() : getCommentStatus()}
>
);
};
export default Comment;