#Can't display fetched posts in Astro

39 messages · Page 1 of 1 (latest)

analog otter
#

Hello everyone! I am building my website in Astro An I'm having problems displaying the fetched posts. It seems that the posts are actually fetched, but the are not inserted into the HTML. I have made this stakoverflow question in which you can find a more detailed description of the problem: https://stackoverflow.com/questions/74648396/cant-display-fetched-posts-in-astrojs . Thanks in advance!

wild linden
#

you need to map frontmatter and Content

#

umm
did you passed
props ?

#

in the Project Thumbnail ?

river lichen
#

instead of /project-sample-img.jpg try putting ./project-sample-img.jpg

#

lmk if it works

analog otter
river lichen
analog otter
# wild linden umm did you passed props ?

yes! i passed them like this:
<Masonry title="grid">
{projects.map(
(project)=>{
console.log(project);
<ProjectThumbnail title={project.frontmatter.title} w_cols={project.frontmatter.width_cols} h_cols={project.frontmatter.height_cols} />
}
)}
</Masonry>

river lichen
#

maybe u missed that?

analog otter
#

how do I pass them? I was following the example in the astro documentation, do you have any resource i can check?, I am bit new to all this stuff ._.

river lichen
#

Just like u passed title and other props

analog otter
river lichen
#

In ur ProjectThumbnail component

wild linden
analog otter
#

yes, this is what the ProjectThumbnail component has inside:

analog otter
#

the image is static for the moment, but the weird thing is if the component is having empty props, it should be still rendered but it would look like this in the DOM: <ProjectThumbnail title="" h_cols="" w_cols=""/>

#

or am i wrong?

wild linden
#

btw
remove that projectThumbnail for a while ?

#

and debug with normal div ?

analog otter
#

i used this, but it is very weird that i do not get anything

#

even the static image is not being displayed

#

and the upper div does not get rendered too

wild linden
#

I think { } need a return statement ?

analog otter
#

seems that is the problem

analog otter
#

i just did :
{projects.map(
(project)=>{
console.log(project.frontmatter.title);
}
)}

#

and it prints the right values

analog otter
#

thanks so much for your help @wild linden 🌈