diff options
| author | nsfisis <nsfisis@gmail.com> | 2023-06-25 18:20:53 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2023-06-25 18:25:31 +0900 |
| commit | 2e135352d0b3662ef44336994465ec7d75d400f1 (patch) | |
| tree | b8b16c6d6c519c0f9854691fb99b2c40e632311c /nuldoc-src/config.ts | |
| parent | 85bdb29b8dfbf6027fc2f98289433e254ec6ff50 (diff) | |
| download | blog.nsfisis.dev-2e135352d0b3662ef44336994465ec7d75d400f1.tar.gz blog.nsfisis.dev-2e135352d0b3662ef44336994465ec7d75d400f1.tar.zst blog.nsfisis.dev-2e135352d0b3662ef44336994465ec7d75d400f1.zip | |
feat(nuldoc): improve error handling when a tag is undefined
Diffstat (limited to 'nuldoc-src/config.ts')
| -rw-r--r-- | nuldoc-src/config.ts | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/nuldoc-src/config.ts b/nuldoc-src/config.ts index cbbabca..76a05fe 100644 --- a/nuldoc-src/config.ts +++ b/nuldoc-src/config.ts @@ -33,3 +33,10 @@ export const config = { }; export type Config = typeof config; + +export function getTagLabel(c: Config, slug: string): string { + if (!(slug in c.blog.tagLabels)) { + throw new Error(`Unknown tag: ${slug}`); + } + return (c.blog.tagLabels as { [slug: string]: string })[slug]; +} |
