added read time on index and post pages

This commit is contained in:
2022-09-29 22:28:06 +02:00
parent 619758c175
commit 6a9ceb9670
22 changed files with 103 additions and 50 deletions

View File

@@ -5,7 +5,6 @@ import { Link } from "gatsby";
import * as styles from "./Feed.module.scss";
import { Edge } from "@/types";
type Props = {
edges: Array<Edge>;
};
@@ -17,12 +16,14 @@ const Feed: React.FC<Props> = ({ edges }: Props) => (
<div className={styles.meta}>
<time
className={styles.time}
dateTime={new Date(edge.node.frontmatter.date).toLocaleDateString(
"en-US",
{ year: "numeric", month: "long", day: "numeric" },
)}
dateTime={new Date(edge.node.frontmatter.date).toLocaleDateString("en-US", {
year: "numeric",
month: "long",
day: "numeric",
})}
>
{new Date(edge.node.frontmatter.date).toLocaleDateString("en-US", {
{new Date(edge.node.frontmatter.date).toLocaleDateString("en-Us", {
day: "numeric",
year: "numeric",
month: "long",
})}
@@ -39,11 +40,9 @@ const Feed: React.FC<Props> = ({ edges }: Props) => (
{edge.node.frontmatter.title}
</Link>
</h2>
<p className={styles.description}>
{edge.node.frontmatter.description}
</p>
<p className={styles.description}>{edge.node.frontmatter.description}</p>
<Link className={styles.more} to={edge.node.fields.slug}>
Read
Read ({edge.node.fields.readingTime?.text})
</Link>
</div>
))}

View File

@@ -7,7 +7,7 @@ exports[`Feed renders correctly 1`] = `
<time
dateTime="September 1, 2016"
>
September 2016
September 1, 2016
</time>
<span />
<span>
@@ -31,7 +31,8 @@ exports[`Feed renders correctly 1`] = `
<a
href="/posts/perfecting-the-art-of-perfection"
>
Read
Read (
)
</a>
</div>
<div>
@@ -39,7 +40,7 @@ exports[`Feed renders correctly 1`] = `
<time
dateTime="September 1, 2016"
>
September 2016
September 1, 2016
</time>
<span />
<span>
@@ -63,7 +64,8 @@ exports[`Feed renders correctly 1`] = `
<a
href="/posts/the-birth-of-movable-type"
>
Read
Read (
)
</a>
</div>
</div>