This commit is contained in:
@@ -71,9 +71,15 @@
|
||||
|
||||
function normaliseHref(href, prefix) {
|
||||
if (!href || href.startsWith("http") || href.startsWith("#")) return null;
|
||||
if (href.startsWith("/")) return href;
|
||||
const base = (prefix || "").replace(/\/$/, "");
|
||||
if (!base || href.startsWith(base + "/")) return href;
|
||||
return href.startsWith("/") ? base + href : base + "/" + href;
|
||||
return base + "/" + href;
|
||||
}
|
||||
|
||||
function isTagLink(a) {
|
||||
const href = a.getAttribute("href") || "";
|
||||
return href.includes("/tags/") || Boolean(a.querySelector(".post-tag"));
|
||||
}
|
||||
|
||||
function extractLinks(doc, max, prefix) {
|
||||
@@ -82,6 +88,8 @@
|
||||
const links = doc.querySelectorAll("#content li a[href], .org-ul li a[href], ul li a[href]");
|
||||
|
||||
for (const a of links) {
|
||||
if (isTagLink(a)) continue;
|
||||
|
||||
const href = normaliseHref(a.getAttribute("href"), prefix);
|
||||
const title = a.textContent.trim();
|
||||
if (!href || !title || seen.has(href)) continue;
|
||||
|
||||
Reference in New Issue
Block a user