just some cleanup to remove the "landing page" post from other locations
This commit is contained in:
parent
7b0a215b20
commit
ac8a448325
|
@ -1,13 +1,27 @@
|
|||
---
|
||||
import PostHero from "../components/PostHero.astro";
|
||||
import PostFooter from "../components/PostFooter.astro";
|
||||
import {invariant, type Post, type Settings } from "@matthiesenxyz/astro-ghostcms/api";
|
||||
import { getFeaturedPosts, invariant, type Post, type Settings } from "@matthiesenxyz/astro-ghostcms/api";
|
||||
export type Props = {
|
||||
post: Post;
|
||||
settings: Settings;
|
||||
posts: Post[];
|
||||
};
|
||||
|
||||
const { post, settings, posts } = Astro.props as Props;
|
||||
|
||||
async function getPostsSet(){
|
||||
const featuredPosts = await getFeaturedPosts();
|
||||
const fposts = posts;
|
||||
if(featuredPosts.posts.length === 0){ return fposts }
|
||||
else {
|
||||
const featured = featuredPosts.posts[0]
|
||||
return fposts.filter((p: Post)=>p.id !== featured.id)
|
||||
}
|
||||
}
|
||||
|
||||
const mPosts = await getPostsSet()
|
||||
|
||||
invariant(settings, "Settings not found");
|
||||
---
|
||||
|
||||
|
@ -15,5 +29,5 @@ invariant(settings, "Settings not found");
|
|||
<div id="ghostimport" class="mt-4 text-ctp-subtext1">
|
||||
<Fragment set:html={post.html} />
|
||||
</div>
|
||||
<PostFooter post={post} settings={settings} posts={posts} />
|
||||
<PostFooter post={post} settings={settings} posts={mPosts} />
|
||||
|
||||
|
|
|
@ -26,14 +26,8 @@ invariant(settings, "Settings are required");
|
|||
|
||||
<Container>
|
||||
|
||||
{
|
||||
post.primary_author && (
|
||||
<Post
|
||||
post={post}
|
||||
settings={settings}
|
||||
posts={posts}
|
||||
/>
|
||||
|
||||
{ post.primary_author && (
|
||||
<Post post={post} settings={settings} posts={posts} />
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
@ -3,17 +3,30 @@ import type { InferGetStaticParamsType, InferGetStaticPropsType } from 'astro';
|
|||
import Container from "../../components/container.astro";
|
||||
import Layout from "../../layouts/Layout.astro";
|
||||
import AuthorDetailCard from '../../components/AuthorDetailCard.astro';
|
||||
import { getAllPosts, getAllAuthors, getSettings, invariant } from "@matthiesenxyz/astro-ghostcms/api";
|
||||
import { getFeaturedPosts, getAllPosts, getAllAuthors, getSettings, invariant, type Post, type Author } from "@matthiesenxyz/astro-ghostcms/api";
|
||||
import PostPreviewList from '../../components/PostPreviewList.astro';
|
||||
|
||||
export async function getStaticPaths() {
|
||||
export async function cleanPosts(){
|
||||
const posts = await getAllPosts();
|
||||
const featuredPosts = await getFeaturedPosts();
|
||||
if(featuredPosts.posts.length === 0) {
|
||||
const notFeatured = posts;
|
||||
return notFeatured;
|
||||
} else {
|
||||
const featured = featuredPosts.posts[0]
|
||||
const notFeatured = posts.filter((post: Post) => post.id !== featured.id )
|
||||
return notFeatured;
|
||||
}
|
||||
}
|
||||
|
||||
export async function getStaticPaths() {
|
||||
const posts = await cleanPosts();
|
||||
const { authors } = await getAllAuthors();
|
||||
const settings = await getSettings();
|
||||
|
||||
return authors.map((author) => {
|
||||
const filteredPosts = posts.filter((post) =>
|
||||
post.authors?.map((author) => author.slug).includes(author.slug)
|
||||
return authors.map((author: Author) => {
|
||||
const filteredPosts = posts.filter((post: Post) =>
|
||||
post.authors?.map((author: Author) => author.slug).includes(author.slug)
|
||||
);
|
||||
return {
|
||||
params: { slug: author.slug },
|
||||
|
|
Loading…
Reference in New Issue