Skip to content

Commit

Permalink
Merge pull request #339 from korosuke613/fix-ogp
Browse files Browse the repository at this point in the history
fix: ogp path
  • Loading branch information
korosuke613 committed Oct 1, 2023
2 parents bb77efe + ad69c54 commit 61bed97
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
3 changes: 1 addition & 2 deletions src/pages/posts/[...slug].astro
Expand Up @@ -2,7 +2,6 @@
import { getCollection } from 'astro:content';
import type { CollectionEntry } from 'astro:content';
import * as path from 'node:path';
import { ContentPost } from '@/partials/ContentPost';
import Base from '@/templates/Base.astro';
import { AppConfig } from '@/utils/AppConfig';
Expand Down Expand Up @@ -39,7 +38,7 @@ const filePath = `src/content/posts/${entry.id}`;
const histories = await getCommitHistories(filePath);
const ogpUrl = entry.data.imgSrc
? path.join('https://korosuke613.dev/', entry.data.imgSrc)
? new URL(entry.data.imgSrc, 'https://korosuke613.dev/').toString()
: undefined;
---

Expand Down
6 changes: 3 additions & 3 deletions src/pages/posts/dormitory_introduction.astro
Expand Up @@ -68,10 +68,10 @@ const similars = getSimilarPosts(
const filePath = 'src/pages/posts/dormitory_introduction.astro';
const histories = await getCommitHistories(filePath);
const ogpUrl = path.join(
'https://korosuke613.dev/',
const ogpUrl = new URL(
Static.DormitoryIntroduction.data.imgSrc!,
);
'https://korosuke613.dev/',
).toString();
---

<Base
Expand Down
5 changes: 4 additions & 1 deletion src/templates/Base.astro
Expand Up @@ -27,7 +27,10 @@ const twitterCardType = Astro.props.head.ogpUrl
: 'summary';
const ogpUrl = Astro.props.head.ogpUrl
? Astro.props.head.ogpUrl
: path.join('https://korosuke613.dev/', 'assets/images/my_icon_2.png');
: new URL(
'assets/images/my_icon_2.png',
'https://korosuke613.dev/',
).toString();
const rssLink = path.join(AppConfig.base, 'rss.xml');
const faviconLink = path.join(AppConfig.base, 'favicon.ico');
Expand Down

0 comments on commit 61bed97

Please sign in to comment.