diff --git a/src/articles/cheat-sheets/index.md b/src/articles/cheat-sheets/index.md index 83b5c2e..cb4dacd 100644 --- a/src/articles/cheat-sheets/index.md +++ b/src/articles/cheat-sheets/index.md @@ -5,4 +5,4 @@ If you add an `index.md` into a directory, it will become a part of the breadcru Use it as overview for subpages of that directory: -- [Markdown cheat sheet](cheat-sheets/Markdown_cheat_sheet.md) - shows the markdown syntax. +- [Markdown cheat sheet](cheat-sheets/Markdown_cheat_sheet) - shows the markdown syntax. diff --git a/src/articles/index.md b/src/articles/index.md index 5edc5e1..82af569 100644 --- a/src/articles/index.md +++ b/src/articles/index.md @@ -7,4 +7,6 @@ Place the content of your *slim wiki* into this directory. Write it using Use the main page as overview and add links to subpages: - [Cheat Sheets](cheat-sheets) - You can add links to directories having a `index.md`. -- [Markdown cheat sheet](cheat-sheets/Markdown_cheat_sheet.md) - Or add direct a link to a markdown file. +- [Markdown cheat sheet](cheat-sheets/Markdown_cheat_sheet) - Or add direct a link to a markdown file. + +**Note:** The `.md` extension is optional when linking to markdown files. diff --git a/src/server/logic/Main.php b/src/server/logic/Main.php index a55a207..cd4c0df 100644 --- a/src/server/logic/Main.php +++ b/src/server/logic/Main.php @@ -12,10 +12,16 @@ class Main { $articleBaseDir = realpath(__DIR__ . '/../../articles') . '/'; $articleFilename = $articleBaseDir . implode('/', $requestPathArray); + // Support `index.md` for directories if (is_dir($articleFilename)) { $articleFilename = rtrim($articleFilename, '/') . '/index.md'; } + // Make the extension `.md` optional + if (! file_exists($articleFilename) && file_exists($articleFilename . '.md')) { + $articleFilename .= '.md'; + } + if (($articleFilename == realpath($articleFilename)) && file_exists($articleFilename) && is_readable($articleFilename)) { $wikiName = 'Slim Wiki'; // TODO: Make this configurable