mirror of
https://github.com/gkd-kit/docs.git
synced 2024-11-16 04:32:19 +08:00
feat: enhance HTML transformation to handle root-relative links
This commit is contained in:
parent
53d3df502f
commit
cc14590e5c
|
@ -87,5 +87,11 @@ export const transformHtml = (code: string) => {
|
|||
e.setAttribute(attr, mirrorBaseUrl + e.getAttribute(attr));
|
||||
});
|
||||
});
|
||||
doc.querySelectorAll('link[href^="/"]').forEach((e) => {
|
||||
const href = e.getAttribute('href');
|
||||
if (href && href.lastIndexOf('/') === 0) {
|
||||
e.setAttribute('href', mirrorBaseUrl + href);
|
||||
}
|
||||
});
|
||||
return doc.documentElement.outerHTML;
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue
Block a user