Remove debug instrumentation and unused webmentions lib
All checks were successful
Deploy / deploy (push) Successful in 1m18s

Drop the hidden data-webmentions-debug div, the console.log in
astro.config.mjs, and src/lib/webmentions.ts (which was superseded by
the inline fetch in Webmentions.astro).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
Adrian Altner 2026-04-22 03:18:41 +02:00
parent 7de0a815f4
commit df59a1405f
3 changed files with 7 additions and 143 deletions

View file

@ -31,15 +31,9 @@ interface Props {
const { target, locale = getLocaleFromUrl(Astro.url) ?? DEFAULT_LOCALE } = Astro.props;
interface FetchResult {
mentions: WMEntry[];
debug: string;
}
async function fetchMentions(target: string): Promise<FetchResult> {
async function fetchMentions(target: string): Promise<WMEntry[]> {
const token = WEBMENTION_TOKEN;
const tokenLen = typeof token === 'string' ? token.length : 0;
if (!token) return { mentions: [], debug: `no-token(len=${tokenLen})` };
if (!token) return [];
const withSlash = target.endsWith('/') ? target : `${target}/`;
const withoutSlash = target.replace(/\/+$/, '');
const fetchOne = async (t: string) => {
@ -48,27 +42,24 @@ async function fetchMentions(target: string): Promise<FetchResult> {
url.searchParams.set('token', token);
url.searchParams.set('per-page', '100');
const res = await fetch(url);
if (!res.ok) return { entries: [] as WMEntry[], status: res.status };
if (!res.ok) return [] as WMEntry[];
const json = (await res.json()) as { children?: WMEntry[] };
return { entries: json.children ?? [], status: 200 };
return json.children ?? [];
};
const [a, b] = await Promise.all([fetchOne(withSlash), fetchOne(withoutSlash)]);
const seen = new Set<number>();
const merged: WMEntry[] = [];
for (const m of [...a.entries, ...b.entries]) {
for (const m of [...a, ...b]) {
const id = m['wm-id'];
if (id == null || seen.has(id)) continue;
seen.add(id);
merged.push(m);
}
return {
mentions: merged,
debug: `ok(len=${tokenLen}) slash=${a.status}:${a.entries.length} noslash=${b.status}:${b.entries.length}`,
};
return merged;
}
const targetStr = target.toString();
const { mentions: all, debug: fetchDebug } = await fetchMentions(targetStr);
const all = await fetchMentions(targetStr);
const likes = all.filter((m) => m['wm-property'] === 'like-of');
const reposts = all.filter((m) => m['wm-property'] === 'repost-of');
@ -95,8 +86,6 @@ function formatDate(iso?: string) {
const hasAny = facepile.length > 0 || replies.length > 0 || mentions.length > 0;
---
<div data-webmentions-debug data-target={targetStr} data-fetch={fetchDebug} data-all={all.length} data-facepile={facepile.length} data-hasany={String(hasAny)} hidden></div>
{
hasAny && (
<section class="webmentions" aria-labelledby="webmentions-heading">