feat: build config using astro from json
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
This commit is contained in:
parent
ce7aef0316
commit
0560c9c9f0
@ -23,6 +23,9 @@ export default defineMarkdocConfig({
|
||||
type: {type: String},
|
||||
},
|
||||
},
|
||||
configOptions: {
|
||||
render: component('./src/components/partials/ConfigOptions.astro'),
|
||||
}
|
||||
},
|
||||
nodes: {
|
||||
heading: {
|
||||
|
@ -29,6 +29,7 @@
|
||||
"typescript": "^5.4.5"
|
||||
},
|
||||
"devDependencies": {
|
||||
"marked": "^14.1.2",
|
||||
"sharp": "^0.33.4"
|
||||
}
|
||||
}
|
10
pnpm-lock.yaml
generated
10
pnpm-lock.yaml
generated
@ -54,6 +54,9 @@ importers:
|
||||
specifier: ^5.4.5
|
||||
version: 5.4.5
|
||||
devDependencies:
|
||||
marked:
|
||||
specifier: ^14.1.2
|
||||
version: 14.1.2
|
||||
sharp:
|
||||
specifier: ^0.33.4
|
||||
version: 0.33.4
|
||||
@ -1971,6 +1974,11 @@ packages:
|
||||
markdown-table@3.0.3:
|
||||
resolution: {integrity: sha512-Z1NL3Tb1M9wH4XESsCDEksWoKTdlUafKc4pt0GRwjUyXaCFZ+dc3g2erqB6zm3szA2IUSi7VnPI+o/9jnxh9hw==}
|
||||
|
||||
marked@14.1.2:
|
||||
resolution: {integrity: sha512-f3r0yqpz31VXiDB/wj9GaOB0a2PRLQl6vJmXiFrniNwjkKdvakqJRULhjFKJpxOchlCRiG5fcacoUZY5Xa6PEQ==}
|
||||
engines: {node: '>= 18'}
|
||||
hasBin: true
|
||||
|
||||
mdast-util-definitions@6.0.0:
|
||||
resolution: {integrity: sha512-scTllyX6pnYNZH/AIp/0ePz6s4cZtARxImwoPJ7kS42n+MnVsI4XbnG6d4ibehRIldYMWM2LD7ImQblVhUejVQ==}
|
||||
|
||||
@ -4810,6 +4818,8 @@ snapshots:
|
||||
|
||||
markdown-table@3.0.3: {}
|
||||
|
||||
marked@14.1.2: {}
|
||||
|
||||
mdast-util-definitions@6.0.0:
|
||||
dependencies:
|
||||
'@types/mdast': 4.0.4
|
||||
|
29
src/components/ConfigOption.astro
Normal file
29
src/components/ConfigOption.astro
Normal file
@ -0,0 +1,29 @@
|
||||
---
|
||||
import {marked} from 'marked'
|
||||
import {generateConfigHeadingId} from '../helpers/configHeadingLink'
|
||||
const {item, parent = '', level = 0} = Astro.props
|
||||
|
||||
const fullPath = parent ? `${parent.replace('undefined', '0')}.${item.key}` : item.key
|
||||
const envPath = `VIKUNJA_${(fullPath ?? '').toUpperCase().replace(/\./g, '_')}`
|
||||
const HeadingTag = 'h' + (level + 2)
|
||||
const headingKey = generateConfigHeadingId(level, parent, item.key)
|
||||
---
|
||||
|
||||
{item.key &&
|
||||
<HeadingTag id={headingKey}>{item.key} <a href={'#' + headingKey}>#</a></HeadingTag>}
|
||||
{item.comment &&
|
||||
<Fragment set:html={marked.parse(item.comment)}/>}
|
||||
|
||||
{item.default_value !== undefined && (
|
||||
<p>Default: <code>{item.default_value === '' ? '<empty>' : item.default_value.toString()}</code></p>)}
|
||||
{item.key && fullPath !== item.key && (
|
||||
<p>Full path: <code>{fullPath}</code></p>
|
||||
)}
|
||||
{item.key && fullPath !== item.key && parent !== 'auth.openid.providers.undefined' && (<p>Environment path:
|
||||
<code>{envPath}</code>
|
||||
</p>)}
|
||||
|
||||
{item.children && (
|
||||
item.children.map(child => (
|
||||
<Astro.self item={child} parent={fullPath} level={level + 1}/>))
|
||||
)}
|
8
src/components/partials/ConfigOptions.astro
Normal file
8
src/components/partials/ConfigOptions.astro
Normal file
@ -0,0 +1,8 @@
|
||||
---
|
||||
import ConfigOption from '../ConfigOption.astro'
|
||||
const response = await fetch('https://kolaente.dev/vikunja/vikunja/raw/branch/main/config-raw.json')
|
||||
const data = await response.json()
|
||||
---
|
||||
|
||||
<hr/>
|
||||
{data.children.map(c => (<ConfigOption item={c}/><hr/>))}
|
File diff suppressed because it is too large
Load Diff
@ -8,6 +8,8 @@ All available migration options can be found [in the docs](/docs/config-options#
|
||||
|
||||
You can develop migrations for more services, see the [documentation](/docs/migrations) for more info.
|
||||
|
||||
TODO Rewrite this for all migration options
|
||||
|
||||
## Trello
|
||||
|
||||
### Config Setup
|
||||
|
43
src/helpers/configHeadingLink.ts
Normal file
43
src/helpers/configHeadingLink.ts
Normal file
@ -0,0 +1,43 @@
|
||||
export function generateConfigHeadingId(level: number, parent: string, key: string): string {
|
||||
return [
|
||||
level,
|
||||
parent,
|
||||
key,
|
||||
].join('-')
|
||||
}
|
||||
|
||||
interface ConfigItem {
|
||||
key?: string;
|
||||
value?: string;
|
||||
comment?: string;
|
||||
children?: ConfigItem[];
|
||||
}
|
||||
|
||||
interface ConfigHeadingEntr {
|
||||
slug: string;
|
||||
depth: number;
|
||||
text: string;
|
||||
}
|
||||
|
||||
export function generateConfigHeadings(data: ConfigItem, parentSlug: string = '', depth: number = 0): ConfigHeadingEntr[] {
|
||||
let result: ConfigHeadingEntr[] = []
|
||||
|
||||
if (data.key) {
|
||||
const slug = generateConfigHeadingId(depth, parentSlug, data.key)
|
||||
result.push({
|
||||
slug,
|
||||
depth: depth + 2,
|
||||
text: data.key,
|
||||
})
|
||||
}
|
||||
|
||||
if (data.children) {
|
||||
for (let i = 0; i < data.children.length; i++) {
|
||||
const child = data.children[i]
|
||||
const childSlug = data.key ? (parentSlug ? `${parentSlug}.${data.key}` : data.key) : `${parentSlug}[${i}]`
|
||||
result = result.concat(generateConfigHeadings(child, childSlug, depth + 1))
|
||||
}
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
@ -29,7 +29,7 @@ function buildToc(headings: MarkdownHeading[]) {
|
||||
if (heading.depth === 2) {
|
||||
toc.push(heading)
|
||||
} else {
|
||||
parentHeadings.get(heading.depth - 1).subheadings.push(heading)
|
||||
parentHeadings.get(heading.depth - 1)?.subheadings.push(heading)
|
||||
}
|
||||
})
|
||||
return toc
|
||||
|
10
src/pages/docs/Config.astro
Normal file
10
src/pages/docs/Config.astro
Normal file
@ -0,0 +1,10 @@
|
||||
---
|
||||
import Docs from '../../layouts/Docs.astro'
|
||||
|
||||
const post = Astro.props
|
||||
const {Content, headings} = await post.render()
|
||||
---
|
||||
|
||||
<Docs headings={headings} {...post.data}>
|
||||
<Content/>
|
||||
</Docs>
|
@ -1,6 +1,7 @@
|
||||
---
|
||||
import {type CollectionEntry, getCollection} from 'astro:content'
|
||||
import Docs from '../../layouts/Docs.astro'
|
||||
import {generateConfigHeadings} from '../../helpers/configHeadingLink'
|
||||
|
||||
export async function getStaticPaths() {
|
||||
const docs = await getCollection('docs')
|
||||
@ -15,6 +16,11 @@ type Props = CollectionEntry<'docs'>
|
||||
|
||||
const post = Astro.props
|
||||
const {Content, headings} = await post.render()
|
||||
if (post.slug === 'config-options') {
|
||||
const response = await fetch('https://kolaente.dev/vikunja/vikunja/raw/branch/main/config-raw.json')
|
||||
const data = await response.json()
|
||||
data.children.forEach(c => headings.push(...generateConfigHeadings(c)))
|
||||
}
|
||||
---
|
||||
<Docs headings={headings} {...post.data}>
|
||||
<Content/>
|
||||
|
Reference in New Issue
Block a user