-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d0c95d4
commit e610924
Showing
7 changed files
with
66 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import getReadingTime from "reading-time" | ||
import { toString } from "mdast-util-to-string" | ||
|
||
export function remarkReadingTime() { | ||
return function (tree, { data }) { | ||
const textOnPage = toString(tree) | ||
const readingTime = getReadingTime(textOnPage) | ||
// readingTime.text will give us minutes read as a friendly string, | ||
// i.e. "3 min read" | ||
data.astro.frontmatter.minutesRead = readingTime.text | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
--- | ||
const { title, url } = Astro.props | ||
const { title, url, minutesRead, pubDate } = Astro.props | ||
--- | ||
|
||
<li><a href={url}>{title}</a></li> | ||
<li> | ||
<a href={url}>{title}</a> <br /> | ||
approximately {minutesRead}, published {pubDate.slice(0,10)} | ||
</li> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,14 @@ | ||
--- | ||
import Layout from "../layouts/Layout.astro" | ||
import BlogPost from "../components/BlogPost.astro" | ||
const allPosts = await Astro.glob("../pages/posts/*.mdx") | ||
const pageTitle = "bitbloxhub's blog" | ||
--- | ||
<Layout title={pageTitle}> | ||
<main class="m-auto p-6 max-w-6xl text-left"> | ||
<h1>bitbloxhub's blog!</h1> | ||
<ul class="text-base"> | ||
{allPosts.map((post) => <li ><a href={post.url}>{post.frontmatter.title}</a></li>)} | ||
{allPosts.map((post) => <BlogPost url={post.url} title={post.frontmatter.title} minutesRead={post.frontmatter.minutesRead} pubDate={post.frontmatter.pubDate} />)} | ||
</ul> | ||
</main> | ||
</Layout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters