Change posts.js to blog.js and improve default values
This commit is contained in:
@ -5,14 +5,13 @@ import Layout from '~/layouts/PageLayout.astro';
|
||||
import BlogList from '~/components/blog/List.astro';
|
||||
import Pagination from '~/components/common/Pagination.astro';
|
||||
|
||||
import { fetchPosts } from '~/utils/posts';
|
||||
import { getCanonical, getPermalink, BLOG_BASE } from '~/utils/permalinks';
|
||||
import { fetchPosts } from '~/utils/blog';
|
||||
import { BLOG_BASE } from '~/utils/permalinks';
|
||||
import Title from '~/components/blog/Title.astro';
|
||||
|
||||
export async function getStaticPaths({ paginate }) {
|
||||
if (BLOG?.disabled || BLOG?.blog?.disabled) return [];
|
||||
const posts = await fetchPosts();
|
||||
return paginate(posts, {
|
||||
return paginate(await fetchPosts(), {
|
||||
params: { blog: BLOG_BASE || undefined },
|
||||
pageSize: BLOG.postsPerPage,
|
||||
});
|
||||
|
@ -5,8 +5,8 @@ import Layout from '~/layouts/PageLayout.astro';
|
||||
import BlogList from '~/components/blog/List.astro';
|
||||
import Pagination from '~/components/common/Pagination.astro';
|
||||
|
||||
import { fetchPosts } from '~/utils/posts';
|
||||
import { cleanSlug, CATEGORY_BASE } from '~/utils/permalinks';
|
||||
import { fetchPosts } from '~/utils/blog';
|
||||
import { CATEGORY_BASE } from '~/utils/permalinks';
|
||||
import Title from '~/components/blog/Title.astro';
|
||||
|
||||
export async function getStaticPaths({ paginate }) {
|
||||
@ -22,7 +22,7 @@ export async function getStaticPaths({ paginate }) {
|
||||
paginate(
|
||||
posts.filter((post) => typeof post.category === 'string' && category === post.category.toLowerCase()),
|
||||
{
|
||||
params: { category: cleanSlug(category), blog: CATEGORY_BASE || undefined },
|
||||
params: { category: category, blog: CATEGORY_BASE || undefined },
|
||||
pageSize: BLOG.postsPerPage,
|
||||
props: { category },
|
||||
}
|
||||
|
@ -5,16 +5,15 @@ import Layout from '~/layouts/PageLayout.astro';
|
||||
import SinglePost from '~/components/blog/SinglePost.astro';
|
||||
import ToBlogLink from '~/components/blog/ToBlogLink.astro';
|
||||
|
||||
import { getCanonical, getPermalink, cleanSlug, POST_BASE } from '~/utils/permalinks';
|
||||
import { fetchPosts } from '~/utils/posts';
|
||||
import { getCanonical, getPermalink, POST_BASE } from '~/utils/permalinks';
|
||||
import { fetchPosts } from '~/utils/blog';
|
||||
import { findImage } from '~/utils/images';
|
||||
|
||||
export async function getStaticPaths() {
|
||||
if (BLOG?.disabled || BLOG?.post?.disabled) return [];
|
||||
const posts = await fetchPosts();
|
||||
return posts.map((post) => ({
|
||||
return (await fetchPosts()).map((post) => ({
|
||||
params: {
|
||||
slug: cleanSlug(post.slug),
|
||||
slug: post.slug,
|
||||
blog: POST_BASE || undefined,
|
||||
},
|
||||
props: { post },
|
||||
|
@ -5,8 +5,8 @@ import Layout from '~/layouts/PageLayout.astro';
|
||||
import BlogList from '~/components/blog/List.astro';
|
||||
import Pagination from '~/components/common/Pagination.astro';
|
||||
|
||||
import { fetchPosts } from '~/utils/posts';
|
||||
import { getCanonical, getPermalink, cleanSlug, TAG_BASE } from '~/utils/permalinks';
|
||||
import { fetchPosts } from '~/utils/blog';
|
||||
import { TAG_BASE } from '~/utils/permalinks';
|
||||
import Title from '~/components/blog/Title.astro';
|
||||
|
||||
export async function getStaticPaths({ paginate }) {
|
||||
@ -22,7 +22,7 @@ export async function getStaticPaths({ paginate }) {
|
||||
paginate(
|
||||
posts.filter((post) => Array.isArray(post.tags) && post.tags.find((elem) => elem.toLowerCase() === tag)),
|
||||
{
|
||||
params: { tag: cleanSlug(tag), blog: TAG_BASE || undefined },
|
||||
params: { tag: tag, blog: TAG_BASE || undefined },
|
||||
pageSize: BLOG.postsPerPage,
|
||||
props: { tag },
|
||||
}
|
||||
|
Reference in New Issue
Block a user