Error flags on the line of my layout containing {frontmatter.title}
This is the frontmatter for the BaseLayoutNoAuthor page:
const {frontmatter} = Astro.props;
And the page that seems to be causing these issues reads as follows:
---
import BaseLayoutNoAuthor from "../../../../layouts/BaseLayoutNoAuthor.astro";
const pageTitle="---";
const allPosts = await Astro.glob('./article/*/*.md');
---
<BaseLayoutNoAuthor pageTitle={pageTitle}>
<ul>
{allPosts.map((post) =>
<li><a href={post.url}>{post.frontmatter.title}</a><br/>
{post.frontmatter.author}, {post.frontmatter.pubDate}<br/>
{post.frontmatter.description}</li>)}
</ul>
</BaseLayoutNoAuthor>
Any idea what might be going wrong?
Your issue seems to be unrelated to Netlify’s systems and instead specific to working with Astro, so you may be better off reaching out to their community.
From a general error perspective, if you log what post
is (or allPosts
) you will find that post.frontmatter
really is undefined
.
You would then need to determine why and adjust.
Make sure to run the same build command you’re running on Netlify on your local system too.
It’s usually much easier to debug things locally.
Once your build runs properly locally, you can expect it to also run correctly on Netlify.
From a general error perspective, if you log what post
is (or allPosts
) you will find that post.frontmatter
really is undefined
.
You would then need to determine why and adjust.
I’m sorry but I know absolutely nothing about code. If I had the money to hire someone, I would. Is it possibly you could elaborate on this? I followed the instructions on Astro’s website but it seems I’ve run into a dead end.
Unfortunately you may need to seek assistance elsewhere just as this forum isn’t for general coding assistance it’s for help with Netlify.
I mean if you did a console.log( allPosts )
or console.log( post )
to output what they contain.
If you’re unfamiliar see: https://www.w3schools.com/jsref/met_console_log.asp
It’s just a way for you to confirm to yourself what is actually in the variable.
Again, since it’s specifically Astro code you’re working with, you may be better off reaching out to them: