Difference between revisions of "Widget:Homepage"
From LINKS Community Center
Line 114: | Line 114: | ||
})); | })); | ||
− | + | const logoUrlQuery = '/api.php?action=query&format=json&prop=imageinfo&iiprop=url&titles=' + | |
encodeURIComponent(sources.map(source => source.image).join('|')); | encodeURIComponent(sources.map(source => source.image).join('|')); | ||
− | + | const logoUrlResponse = await fetch(logoUrlQuery).then(response => response.json()); | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
+ | Object.getOwnPropertyNames(logoUrlResponse.query.pages).forEach(pageId => { | ||
+ | const logoFileName = logoUrlResponse.query.pages[pageId].title; | ||
+ | const logoUrl = logoUrlResponse.query.pages[pageId].imageinfo[0].url; | ||
+ | sources[sources.findIndex(source => source.image === logoFileName)].image = logoUrl; | ||
+ | }); | ||
+ | console.log(sources) | ||
} | } | ||
Revision as of 14:18, 2 June 2022
Development verstion of the DCT Homepage.
Not ready for production!