mirror of
https://github.com/morten-olsen/morten-olsen.github.io.git
synced 2026-02-07 17:36:29 +01:00
add reading time
This commit is contained in:
committed by
Morten Olsen
parent
86a9dc2d31
commit
5e1324adf5
@@ -21,6 +21,9 @@ const getSiteInfo = () => {
|
|||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
...getSiteInfo(),
|
...getSiteInfo(),
|
||||||
output: 'static',
|
output: 'static',
|
||||||
|
server: {
|
||||||
|
allowedHosts: true,
|
||||||
|
},
|
||||||
integrations: [mdx(), sitemap(), icon(), compress({
|
integrations: [mdx(), sitemap(), icon(), compress({
|
||||||
HTML: false,
|
HTML: false,
|
||||||
}), robotsTxt()],
|
}), robotsTxt()],
|
||||||
|
|||||||
@@ -3,7 +3,9 @@ import { profile } from "./data.profile";
|
|||||||
|
|
||||||
class Posts {
|
class Posts {
|
||||||
#map = (post: CollectionEntry<'posts'>) => {
|
#map = (post: CollectionEntry<'posts'>) => {
|
||||||
|
const readingTime = Math.ceil(post.body?.split(/\s+/g).length / 200) || 1;
|
||||||
return Object.assign(post, {
|
return Object.assign(post, {
|
||||||
|
readingTime,
|
||||||
jsonLd: {
|
jsonLd: {
|
||||||
'@context': 'https://schema.org',
|
'@context': 'https://schema.org',
|
||||||
'@type': 'BlogPosting',
|
'@type': 'BlogPosting',
|
||||||
|
|||||||
@@ -35,7 +35,13 @@ const jsonLd = await profile.getJsonLd();
|
|||||||
/>
|
/>
|
||||||
</a>
|
</a>
|
||||||
<a class="title" href={`/posts/${post.id}`}><h3>{post.data.title}</h3></a>
|
<a class="title" href={`/posts/${post.id}`}><h3>{post.data.title}</h3></a>
|
||||||
<div class="subtitle"><AbsoluteTime datetime={post.data.pubDate} /></div>
|
<div class="subtitle">
|
||||||
|
<AbsoluteTime
|
||||||
|
datetime={post.data.pubDate}
|
||||||
|
format={{ month: "long", day: "numeric", year: "numeric" }}
|
||||||
|
/>
|
||||||
|
{" "}• {post.readingTime} min read
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user