Fix type error in blog-multiple-authors example (#1553)

* chore: add description to avoid type error

* fix: fix canonical url type in main head component
This commit is contained in:
Yoshiaki Togami 2021-10-15 03:40:33 +09:00 committed by GitHub
parent 7e4f91db60
commit 32dbf68247
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 9 additions and 4 deletions

View file

@ -6,7 +6,7 @@ export interface Props {
type?: string;
next?: string;
prev?: string;
canonicalURL?: string;
canonicalURL?: string | URL;
}
const { title, description, image, type, next, prev, canonicalURL } = Astro.props as Props;

View file

@ -4,12 +4,13 @@ import Nav from '../components/Nav.astro';
import authorData from '../data/authors.json';
const { content } = Astro.props;
let canonicalURL = Astro.request.canonicalURL;
---
<html lang={ content.lang || 'en' }>
<head>
<title>{content.title}</title>
<MainHead title={content.title} description={content.description} image={content.image} canonicalURL={Astro.request.canonicalURL} />
<MainHead title={content.title} description={content.description} image={content.image} canonicalURL={canonicalURL} />
<style lang="scss">
.title {
margin-top: 4rem;

View file

@ -3,12 +3,15 @@ import MainHead from '../components/MainHead.astro';
import Nav from '../components/Nav.astro';
let title = "About";
let description = "About page of an example blog on Astro";
let canonicalURL = Astro.request.canonicalURL;
---
<html lang="en">
<head>
<MainHead
title={title}
canonicalURL={Astro.request.canonicalURL}
description={description}
canonicalURL={canonicalURL}
/>
<style lang="scss">

View file

@ -18,6 +18,7 @@ interface MarkdownFrontmatter {
// All variables are available to use in the HTML template below.
let title = 'Dons Blog';
let description = 'An example blog on Astro';
let canonicalURL = Astro.request.canonicalURL;
// Data Fetching: List all Markdown posts in the repo.
let allPosts = Astro.fetchContent<MarkdownFrontmatter>('./post/*.md');
@ -34,7 +35,7 @@ let firstPage = allPosts.slice(0, 2);
title={title}
description={description}
image={allPosts[0].image}
canonicalURL={Astro.request.canonicalURL.href}
canonicalURL={canonicalURL}
/>
</head>