Skip to content

Commit

Permalink
Pass in microcopy
Browse files Browse the repository at this point in the history
  • Loading branch information
Sam Richard committed Jul 8, 2024
1 parent e4171c4 commit b1cd531
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
4 changes: 2 additions & 2 deletions site/src/components/ReadingTime.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
export let body: PortableTextBlock[];
export let label = 'Reading time';
export let duration = `{{n}} minutes`;
export let duration = `((n)) minutes`;
export let wrapper = 'div';
const { minutes } = readingTime(toPlainText(body));
const length = duration.replace('{{n}}', `${Math.ceil(minutes)}`);
const length = duration.replace('((n))', `${Math.ceil(minutes)}`);
</script>

<svelte:element this={wrapper} class="extras-section">
Expand Down
6 changes: 5 additions & 1 deletion site/src/layouts/views/Post.astro
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,11 @@ const showUpdated =
<!-- Author Info -->
<Authors {...authors} />
<!-- Reading Time -->
<ReadingTime body={post.body} />
<ReadingTime
body={post.body}
label={microcopy.meta?.readtime}
duration={microcopy.tutorials.minutes}
/>
<!-- Published date info -->
<Published
locale={locale.code}
Expand Down
1 change: 1 addition & 0 deletions site/types/sanity.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,7 @@ export type Microcopy = {
};
meta: {
authored: string;
readtime: string;
toc: string;
updated: string;
posted: string;
Expand Down

0 comments on commit b1cd531

Please sign in to comment.