Move site to a prop instead of directly importing from within the component. (#803)

This commit is contained in:
Caleb Jasik 2021-07-22 19:08:45 -05:00 committed by GitHub
parent debbc18708
commit 7b600d597b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 3 deletions

View file

@ -1,6 +1,10 @@
---
import { site } from '../config.ts';
const { content = {}, canonicalURL } = Astro.props;
export interface Props {
content: any,
site: any,
canonicalURL: URL | string,
};
const { content = {}, site, canonicalURL } = Astro.props;
const formattedContentTitle = content.title ? `${content.title} 🚀 ${site.title}` : site.title;
const imageSrc = content?.image?.src ?? site.image.src;
const canonicalImageSrc = new URL(imageSrc, Astro.site);

View file

@ -23,7 +23,7 @@ if (currentPage) {
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{content.title ? `${content.title} 🚀 ${site.title}` : site.title}</title>
<MetaData {content} canonicalURL={Astro.request.canonicalURL}/>
<MetaData {content} {site} canonicalURL={Astro.request.canonicalURL}/>
<!-- This is intentionally inlined to avoid FOUC -->
<script>