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 PostHero from "../components/PostHero.astro";
|
||||||
import PostFooter from "../components/PostFooter.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 = {
|
export type Props = {
|
||||||
post: Post;
|
post: Post;
|
||||||
settings: Settings;
|
settings: Settings;
|
||||||
posts: Post[];
|
posts: Post[];
|
||||||
};
|
};
|
||||||
|
|
||||||
const { post, settings, posts } = Astro.props as Props;
|
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");
|
invariant(settings, "Settings not found");
|
||||||
---
|
---
|
||||||
|
|
||||||
|
@ -15,5 +29,5 @@ invariant(settings, "Settings not found");
|
||||||
<div id="ghostimport" class="mt-4 text-ctp-subtext1">
|
<div id="ghostimport" class="mt-4 text-ctp-subtext1">
|
||||||
<Fragment set:html={post.html} />
|
<Fragment set:html={post.html} />
|
||||||
</div>
|
</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>
|
<Container>
|
||||||
|
|
||||||
{
|
{ post.primary_author && (
|
||||||
post.primary_author && (
|
<Post post={post} settings={settings} posts={posts} />
|
||||||
<Post
|
|
||||||
post={post}
|
|
||||||
settings={settings}
|
|
||||||
posts={posts}
|
|
||||||
/>
|
|
||||||
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,17 +3,30 @@ import type { InferGetStaticParamsType, InferGetStaticPropsType } from 'astro';
|
||||||
import Container from "../../components/container.astro";
|
import Container from "../../components/container.astro";
|
||||||
import Layout from "../../layouts/Layout.astro";
|
import Layout from "../../layouts/Layout.astro";
|
||||||
import AuthorDetailCard from '../../components/AuthorDetailCard.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';
|
import PostPreviewList from '../../components/PostPreviewList.astro';
|
||||||
|
|
||||||
export async function getStaticPaths() {
|
export async function cleanPosts(){
|
||||||
const posts = await getAllPosts();
|
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 { authors } = await getAllAuthors();
|
||||||
const settings = await getSettings();
|
const settings = await getSettings();
|
||||||
|
|
||||||
return authors.map((author) => {
|
return authors.map((author: Author) => {
|
||||||
const filteredPosts = posts.filter((post) =>
|
const filteredPosts = posts.filter((post: Post) =>
|
||||||
post.authors?.map((author) => author.slug).includes(author.slug)
|
post.authors?.map((author: Author) => author.slug).includes(author.slug)
|
||||||
);
|
);
|
||||||
return {
|
return {
|
||||||
params: { slug: author.slug },
|
params: { slug: author.slug },
|
||||||
|
|
Loading…
Reference in New Issue