@@ -6,6 +6,7 @@ import ThemeSettings from '../components/ThemeSettings.astro';
66import type { CollectionEntry } from ' astro:content' ;
77import { getPostTitle } from ' ../utils/content' ;
88import { getPostComputedMetadataById } from ' ../utils/postMetadata' ;
9+ import { getReadingTime } from ' ../utils/readingTime' ;
910import { render } from ' astro:content' ;
1011
1112export interface Props {
@@ -15,6 +16,7 @@ export interface Props {
1516
1617const { entry, relatedPosts = [] } = Astro .props ;
1718const { title : frontmatterTitle, description, author, date, tags, readTime } = entry .data ;
19+ const effectiveReadTime = readTime ?? getReadingTime (entry .body ?? ' ' );
1820const title = frontmatterTitle || getPostTitle (entry );
1921const { Content } = await render (entry );
2022
@@ -47,12 +49,12 @@ const structuredData = {
4749 <h1 >{ title } </h1 >
4850 <p class =" post-meta" >
4951 { tags .length > 0 && <TagList tags = { tags } />}
50- { tags .length > 0 && (author || effectiveDate || readTime ) && <span class = " meta-separator" >·</span >}
52+ { tags .length > 0 && (author || effectiveDate || effectiveReadTime ) && <span class = " meta-separator" >·</span >}
5153 { author && <span >by { author } </span >}
52- { author && (effectiveDate || readTime ) && <span class = " meta-separator" >·</span >}
54+ { author && (effectiveDate || effectiveReadTime ) && <span class = " meta-separator" >·</span >}
5355 { effectiveDate && <time datetime = { effectiveDate .toISOString ()} >{ effectiveDate .toLocaleDateString ()} </time >}
54- { effectiveDate && readTime && <span class = " meta-separator" >·</span >}
55- { readTime && <span >{ readTime } </span >}
56+ { effectiveDate && effectiveReadTime && <span class = " meta-separator" >·</span >}
57+ { effectiveReadTime && <span >{ effectiveReadTime } </span >}
5658 </p >
5759 </header >
5860 <div class =" content" >
0 commit comments