diff --git a/pages/[slug].js b/pages/[slug].js index 2aef842a..d245e2b4 100644 --- a/pages/[slug].js +++ b/pages/[slug].js @@ -14,7 +14,7 @@ import Related from '@/components/Post/Related' import LayoutArticle from '@/components/Layout/Article' -import { getPostBySlug, getAllPosts, getRelatedPost } from '@/lib/api' +import { getPostBySlug, getAllPosts, getRelatedPost, DEFAULT_FIELDS } from '@/lib/api' import { SITE_METADATA } from '@/lib/constants' export default function Post ({ post, related, preview }) { @@ -99,7 +99,7 @@ export async function getStaticProps ({ params }) { } export async function getStaticPaths () { - const posts = await getAllPosts(['slug']) + const posts = await getAllPosts(DEFAULT_FIELDS, 'id') return { paths: posts.map((post) => { diff --git a/pages/en/[slug].js b/pages/en/[slug].js index 3eda860d..a63484ca 100644 --- a/pages/en/[slug].js +++ b/pages/en/[slug].js @@ -14,7 +14,7 @@ import Related from '@/components/Post/Related' import LayoutArticle from '@/components/Layout/Article' -import { getPostBySlug, getAllPosts, getRelatedPost } from '@/lib/api' +import { getPostBySlug, getAllPosts, getRelatedPost, DEFAULT_FIELDS } from '@/lib/api' import { SITE_METADATA } from '@/lib/constants' export default function Post({ post, related, preview }) { @@ -98,7 +98,7 @@ export async function getStaticProps({ params }) { } export async function getStaticPaths() { - const posts = await getAllPosts(['slug'], 'en') + const posts = await getAllPosts(DEFAULT_FIELDS, 'en') return { paths: posts.map((post) => { diff --git a/scripts/rss-feed.js b/scripts/rss-feed.js index 67890579..9037dba7 100644 --- a/scripts/rss-feed.js +++ b/scripts/rss-feed.js @@ -2,7 +2,7 @@ const fs = require('fs') const path = require('path') const Feed = require('feed').Feed -const { getAllPosts } = require('../lib/api') +const { getAllPosts, DEFAULT_FIELDS } = require('../lib/api') const { getAllTils } = require('../lib/tils') const { SITE_METADATA } = require('../lib/constants') @@ -29,7 +29,7 @@ async function main () { }) const posts = await getAllPosts( - ['title', 'date', 'slug', 'author', 'coverImage', 'excerpt'], + DEFAULT_FIELDS, 'id' ) diff --git a/scripts/sitemap.js b/scripts/sitemap.js index 656beec9..3250ed3b 100644 --- a/scripts/sitemap.js +++ b/scripts/sitemap.js @@ -2,13 +2,13 @@ const fs = require('fs') const path = require('path') const nanositemap = require('nanositemap') -const { getAllPosts, getAllTags } = require('../lib/api') +const { getAllPosts, getAllTags, DEFAULT_FIELDS } = require('../lib/api') const { getAllTils } = require('../lib/tils') const { SITE_METADATA } = require('../lib/constants') async function main () { const sitemapObj = {} - const posts = await getAllPosts(['date', 'slug'], 'id') + const posts = await getAllPosts(DEFAULT_FIELDS, 'id') for (const post of posts) { sitemapObj[`/${post.slug}`] = {