Skip to content

Commit

Permalink
feat: support multiple readmes
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianschubek committed Oct 29, 2024
1 parent a0e5f6d commit 70c3f91
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ ENV API=true
ENV LAYOUT=basic
# TODO: show files in tree on hover
ENV PREVIEW=false
# TODO: support for multiple files
ENV README_NAME=readme.md

ENV README_NAME=readme.md;readme.txt;readme.html;readme;read.me;read\ me;liesmich.md;liesmich.txt;liesmich;lies\ mich;index.html;index.htm;index.txt;license

ENV README_FIRST=false

Expand Down
2 changes: 1 addition & 1 deletion docs/docs/configuration/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ By default unsafe HTML inside markdown (such as `<script>`) will be escaped. You

import EnvConfig from '@site/src/components/EnvConfig';

<EnvConfig name="README_RENDER|README_NAME|README_FIRST|ALLOW_RAW_HTML|README_META" init="true|readme.md|false|false|true" values="true,false|<string>|true,false|true,false|true,false" versions="1.1|3.2|3.2|1.1|3.5" desc="|The case-insensitive file name which should be rendered|Render the readme above the file tree instead of below it.||Renders a .dbmeta.md file if it exists" />
<EnvConfig name="README_RENDER|README_NAME|README_FIRST|ALLOW_RAW_HTML|README_META" init="true|readme.md;readme.txt;readme.html;readme;read.me;read\ me;liesmich.md;liesmich.txt;liesmich;lies\ mich;index.html;index.htm;index.txt;license|false|false|true" values="true,false|<string>|true,false|true,false|true,false" versions="1.1|3.2|3.2|1.1|3.5" desc="|The case-insensitive file names seperated by a semicolon which should be rendered|Render the readme above the file tree instead of below it.||Renders a .dbmeta.md file if it exists" />
8 changes: 5 additions & 3 deletions src/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -284,9 +284,11 @@ function downloadBatch(array $urls) {
$[if `process.env.README_RENDER === "true"`]$
// check if readme exists
foreach ($sorted_files as $file) {
if (mb_strtolower($file->name) === "${{`process.env.README_NAME`}}$") {
$readme = $file;
break;
foreach (explode(';', "${{`process.env.README_NAME`}}$") as $readme_name) {
if (mb_strtolower($file->name) === $readme_name) {
$readme = $file;
break;
}
}
}
$[end]$
Expand Down

0 comments on commit 70c3f91

Please sign in to comment.