Extra contents beyond WaniKani
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

32 lines
713 B

import { readFileSync } from 'fs';
import matter from 'gray-matter';
import yaml from 'js-yaml';
import S from 'jsonschema-definer';
export const isDev = process.env['NODE_ENV'] === 'development';
export function readYAML(filepath: string) {
return matter(readFileSync(filepath, 'utf-8'), {
engines: {
yaml: {
parse: (s) =>
s
? (yaml.load(s, {
schema: yaml.JSON_SCHEMA,
}) as Record<string, any>)
: {},
},
},
});
}
export const oItem = {
skip: S.boolean().optional(),
examples: S.list(
S.shape({
ja: S.string(),
en: S.string().optional(),
}).additionalProperties(true),
).optional(),
};