If you use the default document template in @podium/layout to handle podlet assets, you should be able to handle multiple podlets and a single podlet in same way.
There is a incoming.podlets property which sets the JS and CSS accordingly, but it only supports an array of podlet responses. So for a single podlet you'll have to set .css and .js.
app.get('/', async (req, res) => {
const incoming = res.locals.podium;
// If we have a single podlet
const result = await podlet.fetch(incoming);
incoming.js = result.js;
incoming.css = result.css;
res.podiumSend(result.content);
// If we have multiple podlets
const responses = await Promise.all([podlet1.fetch(incoming), podlet2.fetch(incoming)];
incoming.podlets = responses;
res.podiumSend(responses[0].content + responses[1].content);
});
We should change incoming.podlets so it also handles a single podlet response, not just an array.
If you use the default document template in
@podium/layout
to handle podlet assets, you should be able to handle multiple podlets and a single podlet in same way.There is a
incoming.podlets
property which sets the JS and CSS accordingly, but it only supports an array of podlet responses. So for a single podlet you'll have to set.css
and.js
.We should change
incoming.podlets
so it also handles a single podlet response, not just an array.