Hey, I’ve been building a custom Blog Post widget that shows x amount of the latest posts and updates the data in a repeater element.
I’ve managed to get the title and excerpt from the blog posts but I have not figured out how to get the link to the post as well as the cover image.
My page script:
$w.onReady(async function () {
const postData = await queryBlogPosts();
$w("#repeater").onItemReady((item, itemData, i) => {
item("#posttitle").text = itemData.title;
item("#postdescription").text = itemData.excerpt;
item("#postimage").src = itemData.media.wixMedia.image;
});
$w("#repeater").data = postData;
});
I’ve tried to use “itemData.media.wixMedia.image” and “itemData.coverMedia.image” to retrieve the cover image without any success.
I get image links like this: wix:image://v1/RANDOMNUMBERSANDLETTERS~mv2.png#originWidth=1920&originHeight=1005
My backend script:
export async function queryBlogPosts() {
try {
const result = await posts.queryPosts().eq("en", language).limit(8).find();
return result.items;
} catch (error) {
console.log(error);
}
}
I’ve not found any post link from the data I get with the backend script and the image does not work.
Does anyone have a solution to this?