-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
What is this post.url
?
#10657
Comments
Markdown files loaded with
You can read more here https://docs.astro.build/en/guides/imports/#import-type-utilities |
What is a rendered path of a file outside of pages folder? src/components/my-component.astro ---
// imports all files that end with `.md` in `./src/pages/post/`
const matches = import.meta.glob('../pages/post/*.md', { eager: true });
const posts = Object.values(matches);
---
<!-- Renders an <article> for the first 5 blog posts -->
<div>
{posts.slice(0, 4).map((post) => (
<article>
<h2>{post.frontmatter.title}</h2>
<p>{post.frontmatter.description}</p>
<a href={post.url}>Read more</a>
</article>
))}
</div> Comment at https://docs.astro.build/en/guides/imports/#astro-files says export interface AstroInstance {
/* The file path of this file */
file: string;
/* The URL for this file (if it is in the pages directory) */
url: string | undefined;
default: AstroComponentFactory;
} But https://docs.astro.build/en/guides/imports/#markdown-files doesn't have similar description. So, what does |
I think this example is assuming files in the The docs for I guess we could update the example to avoid using |
In the example of https://docs.astro.build/en/guides/markdown-content/#dynamic-jsx-like-expressions, the file itself is |
Yeah, I just think that’s a detail someone missed — probably the filename was added later without attention to the detail in the example content or something. |
Agreed, this seems to be a matter of fixing the file paths so that we're talking about pages within |
📚 Subject area/topic
Guides and recipes
📋 Page(s) affected (or suggested, for new content)
https://docs.astro.build/en/guides/markdown-content/#dynamic-jsx-like-expressions
📋 Description of content that is out-of-date or incorrect
src/pages/my-posts.astro
🖥️ Reproduction in StackBlitz (if reporting incorrect content or code samples)
'../posts/*.md'
isn't in pages folder. What is the URL should be? Did I miss something?The text was updated successfully, but these errors were encountered: