EDIT It turned out everything works correctly, the images were assigned to posts that were moved to trash and as soon as I delete the posts the issue disappeared. Not sure what the issue is now.
Hi guys I’m quite new here, I just discovered this project and it looks amazing. I’m trying to create a parent page with a list of subpages and I think more or less I found out how to do, I’m prefetching everything in a beforeSSR action in my theme. For now I need this on a single specific page so for now I’m hardcoding url and id, if I can do better I’m happy to improve.
I’ll share what I’ve done so far since it might be useful to understand better and I believe it might be useful for others since I struggled a little to understand how to achieve this.
const marsTheme = {
name: "@frontity/mars-theme",
roots: {...},
state: {...},
/**
* Actions are functions that modify the state or deal with other parts of
* Frontity like libraries.
*/
actions: {
theme: {
beforeSSR: async ({ state, actions, libraries }) => {
// prefetch extra content from dummy holder page
const response = await libraries.source.api.get({
endpoint: "pages",
params: {
_embed: true,
parent: 33, // This is the hardcoded parent id
},
});
const res = await response.json();
// add the content to our data
Object.assign(state.source.data[state.router.link], {
childrenPages: res.sort((a, b) => a.menu_order - b.menu_order),
isPageWithChildren: true,
});
await Promise.all(
res.map((r) => actions.source.fetch(`/my-specific-url/${r.slug}`))
);
} else if (state.router.link.includes("/my-specific-url/")) {
await actions.source.fetch(state.router.link);
Object.assign(state.source.data[state.router.link], {
isChildPage: true,
});
}
},
},
libraries: { ... }
}
So first question does the above makes sense? Do you think it can be improved?
My real question is about images because right now images are not being loaded because I think those pages are not included in any other list, so I’m trying to figure out how to load the feature images. Any hints?
Thank you!
P.S. This is the page I’m trying to build and all the boxes below are supposed to have a feature image but for some reason the image is not loaded. I Nostri Corsi - Il Dedalo 🌿 Soul Space I’m wondering if the issue is elsewhere since the image will not be loaded even when I’m visiting the page.