perf: improve SEO and page performance #3
No files matched your search
@@ -184,7 +184,22 @@ for (const post of postPages) {
|
|||||||
);
|
);
|
||||||
requireSingleMeta(post.html, post.label, 'og:type', 'article');
|
requireSingleMeta(post.html, post.label, 'og:type', 'article');
|
||||||
const publishedTime = requireSingleMeta(post.html, post.label, 'article:published_time');
|
const publishedTime = requireSingleMeta(post.html, post.label, 'article:published_time');
|
||||||
requireSingleMeta(post.html, post.label, 'article:author');
|
const articleAuthors = metaTags(post.html, 'property', 'article:author');
|
||||||
|
for (const articleAuthor of articleAuthors) {
|
||||||
|
const authorUrl = attribute(articleAuthor, 'content');
|
||||||
|
assert.ok(authorUrl?.trim(), `${post.label} article:author must not be empty`);
|
||||||
|
let parsedAuthorUrl;
|
||||||
|
assert.doesNotThrow(
|
||||||
|
() => {
|
||||||
|
parsedAuthorUrl = new URL(authorUrl);
|
||||||
|
},
|
||||||
|
`${post.label} article:author must be a valid absolute URL`,
|
||||||
|
);
|
||||||
|
assert.ok(
|
||||||
|
['https:', 'http:'].includes(parsedAuthorUrl.protocol),
|
||||||
|
`${post.label} article:author must use HTTP or HTTPS`,
|
||||||
|
);
|
||||||
|
}
|
||||||
requireValidDate(
|
requireValidDate(
|
||||||
attribute(publishedTime, 'content'),
|
attribute(publishedTime, 'content'),
|
||||||
`${post.label} article:published_time content`,
|
`${post.label} article:published_time content`,
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ interface Props {
|
|||||||
robots?: string;
|
robots?: string;
|
||||||
publishedTime?: Date;
|
publishedTime?: Date;
|
||||||
updatedTime?: Date;
|
updatedTime?: Date;
|
||||||
author?: string;
|
authorUrl?: string;
|
||||||
tags?: string[];
|
tags?: string[];
|
||||||
structuredData?: StructuredData;
|
structuredData?: StructuredData;
|
||||||
}
|
}
|
||||||
@@ -27,7 +27,7 @@ const {
|
|||||||
robots = 'index, follow',
|
robots = 'index, follow',
|
||||||
publishedTime,
|
publishedTime,
|
||||||
updatedTime,
|
updatedTime,
|
||||||
author,
|
authorUrl,
|
||||||
tags,
|
tags,
|
||||||
structuredData,
|
structuredData,
|
||||||
} = Astro.props;
|
} = Astro.props;
|
||||||
@@ -62,7 +62,7 @@ const serializedStructuredData = structuredData
|
|||||||
<>
|
<>
|
||||||
{publishedTime && <meta property="article:published_time" content={publishedTime.toISOString()} />}
|
{publishedTime && <meta property="article:published_time" content={publishedTime.toISOString()} />}
|
||||||
{updatedTime && <meta property="article:modified_time" content={updatedTime.toISOString()} />}
|
{updatedTime && <meta property="article:modified_time" content={updatedTime.toISOString()} />}
|
||||||
{author && <meta property="article:author" content={author} />}
|
{authorUrl && <meta property="article:author" content={authorUrl} />}
|
||||||
{tags?.map((tag) => <meta property="article:tag" content={tag} />)}
|
{tags?.map((tag) => <meta property="article:tag" content={tag} />)}
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -53,7 +53,6 @@ const structuredData = {
|
|||||||
ogType="article"
|
ogType="article"
|
||||||
publishedTime={pubDate}
|
publishedTime={pubDate}
|
||||||
updatedTime={updatedDate ?? pubDate}
|
updatedTime={updatedDate ?? pubDate}
|
||||||
author={author}
|
|
||||||
tags={tags}
|
tags={tags}
|
||||||
structuredData={structuredData}
|
structuredData={structuredData}
|
||||||
>
|
>
|
||||||
|
|||||||
Reference in new issue
Block a user