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:
Tony 2026-01-03 09:22:32 +08:00 committed by GitHub
parent 6b38e2ceeb
commit 9aa55f54af
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 2 additions and 5 deletions

View File

@ -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');