search for standard sites pub-search.waow.tech
search zig blog atproto

refactor: use server-provided url field in frontend

remove buildDocUrl function and docUrl callbacks from PLATFORM_CONFIG.
frontend now reads doc.url directly from the API response (-72 lines).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

+8 -72
+8 -72
site/index.html
··· 986 986 for (const doc of results) { 987 987 const entityType = doc.type || 'article'; 988 988 const plat = doc.platform || 'leaflet'; 989 - const docUrl = buildDocUrl(doc, entityType, plat); 989 + const docUrl = doc.url || null; 990 990 const platformConfig = PLATFORM_CONFIG[plat]; 991 991 const platformBadge = platformConfig 992 992 ? `<span class="platform-badge" onclick="event.stopPropagation(); setPlatform('${escapeHtml(plat)}')" style="cursor:pointer">${escapeHtml(platformConfig.label)}</span>` ··· 1130 1130 return `"${escaped}"`; 1131 1131 } 1132 1132 1133 - // platform-specific URL patterns 1134 - // note: some platforms use basePath from publication, which we prefer 1135 - // fallback docUrl() is used when basePath is missing 1136 1133 const PLATFORM_CONFIG = { 1137 - leaflet: { 1138 - home: 'https://leaflet.pub', 1139 - label: 'leaflet.pub', 1140 - // leaflet uses did/rkey pattern for fallback URLs 1141 - docUrl: (did, rkey) => `https://leaflet.pub/p/${did}/${rkey}` 1142 - }, 1143 - pckt: { 1144 - home: 'https://pckt.blog', 1145 - label: 'pckt.blog', 1146 - // pckt uses blog slugs + path, not did/rkey - needs basePath from publication 1147 - docUrl: null 1148 - }, 1149 - offprint: { 1150 - home: 'https://offprint.app', 1151 - label: 'offprint.app', 1152 - // offprint is in early beta, URL pattern unknown 1153 - docUrl: null 1154 - }, 1155 - greengale: { 1156 - home: 'https://greengale.app', 1157 - label: 'greengale.app', 1158 - // greengale uses basePath + path pattern 1159 - docUrl: null 1160 - }, 1161 - whitewind: { 1162 - home: 'https://whtwnd.com', 1163 - label: 'whtwnd.com', 1164 - docUrl: (did, rkey) => `https://whtwnd.com/${did}/${rkey}` 1165 - }, 1166 - other: { 1167 - home: 'https://standard.site', 1168 - label: 'other', 1169 - // "other" = site.standard.* documents not from a known platform 1170 - docUrl: null 1171 - }, 1134 + leaflet: { home: 'https://leaflet.pub', label: 'leaflet.pub' }, 1135 + pckt: { home: 'https://pckt.blog', label: 'pckt.blog' }, 1136 + offprint: { home: 'https://offprint.app', label: 'offprint.app' }, 1137 + greengale: { home: 'https://greengale.app', label: 'greengale.app' }, 1138 + whitewind: { home: 'https://whtwnd.com', label: 'whtwnd.com' }, 1139 + other: { home: 'https://standard.site', label: 'other' }, 1172 1140 }; 1173 - 1174 - function buildDocUrl(doc, entityType, platform) { 1175 - if (entityType === 'publication') { 1176 - return doc.basePath ? `https://${doc.basePath}` : null; 1177 - } 1178 - 1179 - // Platform-specific URL patterns: 1180 - // 1. Leaflet: basePath + rkey (e.g., https://dad.leaflet.pub/3mburumcnbs2m) 1181 - if (platform === 'leaflet' && doc.basePath && doc.rkey) { 1182 - return `https://${doc.basePath}/${doc.rkey}`; 1183 - } 1184 - 1185 - // 2. pckt: basePath + path (e.g., https://devlog.pckt.blog/some-slug-abc123) 1186 - if (platform === 'pckt' && doc.basePath && doc.path) { 1187 - const separator = doc.path.startsWith('/') ? '' : '/'; 1188 - return `https://${doc.basePath}${separator}${doc.path}`; 1189 - } 1190 - 1191 - // 3. Other platforms with path: basePath + path 1192 - if (doc.basePath && doc.path) { 1193 - const separator = doc.path.startsWith('/') ? '' : '/'; 1194 - return `https://${doc.basePath}${separator}${doc.path}`; 1195 - } 1196 - 1197 - // 5. Platform-specific fallback URL (e.g., leaflet.pub/p/did/rkey) 1198 - const config = PLATFORM_CONFIG[platform]; 1199 - if (config?.docUrl && doc.did && doc.rkey) { 1200 - return config.docUrl(doc.did, doc.rkey); 1201 - } 1202 - 1203 - return null; 1204 - } 1205 1141 1206 1142 function getPlatformHome(platform, basePath) { 1207 1143 if (basePath) { ··· 1633 1569 1634 1570 const items = filtered.map(doc => { 1635 1571 const platform = doc.platform || 'leaflet'; 1636 - const url = buildDocUrl(doc, doc.type || 'article', platform); 1572 + const url = doc.url || null; 1637 1573 return url 1638 1574 ? `<a href="${url}" target="_blank" class="related-item">${escapeHtml(doc.title || 'Untitled')}</a>` 1639 1575 : `<span class="related-item">${escapeHtml(doc.title || 'Untitled')}</span>`;