Skip to content

Commit

Permalink
fix: duplicate transition id
Browse files Browse the repository at this point in the history
  • Loading branch information
jxlpzqc committed Apr 5, 2024
1 parent a451b20 commit bee138d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
5 changes: 3 additions & 2 deletions pages/src/components/Card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,21 @@ import { slugifyStr } from "@utils/slugify";
import type { CollectionEntry } from "astro:content";

export interface Props {
id?: string;
href?: string;
frontmatter: CollectionEntry<"posts">["data"];
secHeading?: boolean;
body?: string;
}

export default function Card({ href, frontmatter, secHeading = true, body }: Props) {
export default function Card({ id, href, frontmatter, secHeading = true, body }: Props) {
const {
title,
status,
} = frontmatter;

const headerProps = {
style: { viewTransitionName: slugifyStr(title) },
style: { viewTransitionName: slugifyStr(id) },
className: "text-lg font-medium decoration-dashed hover:underline",
};

Expand Down
4 changes: 3 additions & 1 deletion pages/src/layouts/PostDetails.astro
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ export interface Props {
const { post } = Astro.props;
const { id } = post;
const { title, author, collected_date, collector, translated_date, translator, link, proofreader, proofread_date, publisher, published_date } = post.data;
const { Content } = await post.render();
Expand Down Expand Up @@ -51,7 +53,7 @@ const layoutProps = {
</button>
</div>
<main id="main-content">
<h1 transition:name={slugifyStr(title)} class="post-title">{title}</h1>
<h1 transition:name={slugifyStr(id)} class="post-title">{title}</h1>
<!-- <Datetime -->
<!-- pubDatetime={pubDatetime} -->
<!-- modDatetime={modDatetime} -->
Expand Down
4 changes: 2 additions & 2 deletions pages/src/layouts/Posts.astro
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ function getStyle(tabStatus: string) {
</nav>
<ul>
{
paginatedPosts.map(({ data, slug, body }) => (
<Card href={`/posts/${slug}/`} frontmatter={data} body={body} />
paginatedPosts.map(({ id, data, slug, body }) => (
<Card id={id} href={`/posts/${slug}/`} frontmatter={data} body={body} />
))
}
</ul>
Expand Down

0 comments on commit bee138d

Please sign in to comment.