From 0225d3076b6032bd9165d289a76d861daee2a8b8 Mon Sep 17 00:00:00 2001 From: Julien Calixte Date: Sat, 19 Nov 2022 16:19:39 +0100 Subject: [PATCH] extract Post to module post --- src/hooks/usePosts.hook.ts | 25 +----- src/layouts/post.vue | 11 +++ src/modules/post/entities/Post.ts | 18 +++++ src/pages/posts/feature-factory.mdx | 2 +- .../posts/introduction-to-smart-notes.md | 9 ++- .../posts/make-your-environment-loopy.md | 77 +++++++++++++++++++ 6 files changed, 114 insertions(+), 28 deletions(-) create mode 100644 src/modules/post/entities/Post.ts create mode 100644 src/pages/posts/make-your-environment-loopy.md diff --git a/src/hooks/usePosts.hook.ts b/src/hooks/usePosts.hook.ts index df40041..22e473e 100644 --- a/src/hooks/usePosts.hook.ts +++ b/src/hooks/usePosts.hook.ts @@ -1,23 +1,6 @@ +import { Post } from "@/modules/post/entities/Post" import { computed } from "vue" -interface Post { - filename: string - lastUpdated: Date - href: string - title: string - date: Date - meta: { - filename: string - lastUpdated: Date - href: string - } - frontmatter: { - title: string - publishedAt?: Date - } - draft?: boolean -} - const byMostRecentFirst = (a: Post, b: Post) => { if (!b.date) { return 1 @@ -33,9 +16,5 @@ const byMostRecentFirst = (a: Post, b: Post) => { export const usePosts = () => { const posts = $(useDocuments("@/pages/posts")) - return computed(() => - posts - .filter((post) => import.meta.env.DEV || post.draft !== true) - .sort(byMostRecentFirst) - ) + return computed(() => posts.sort(byMostRecentFirst)) } diff --git a/src/layouts/post.vue b/src/layouts/post.vue index e260c33..2ec8290 100644 --- a/src/layouts/post.vue +++ b/src/layouts/post.vue @@ -1,7 +1,13 @@ + +