Make index page configurable
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
"@codemirror/view": "^6.0.0",
|
||||
"@lezer/common": "1.0.0",
|
||||
"@lezer/highlight": "1.0.0",
|
||||
"@lezer/markdown": "1.0.1"
|
||||
"@lezer/markdown": "1.0.1",
|
||||
"yaml": "^1.10.2"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import YAML from "yaml";
|
||||
|
||||
export function safeRun(fn: () => Promise<void>) {
|
||||
fn().catch((e) => {
|
||||
console.error(e);
|
||||
@@ -19,3 +21,17 @@ export function throttle(func: () => void, limit: number) {
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// TODO: This is naive, may be better to use a proper parser
|
||||
const yamlSettingsRegex = /```yaml([^`]+)```/;
|
||||
|
||||
export function parseYamlSettings(settingsMarkdown: string): {
|
||||
[key: string]: any;
|
||||
} {
|
||||
const match = yamlSettingsRegex.exec(settingsMarkdown);
|
||||
if (!match) {
|
||||
return {};
|
||||
}
|
||||
const yaml = match[1];
|
||||
return YAML.parse(yaml);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user