Skip to content

Commit 62a7c1e

Browse files
committed
fix: render config
1 parent 37f4702 commit 62a7c1e

2 files changed

Lines changed: 51 additions & 0 deletions

File tree

config.data.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import {createMarkdownRenderer} from 'vitepress';
2+
3+
const SOURCE = 'https://raw.githubusercontent.com/gotify/server/master/gotify-server.env.example';
4+
5+
const uncomment = (line: string): string => line.replace(/^#( ?)/, '');
6+
const codeBlock = (text: string) => '```\n' + text.trimEnd() + '\n```';
7+
8+
const renderSetting = (block: string[]): string => {
9+
const assignment = block.find((l) => /^[A-Z][A-Z0-9_]*=/.test(uncomment(l)));
10+
if (!assignment) throw Error('could not find assignment ' + block);
11+
12+
const name = uncomment(assignment).split('=')[0];
13+
return ['### ' + name, codeBlock(block.join('\n'))].join('\n\n');
14+
};
15+
16+
export default {
17+
async load() {
18+
const res = await fetch(SOURCE);
19+
if (!res.ok) throw Error('could not fetch gotify-server.env.example');
20+
21+
const [header, ...blocks] = (await res.text())
22+
.trimEnd()
23+
.split(/\n *\n/)
24+
.map((b) => b.split('\n'))
25+
.filter((b) => b.some((l) => l.trim()));
26+
27+
const markdown = [
28+
codeBlock(header.map(uncomment).join('\n')),
29+
...blocks.map(renderSetting),
30+
].join('\n\n');
31+
32+
return (await createMarkdownRenderer('.')).render(markdown);
33+
},
34+
};

docs/config.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,20 @@
11
# Configuration
22

3+
<script setup>
4+
import {data as envExample} from '../config.data.ts'
5+
</script>
6+
7+
::: details 3.x Config
8+
9+
Gotify 3.x is configured through environment variables, which can be loaded from
10+
an env file. [`gotify-server.env.example`](https://raw.githubusercontent.com/gotify/server/refs/heads/master/gotify-server.env.example)
11+
12+
<div v-html="envExample"></div>
13+
14+
:::
15+
16+
::: details 2.x Config
17+
318
gotify/server can be configured per config file and environment variables.
419
When using docker it is recommended to use environment variables.
520

@@ -158,3 +173,5 @@ GOTIFY_OIDC_REDIRECTURL=http://gotify.example.org/auth/oidc/callback
158173
GOTIFY_OIDC_AUTOREGISTER=true
159174
GOTIFY_OIDC_USERNAMECLAIM=preferred_username
160175
```
176+
177+
:::

0 commit comments

Comments
 (0)