Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: ogp path #339

Merged
merged 1 commit into from Oct 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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