Skip to content

Commit

Permalink
各記事でdescriptionが正しく設定されるように
Browse files Browse the repository at this point in the history
  • Loading branch information
tunamaguro committed May 5, 2023
1 parent e843bc7 commit e0f8630
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
9 changes: 8 additions & 1 deletion app/src/layouts/BaseLayout.astro
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,21 @@
import { Layout } from "@/components/Layout";
import Seo from "@/components/Seo/index.astro";
interface Props {
title?: string;
description?: string;
}
const { description, title } = Astro.props;
const siteTitle = "tunamaguro's blog";
const author = "tunamaguro";
---

<!DOCTYPE html>
<html lang="ja">
<head>
<Seo />
<Seo title={title} description={description} />
</head>
<body>
<Layout siteTitle={siteTitle} author={author}>
Expand Down
14 changes: 9 additions & 5 deletions app/src/layouts/MdLayout.astro
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
---
import type { MDXLayoutProps, MarkdownLayoutProps } from "astro";
import type { CollectionEntry } from "astro:content";
type Props = {
frontmatter: CollectionEntry<"article">["data"];
};
type Props = MarkdownLayoutProps<CollectionEntry<"article">["data"]>;
import BaseLayout from "./BaseLayout.astro";
import { MdDetail } from "@/components/MdDetail";
import { getMarkdownExcerpt } from "@/server/getMarkdownExcerpt";
const { frontmatter, rawContent } = Astro.props;
const { frontmatter } = Astro.props;
// もしrawContentがなかったデフォルトのdescriptionを使用する
const description = getMarkdownExcerpt(rawContent?.() ?? "") || undefined;
---

<BaseLayout>
<BaseLayout title={frontmatter.title} description={description}>
<MdDetail
title={frontmatter.title}
emoji={frontmatter.emoji}
Expand Down

0 comments on commit e0f8630

Please sign in to comment.