#Cannot read properties of undefined (reading ‘title’)

1 messages · Page 1 of 1 (latest)

severe vault
#

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? I followed all the instructions on the Astro website.

pine prism
#

The snippet does look fine to me, can you share the repo if its feasible?

severe vault
#

It's on github as a private repository, I can share it with you if you like

gusty garden
#

Not sure, haven't look in deep, but isn't the issue here?

const allPosts = await Astro.glob('./article/*/*.md');

Doesn't look like there is any article folder.

severe vault
#

I actually solved it. {frontmatter.title} doesn't work for markdown files, only .astro

mellow crestBOT
#
If your issue is resolved, please help by doing the following two steps:
  1. From the ellipses (3-dot menu) in the top-right corner of the post (not the first message), edit the tags to include the Solved tag.
  2. From the same ellipses, select Close Post.
    Your post will still be available to search and can be re-opened simply by replying in it. Closing a post moves it down with older posts, so we can more easily focus on issues that still need to be resovled.
    Thank you for your help!