diff --git a/lib/model/content/model.ts b/lib/model/content/model.ts index fd2ec8cf0..a216460c2 100644 --- a/lib/model/content/model.ts +++ b/lib/model/content/model.ts @@ -136,11 +136,11 @@ export const isNuxtContentResult = ( export const queryNuxtContent = async ( $content: Context['$content'], - route: Context['route'], year?: string, month?: string, ): Promise => { let contents: INuxtContentResult[] = [] + let db: INuxtContentInstance /** * Bookmarks: * - https://github.com/techfort/LokiJS/wiki/Query-Examples#find-queries @@ -152,7 +152,14 @@ export const queryNuxtContent = async ( * - http://localhost:3000/_content/blog?deep=true * - http://localhost:3000/_content/blog?deep=true&created_defined=asdf */ - const db = $content('blog', { deep: true }) + if (year && month) { + db = $content('blog', year, month, { deep: true }) + } else if (year) { + db = $content('blog', year, { deep: true }) + } else { + db = $content('blog', { deep: true }) + } + db = db .sortBy('createdAt', 'desc') .only([ 'createdAt', @@ -168,9 +175,6 @@ export const queryNuxtContent = async ( ]) contents = await db.fetch() - contents = contents.filter((a) => - findExcludingRedirectPredicate(a as INuxtContentResult), - ) return contents } diff --git a/pages/blog/_year/_month/_slug.vue b/pages/blog/_year/_month/_slug.vue index 3239534d9..116170363 100644 --- a/pages/blog/_year/_month/_slug.vue +++ b/pages/blog/_year/_month/_slug.vue @@ -72,7 +72,6 @@ class="my-10" :prev="prev" :next="next" - style="display: none" /> diff --git a/pages/blog/_year/_month/index.vue b/pages/blog/_year/_month/index.vue index e4aa16867..ccd0f3d9e 100644 --- a/pages/blog/_year/_month/index.vue +++ b/pages/blog/_year/_month/index.vue @@ -35,12 +35,11 @@ components: { 'blog-list-model-by-year': BlogListModelByYear, }, - async asyncData({ $content, route, params }) { + async asyncData({ $content, params }) { let contents: INuxtContentIndexResult[] = [] try { contents = await queryNuxtContent( $content, - route, params.year, params.month, ) diff --git a/pages/blog/_year/index.vue b/pages/blog/_year/index.vue index 9901a3ca0..f3ca79178 100644 --- a/pages/blog/_year/index.vue +++ b/pages/blog/_year/index.vue @@ -35,10 +35,10 @@ components: { 'blog-list-model-by-year': BlogListModelByYear, }, - async asyncData({ $content, route, params }) { + async asyncData({ $content, params }) { let contents: INuxtContentIndexResult[] = [] try { - contents = await queryNuxtContent($content, route, params.year) + contents = await queryNuxtContent($content, params.year) } catch (_) { // .. } diff --git a/pages/blog/index.vue b/pages/blog/index.vue index 65f9c6f98..b571d29b2 100644 --- a/pages/blog/index.vue +++ b/pages/blog/index.vue @@ -43,9 +43,9 @@ components: { 'blog-list-model-by-year': BlogListModelByYear, }, - async asyncData({ $content, route }) { + async asyncData({ $content }) { let contents: INuxtContentIndexResult[] = [] - contents = await queryNuxtContent($content, route) + contents = await queryNuxtContent($content) return { contents, pageTitle: 'Blog',