fix(route/patreon): use Patreon API (#20803)
* fix(route/patreon): support creator under /cw/ * fix(route/patreon): improve regex * fix(route/patreon): streamline creator data extraction from Patreon API
This commit is contained in:
parent
6b38e2ceeb
commit
9aa55f54af
|
|
@ -123,13 +123,10 @@ async function handler(ctx) {
|
|||
const ogImage = $('meta[property="og:image"]').attr('content');
|
||||
const creatorId = decodeURIComponent(ogImage || '').match(/card-teaser-image\/creator\/(\d+?)\?/)?.[1];
|
||||
if (creatorId) {
|
||||
const creator = await ofetch(`${baseUrl}/api/campaigns/${creatorId}`);
|
||||
return {
|
||||
id: creatorId,
|
||||
attributes: {
|
||||
name: $('meta[property="og:title"]').attr('content'),
|
||||
creation_name: $('meta[name="description"]').attr('content'),
|
||||
avatar_photo_url: $('link[rel="preload"][as="image"]').attr('href') || ogImage,
|
||||
},
|
||||
attributes: creator.data.attributes,
|
||||
};
|
||||
}
|
||||
throw new Error('Unable to extract creator ID');
|
||||
|
|
|
|||
Loading…
Reference in New Issue