fix: clean url for use in metadata

This commit is contained in:
Ben Schlegel 2024-02-23 15:48:11 +01:00
parent 35ed47db35
commit e64f2e7e0a
No known key found for this signature in database
GPG Key ID: 8BDB8891C1575E22

View File

@ -136,6 +136,10 @@ export default (() => {
ogImagePath = `https://${cfg.baseUrl}/static/${frontmatterImgUrl}`
}
// Url of current page
const socialUrl =
fileData.slug === "404" ? url.toString() : joinSegments(url.toString(), fileData.slug!)
return (
<head>
<title>{title}</title>
@ -172,8 +176,8 @@ export default (() => {
<meta name="twitter:image" content={ogImagePath} />
<meta property="og:image" content={ogImagePath} />
<meta property="twitter:domain" content={cfg.baseUrl}></meta>
<meta property="og:url" content={`https://${cfg.baseUrl}/${fileData.slug}`}></meta>
<meta property="twitter:url" content={`https://${cfg.baseUrl}/${fileData.slug}`}></meta>
<meta property="og:url" content={socialUrl}></meta>
<meta property="twitter:url" content={socialUrl}></meta>
</>
)}
<link rel="icon" href={iconPath} />