mirror of
https://github.com/jackyzha0/quartz.git
synced 2025-12-24 21:34:06 -06:00
feat: add option to disable broken wikilinks
This commit is contained in:
parent
6d49d97559
commit
cddc258489
@ -41,6 +41,7 @@ export interface Options {
|
|||||||
enableYouTubeEmbed: boolean
|
enableYouTubeEmbed: boolean
|
||||||
enableVideoEmbed: boolean
|
enableVideoEmbed: boolean
|
||||||
enableCheckbox: boolean
|
enableCheckbox: boolean
|
||||||
|
disableBrokenWikilinks: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
const defaultOptions: Options = {
|
const defaultOptions: Options = {
|
||||||
@ -56,6 +57,7 @@ const defaultOptions: Options = {
|
|||||||
enableYouTubeEmbed: true,
|
enableYouTubeEmbed: true,
|
||||||
enableVideoEmbed: true,
|
enableVideoEmbed: true,
|
||||||
enableCheckbox: false,
|
enableCheckbox: false,
|
||||||
|
disableBrokenWikilinks: false,
|
||||||
}
|
}
|
||||||
|
|
||||||
const calloutMapping = {
|
const calloutMapping = {
|
||||||
@ -206,7 +208,7 @@ export const ObsidianFlavoredMarkdown: QuartzTransformerPlugin<Partial<Options>>
|
|||||||
|
|
||||||
return src
|
return src
|
||||||
},
|
},
|
||||||
markdownPlugins(_ctx) {
|
markdownPlugins(ctx) {
|
||||||
const plugins: PluggableList = []
|
const plugins: PluggableList = []
|
||||||
|
|
||||||
// regex replacements
|
// regex replacements
|
||||||
@ -275,6 +277,18 @@ export const ObsidianFlavoredMarkdown: QuartzTransformerPlugin<Partial<Options>>
|
|||||||
// otherwise, fall through to regular link
|
// otherwise, fall through to regular link
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// treat as broken link if slug not in ctx.allSlugs
|
||||||
|
if (opts.disableBrokenWikilinks) {
|
||||||
|
const slug = slugifyFilePath(fp as FilePath)
|
||||||
|
const exists = ctx.allSlugs && ctx.allSlugs.includes(slug)
|
||||||
|
if (!exists) {
|
||||||
|
return {
|
||||||
|
type: "html",
|
||||||
|
value: `<a class=\"internal broken\">${alias ?? fp}</a>`,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// internal link
|
// internal link
|
||||||
const url = fp + anchor
|
const url = fp + anchor
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user