-
Notifications
You must be signed in to change notification settings - Fork 79
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
Sam Richard
committed
Jul 8, 2024
1 parent
69dd4a6
commit e4171c4
Showing
4 changed files
with
35 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<script lang="ts"> | ||
import readingTime from 'reading-time'; | ||
import { toPlainText } from 'astro-portabletext/utils'; | ||
import type { PortableTextBlock } from '@sanity/types'; | ||
export let body: PortableTextBlock[]; | ||
export let label = 'Reading time'; | ||
export let duration = `{{n}} minutes`; | ||
export let wrapper = 'div'; | ||
const { minutes } = readingTime(toPlainText(body)); | ||
const length = duration.replace('{{n}}', `${Math.ceil(minutes)}`); | ||
</script> | ||
|
||
<svelte:element this={wrapper} class="extras-section"> | ||
<h4 class="type--label">{label}</h4> | ||
<p class="type--h6">{length}</p> | ||
</svelte:element> | ||
|
||
<style> | ||
.type--h6 { | ||
font-weight: 400; | ||
} | ||
</style> |
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