diff --git a/src/components/Webmentions.astro b/src/components/Webmentions.astro index 82cbd24..47e6e55 100644 --- a/src/components/Webmentions.astro +++ b/src/components/Webmentions.astro @@ -30,9 +30,12 @@ interface FetchResult { } async function fetchMentions(target: string): Promise { - const token = import.meta.env.WEBMENTION_TOKEN; - const tokenLen = typeof token === 'string' ? token.length : 0; - if (!token) return { mentions: [], debug: `no-token(len=${tokenLen})` }; + const importMetaToken = import.meta.env.WEBMENTION_TOKEN; + const processToken = typeof process !== 'undefined' ? process.env.WEBMENTION_TOKEN : undefined; + const token = importMetaToken || processToken; + const iLen = typeof importMetaToken === 'string' ? importMetaToken.length : 0; + const pLen = typeof processToken === 'string' ? processToken.length : 0; + if (!token) return { mentions: [], debug: `no-token(iml=${iLen},pe=${pLen})` }; const withSlash = target.endsWith('/') ? target : `${target}/`; const withoutSlash = target.replace(/\/+$/, ''); const fetchOne = async (t: string) => { @@ -56,7 +59,7 @@ async function fetchMentions(target: string): Promise { } return { mentions: merged, - debug: `len=${tokenLen} slash=${a.status}:${a.entries.length} noslash=${b.status}:${b.entries.length}`, + debug: `iml=${iLen} pe=${pLen} slash=${a.status}:${a.entries.length} noslash=${b.status}:${b.entries.length}`, }; }