From 63bae44c1c6a80eeb4f8f4ef95af554b789bc1e9 Mon Sep 17 00:00:00 2001 From: kmacoders Date: Sun, 4 Jul 2021 15:16:30 +0700 Subject: [PATCH] fix: deep folder --- content/blog/{ => 2020}/a-blue-bird.md | 2 +- .../blog/{ => 2020}/optimize-your-website.md | 2 +- content/blog/2020/vue/deep-folder.md | 23 +++++++++++++++++++ .../{ => 2021}/first-blog-post-ehandy copy.md | 2 +- .../blog/{ => 2021}/first-blog-post-ehandy.md | 2 +- content/blog/{ => 2021}/how-to-code.md | 2 +- .../{ => 2021}/learn-nuxt-from-scratch.md | 2 +- .../{ => 2021}/placeholder-image-shopify.md | 2 +- content/blog/{ => 2021}/shopify-partner.md | 2 +- pages/blog/page/_page.vue | 2 +- utils/getContent.js | 6 +++-- 11 files changed, 36 insertions(+), 11 deletions(-) rename content/blog/{ => 2020}/a-blue-bird.md (97%) rename content/blog/{ => 2020}/optimize-your-website.md (97%) create mode 100644 content/blog/2020/vue/deep-folder.md rename content/blog/{ => 2021}/first-blog-post-ehandy copy.md (97%) rename content/blog/{ => 2021}/first-blog-post-ehandy.md (97%) rename content/blog/{ => 2021}/how-to-code.md (97%) rename content/blog/{ => 2021}/learn-nuxt-from-scratch.md (97%) rename content/blog/{ => 2021}/placeholder-image-shopify.md (97%) rename content/blog/{ => 2021}/shopify-partner.md (97%) diff --git a/content/blog/a-blue-bird.md b/content/blog/2020/a-blue-bird.md similarity index 97% rename from content/blog/a-blue-bird.md rename to content/blog/2020/a-blue-bird.md index b862388..bbf5d35 100644 --- a/content/blog/a-blue-bird.md +++ b/content/blog/2020/a-blue-bird.md @@ -3,7 +3,7 @@ title: How to code description: 'Empower your NuxtJS application with @nuxt/content module: write in a content/ directory and fetch your Markdown, JSON, YAML and CSV files through a MongoDB like API, acting as a Git-based Headless CMS.' image: 'http://placekitten.com/g/1920/1080' tags: ['VueJS', 'Nuxt'] -published: '2020-07-12' +published: '2020-02-12' --- ## Getting started diff --git a/content/blog/optimize-your-website.md b/content/blog/2020/optimize-your-website.md similarity index 97% rename from content/blog/optimize-your-website.md rename to content/blog/2020/optimize-your-website.md index 3ced8dd..2d24043 100644 --- a/content/blog/optimize-your-website.md +++ b/content/blog/2020/optimize-your-website.md @@ -3,7 +3,7 @@ title: Optimize your website description: 'Empower your NuxtJS application with @nuxt/content module: write in a content/ directory and fetch your Markdown, JSON, YAML and CSV files through a MongoDB like API, acting as a Git-based Headless CMS.' image: 'http://placekitten.com/g/1920/1080' tags: ['VueJS', 'Nuxt'] -published: '2020-06-30' +published: '2020-03-30' --- ## Getting started diff --git a/content/blog/2020/vue/deep-folder.md b/content/blog/2020/vue/deep-folder.md new file mode 100644 index 0000000..43d55aa --- /dev/null +++ b/content/blog/2020/vue/deep-folder.md @@ -0,0 +1,23 @@ +--- +title: Deep folder Vue +description: 'Empower your NuxtJS application with @nuxt/content module: write in a content/ directory and fetch your Markdown, JSON, YAML and CSV files through a MongoDB like API, acting as a Git-based Headless CMS.' +image: 'http://placekitten.com/g/1920/1080' +tags: ['VueJS'] +published: '2020-01-12' +--- + +## Getting started + +Empower your NuxtJS application with `@nuxtjs/content` module: write in a `content/` directory and fetch your Markdown, JSON, YAML and CSV files through a MongoDB like API, acting as a **Git-based Headless CMS**. + +## Writing content + +Learn how to write your `content/`, supporting Markdown, YAML, CSV and JSON: https://content.nuxtjs.org/writing. + +## Fetching content + +Learn how to fetch your content with `$content`: https://content.nuxtjs.org/fetching. + +## Displaying content + +Learn how to display your Markdown content with the `` component directly in your template: https://content.nuxtjs.org/displaying. diff --git a/content/blog/first-blog-post-ehandy copy.md b/content/blog/2021/first-blog-post-ehandy copy.md similarity index 97% rename from content/blog/first-blog-post-ehandy copy.md rename to content/blog/2021/first-blog-post-ehandy copy.md index ad0fe88..a3bddcf 100644 --- a/content/blog/first-blog-post-ehandy copy.md +++ b/content/blog/2021/first-blog-post-ehandy copy.md @@ -3,7 +3,7 @@ title: Fisrt Blog Post eHandy description: 'Empower your NuxtJS application with @nuxt/content module: write in a content/ directory and fetch your Markdown, JSON, YAML and CSV files through a MongoDB like API, acting as a Git-based Headless CMS.' image: 'http://placekitten.com/g/1920/1080' tags: ['VueJS', 'Nuxt'] -published: '2021-06-30' +published: '2021-01-30' --- ## Getting started diff --git a/content/blog/first-blog-post-ehandy.md b/content/blog/2021/first-blog-post-ehandy.md similarity index 97% rename from content/blog/first-blog-post-ehandy.md rename to content/blog/2021/first-blog-post-ehandy.md index 594b468..e807a07 100644 --- a/content/blog/first-blog-post-ehandy.md +++ b/content/blog/2021/first-blog-post-ehandy.md @@ -3,7 +3,7 @@ title: Fisrt Blog Post eHandy description: 'Empower your NuxtJS application with @nuxt/content module: write in a content/ directory and fetch your Markdown, JSON, YAML and CSV files through a MongoDB like API, acting as a Git-based Headless CMS.' image: 'https://cdn.emk.dev/templates/featured-image.png' tags: ['VueJS', 'Nuxt'] -published: '2021-06-30' +published: '2021-02-30' --- ## Getting started diff --git a/content/blog/how-to-code.md b/content/blog/2021/how-to-code.md similarity index 97% rename from content/blog/how-to-code.md rename to content/blog/2021/how-to-code.md index ad0fe88..4c504d9 100644 --- a/content/blog/how-to-code.md +++ b/content/blog/2021/how-to-code.md @@ -3,7 +3,7 @@ title: Fisrt Blog Post eHandy description: 'Empower your NuxtJS application with @nuxt/content module: write in a content/ directory and fetch your Markdown, JSON, YAML and CSV files through a MongoDB like API, acting as a Git-based Headless CMS.' image: 'http://placekitten.com/g/1920/1080' tags: ['VueJS', 'Nuxt'] -published: '2021-06-30' +published: '2021-03-30' --- ## Getting started diff --git a/content/blog/learn-nuxt-from-scratch.md b/content/blog/2021/learn-nuxt-from-scratch.md similarity index 97% rename from content/blog/learn-nuxt-from-scratch.md rename to content/blog/2021/learn-nuxt-from-scratch.md index 345f1f7..6f430c4 100644 --- a/content/blog/learn-nuxt-from-scratch.md +++ b/content/blog/2021/learn-nuxt-from-scratch.md @@ -3,7 +3,7 @@ title: Learn Nuxt from scratch description: 'Empower your NuxtJS application with @nuxt/content module: write in a content/ directory and fetch your Markdown, JSON, YAML and CSV files through a MongoDB like API, acting as a Git-based Headless CMS.' image: 'http://placekitten.com/g/1920/1080' tags: ['VueJS', 'Nuxt'] -published: '2021-09-30' +published: '2021-04-30' --- ## Getting started diff --git a/content/blog/placeholder-image-shopify.md b/content/blog/2021/placeholder-image-shopify.md similarity index 97% rename from content/blog/placeholder-image-shopify.md rename to content/blog/2021/placeholder-image-shopify.md index 0ea8b09..fe44b55 100644 --- a/content/blog/placeholder-image-shopify.md +++ b/content/blog/2021/placeholder-image-shopify.md @@ -3,7 +3,7 @@ title: Placeholder image shopify description: 'Empower your NuxtJS application with @nuxt/content module: write in a content/ directory and fetch your Markdown, JSON, YAML and CSV files through a MongoDB like API, acting as a Git-based Headless CMS.' image: 'http://placekitten.com/g/1920/1080' tags: ['VueJS', 'Nuxt'] -published: '2021-06-30' +published: '2021-05-30' --- ## Getting started diff --git a/content/blog/shopify-partner.md b/content/blog/2021/shopify-partner.md similarity index 97% rename from content/blog/shopify-partner.md rename to content/blog/2021/shopify-partner.md index 9ae3a55..30ee600 100644 --- a/content/blog/shopify-partner.md +++ b/content/blog/2021/shopify-partner.md @@ -3,7 +3,7 @@ title: Shopify partner description: 'Empower your NuxtJS application with @nuxt/content module: write in a content/ directory and fetch your Markdown, JSON, YAML and CSV files through a MongoDB like API, acting as a Git-based Headless CMS.' image: 'http://placekitten.com/g/1920/1080' tags: ['VueJS', 'Nuxt'] -published: '2021-06-30' +published: '2022-06-30' --- ## Getting started diff --git a/pages/blog/page/_page.vue b/pages/blog/page/_page.vue index 98f0235..be745e7 100644 --- a/pages/blog/page/_page.vue +++ b/pages/blog/page/_page.vue @@ -5,7 +5,7 @@

- +
diff --git a/utils/getContent.js b/utils/getContent.js index 269c4b8..dcd666f 100644 --- a/utils/getContent.js +++ b/utils/getContent.js @@ -4,7 +4,9 @@ export default async ($content, params, error, path) => { * Số items trên 1 page */ const perPage = 14 - const allArticles = await $content(path).fetch() + const allArticles = await $content(path, { deep: true }) + .sortBy('published', 'desc') + .fetch() const totalArticles = allArticles.length /** @@ -30,7 +32,7 @@ export default async ($content, params, error, path) => { /** * get items skip */ - const paginatedArticles = await $content(path) + const paginatedArticles = await $content(path, { deep: true }) .only(['title', 'description', 'image', 'slug', 'tags', 'published']) .sortBy('published', 'desc') .limit(perPage)