diff --git a/astro.config.mjs b/astro.config.mjs index 544ca53..45039ef 100644 --- a/astro.config.mjs +++ b/astro.config.mjs @@ -69,7 +69,7 @@ export default defineConfig({ "recipes/base-url", "recipes/root-dir", "recipes/pretty-urls", - "recipes/wikilinks", + "recipes/md-wikilinks", ], }, { diff --git a/src/content/docs/recipes/md-wikilinks.md b/src/content/docs/recipes/md-wikilinks.md new file mode 100644 index 0000000..b4d5e06 --- /dev/null +++ b/src/content/docs/recipes/md-wikilinks.md @@ -0,0 +1,41 @@ +--- +title: Markdown Wikilinks +--- + +## Relevant CLI Flags + +Lychee provides a built-in `WikilinkResolver` to check Wikilinks in Markdown Files. This `WikilinkResolver` indexes all files in a given directory (incl. available subdirectories) by their filenames. +Symlinks are ignored during this procedure. +It then tries to resolve the extracted Wikilinks by looking up the Wikilink in the created index. + +Both Extraction and Resolving are **deactivated by default**. + +For checking Wikilinks please specify the following CLI Flags: + +- `--include-wikilinks` to enable the extraction of Wikilinks +- `--base-url /path/to/your/directory` where the `WikilinkResolver` should start indexing +- `--fallback-extensions`, e.g. `--fallback-extensions md, mdx` + +:::note[Good to know] +Because Wikilinks do not include a file extension, lychee needs you to specify the extensions you are using with `--fallback-extensions` +::: + +Summed up the following command might be a good starting point to check for the existance of files used by Wikilinks: + +```bash +lychee --include-wikilinks \ +--base-url /path/to/your/local/directory \ +--fallback-extensions md,mdx . +``` + +## Link Renaming + +Some tools provide a possibility to rename Wikilinks by specifying the alternative title after a so-called pothole: `|`. Lets have a look at an example: + +```Markdown +[[Filename|Alternative Title]] +[[Filename|Another Alternative Title]] +``` + +Both Wikilinks will be displayed with their alternative titles but link to the same file. +Lychee tries to resolve these Links by stripping away the alternative title and resolving by the remaining Filename only. diff --git a/src/content/docs/recipes/wikilinks.md b/src/content/docs/recipes/wikilinks.md deleted file mode 100644 index 37015c4..0000000 --- a/src/content/docs/recipes/wikilinks.md +++ /dev/null @@ -1,26 +0,0 @@ ---- -title: Wikilinks ---- - -lychee can check Wikilinks in Markdown files as long as they provide a path to the linked ressource. - -```markdown -# ✅ Good - links can be checked - -[[https://example.com/docs/]] -[[./another/markdown/file.md]] - -# ❌ Bad - Will not work - -[[another-markdown-page]] -``` - -Tools like e.g. [Obsidian](https://obsidian.md/) use the second (bad) form of link, using only the file name without path or file extension. - -lychee has no possibility of determining the correct path for this file as it could be: - -- in the same directory -- in a subdirectory -- in a parent directory - -A recursive search of all those options is currently not supported.