diff --git a/web/src/components/post/postInfo.astro b/web/src/components/post/postInfo.astro new file mode 100644 index 0000000..860b5d5 --- /dev/null +++ b/web/src/components/post/postInfo.astro @@ -0,0 +1,17 @@ +--- +import { getFormattedDate } from '@utils/date' +const { publishDate, readTime, tags } = Astro.props +--- + + | +{readTime} min. read | +{ + tags.map((tag, i) => ( + <> + + #{tag} + + {i < tags.length - 1 && ", "} + + )) +} \ No newline at end of file diff --git a/web/src/components/post/toc.astro b/web/src/components/post/toc.astro new file mode 100644 index 0000000..3766c41 --- /dev/null +++ b/web/src/components/post/toc.astro @@ -0,0 +1,56 @@ +--- + +--- + + + + \ No newline at end of file diff --git a/web/src/pages/posts/[slug].astro b/web/src/pages/posts/[slug].astro index 52b83eb..e7cb9c0 100644 --- a/web/src/pages/posts/[slug].astro +++ b/web/src/pages/posts/[slug].astro @@ -1,22 +1,22 @@ --- import Base from "@layout/Base"; -import { getFormattedDate } from "@utils/date"; +import PostInfo from "@components/post/postInfo"; +import TableOfContents from "@components/post/toc"; + import { calcReadTime } from '@utils/post' import { authPB } from "@utils/pocketbase"; + const { slug } = Astro.params export const prerender = false const pb = await authPB() - const post = await pb.collection('posts').getFirstListItem(`slug="${slug}"`) const { title, content, publishDate, description } = post - const headerImage = pb.files.getURL(post, post.headerImage) const wordCount = content.split(' ').length; const readTime = calcReadTime(wordCount); -const formattedPublishDate = getFormattedDate(publishDate); --- @@ -28,21 +28,13 @@ const formattedPublishDate = getFormattedDate(publishDate);

{description}

- | - {readTime} min. read | - { - post.tags.map((tag, i) => ( - <> - - #{tag} - - {i < post.tags.length - 1 && ", "} - - )) - } + - - + @@ -50,57 +42,10 @@ const formattedPublishDate = getFormattedDate(publishDate); - - - - \ No newline at end of file + \ No newline at end of file