mirror of
https://github.com/til-schneider/slim-wiki.git
synced 2025-08-06 08:37:31 +02:00
Made .md
extension optional
This commit is contained in:
@@ -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:
|
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.
|
||||||
|
@@ -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:
|
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`.
|
- [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.
|
||||||
|
@@ -12,10 +12,16 @@ class Main {
|
|||||||
$articleBaseDir = realpath(__DIR__ . '/../../articles') . '/';
|
$articleBaseDir = realpath(__DIR__ . '/../../articles') . '/';
|
||||||
$articleFilename = $articleBaseDir . implode('/', $requestPathArray);
|
$articleFilename = $articleBaseDir . implode('/', $requestPathArray);
|
||||||
|
|
||||||
|
// Support `index.md` for directories
|
||||||
if (is_dir($articleFilename)) {
|
if (is_dir($articleFilename)) {
|
||||||
$articleFilename = rtrim($articleFilename, '/') . '/index.md';
|
$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)) {
|
if (($articleFilename == realpath($articleFilename)) && file_exists($articleFilename) && is_readable($articleFilename)) {
|
||||||
$wikiName = 'Slim Wiki'; // TODO: Make this configurable
|
$wikiName = 'Slim Wiki'; // TODO: Make this configurable
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user