igorskyflyer / npm-astro-post-excerpt

ā­ An Astro component that renders post excerpts for your Astro blog - directly from your Markdown and MDX files! šŸ’Ž Featured on Astro's official Integrations library: https://astro.build/integrations?search=igor.dvlpr šŸ˜
https://www.npmjs.com/package/@igor.dvlpr/astro-post-excerpt
MIT License
19 stars 2 forks source link

Boolean prop not valid - aborting. Error #34

Closed tjex closed 1 year ago

tjex commented 1 year ago

Hello, thanks for your plugin. Looks great, but unfortunately when trying to implement I'm getting the following error:

Screen Shot 2023-06-01 at 17 35 12

This is my loop for getting the static paths. ./[...page].astro:

export async function getStaticPaths({paginate}) {

    const posts = await getCollection('blog').then(posts =>
    posts
        .map(({ data, slug }) => ({
            slug: slug,
            title: data.title,
            description: data.description,
            pubDate: data.pubDate,
        }))
);
return paginate(posts, {pageSize: 10});

}

const seo = {
  title: 'Blog',
  description: 'Blog posts, essays, diaries, news and tutorials by tjex / Tillman Jex'
}

const { page } = Astro.props;
---

<Layout seo={seo} >
    <article class="blog-page-content__article">
      <section class="postlist">
        {page.data.map((post: any) => <BlogPostPreview post={post} />)}
      </section>
    </article>
    <Paginator page={page}/>
</Layout>

the post prop is beings passed into the BlogPostPreview component. It's in this component that I want to implement the post excerpt. ../../components/BlogPostPreview.astro:

---
import PostExcerpt from "@igor.dvlpr/astro-post-excerpt";
export interface Props {
    post: any;
}

const { post } = Astro.props;
---

<article class="post-preview">
    <a href={`/blog/${post.slug}`}>
        <h1 class="title">{post.title}</h1>
        <p class="description">{post.description}</p>
    </a>
    <p class="post-excerpt">
        <PostExcerpt {post} words={20} addEllipsis={false} />
    </p>
</article>

You can see here how the blog page looks normally (ie without the post-excerpt implementation): https://tjex.net/blog/

igorskyflyer commented 1 year ago

Sorry for the inconvenience and thanks for the interest in the component!

There was a major upgrade of Astro, where they switched to using Collections, which was implemented recently in my component as well. I tested the new implementation twice, in the test site of the component itself and in my personal blog, both work fine and I got some input from other devs using the component that everything works fine.

That being said, I need to take your sample code, test it locally and I'll get back to you with a solution. šŸ˜‰

tjex commented 1 year ago

great, thanks!

igorskyflyer commented 1 year ago

Sorry for the late reply, I was quite busy with work, I tried a few days ago and now again to reproduce your issue but couldn't.

Is there a complete sample repo/code for me to test it against? šŸ«¤

tjex commented 1 year ago

thanks for getting back. I'm in the middle of a few things myself. I'll try reimplementing your plugin on a separate branch of my website, which is on github and ping you here with a link when it's available. And if in the process I realise it's something on my end, I'll update here accordingly šŸ‘

igorskyflyer commented 1 year ago

thanks for getting back. I'm in the middle of a few things myself. I'll try reimplementing your plugin on a separate branch of my website, which is on github and ping you here with a link when it's available. And if in the process I realise it's something on my end, I'll update here accordingly šŸ‘

What I can tell you is that the error you're getting means that you didn't pass a valid post so the problem must be in the way you pass your posts to my component, most likely in your posts loop.

Hope that helps a bit, I look forward to fixing your issue when you set up the new branch. šŸ˜„

tjex commented 1 year ago

Heyo. Here's the branch where I've tried reimplementing the plugin: https://github.com/tjex/tjex.net/tree/post-preview

Implementation is here: https://github.com/tjex/tjex.net/blob/post-preview/src/pages/blog/%5B...page%5D.astro

igorskyflyer commented 1 year ago

Heyo. Here's the branch where I've tried reimplementing the plugin: https://github.com/tjex/tjex.net/tree/post-preview

Implementation is here: https://github.com/tjex/tjex.net/blob/post-preview/src/pages/blog/%5B...page%5D.astro

Great, I'll be working on it tonight, thanks šŸ˜

tjex commented 1 year ago

thanks again :)