Skip to content

Commit

Permalink
Merge pull request #547 from shibomb/fix/ogp-url-default-img
Browse files Browse the repository at this point in the history
Fix: ogp url, ogp image url and default ogp image file.
  • Loading branch information
limzykenneth authored Oct 8, 2024
2 parents d1cae09 + e23bf7b commit 1a1bb0a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
1 change: 1 addition & 0 deletions astro.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ if (shouldSkipCompress) {

// https://astro.build/config
export default defineConfig({
site: 'https://p5js.org',
integrations: [
preact({
compat: true,
Expand Down
Binary file added public/assets/img/p5js.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 6 additions & 3 deletions src/components/Head/index.astro
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ interface Props {
const {
title,
featuredImageSrc = "/favicon.svg",
featuredImageSrc = "/assets/img/p5js.png",
locale,
description,
} = Astro.props;
Expand All @@ -28,6 +28,9 @@ const t = await getUiTranslator(locale);
const localizedTitle = t(title) as string;
const localizedDescription =
description || (t("briefPageDescriptions", title) as string);
const rootUrl = new URL('/', process.env.NODE_ENV === "production" ? Astro.site : Astro.url.href);
const ogpImageSrc = new URL(featuredImageSrc, rootUrl);
---

<head>
Expand All @@ -38,14 +41,14 @@ const localizedDescription =
<meta name="description" content={localizedDescription} />
<meta property="og:title" content={title} />
<meta property="og:description" content={localizedDescription} />
<meta property="og:image" content={featuredImageSrc} />
<meta property="og:image" content={ogpImageSrc} />
<meta property="og:url" content={Astro.url.href} />
<meta property="og:type" content="website" />
<meta property="og:locale" content={localeContentMap[locale]} />
<meta name="twitter:card" content="summary_large_image" />
<meta name="twitter:site" content="@p5xjs" />
<meta name="twitter:title" content={title} />
<meta name="twitter:description" content={localizedDescription} />
<meta name="twitter:image" content={featuredImageSrc} />
<meta name="twitter:image" content={ogpImageSrc} />
<meta name="twitter:url" content={Astro.url.href} />
</head>

0 comments on commit 1a1bb0a

Please sign in to comment.