UNPKG

md-toy-blog

Version:

Very simple Markdown blog: serves your md as html without fancy databases. You will only spend time writing the actual data.

23 lines (19 loc) 768 B
import { LoadDictElement } from 'di-why/build/src/DiContainer'; function isString(slug: string | undefined): slug is string { return typeof slug !== 'undefined'; } export type PostSlugList = string[]; export type PostListGetter = () => PostSlugList; const loadDictElement: LoadDictElement<PostListGetter> = { factory: ({ compiledUserContentDir }: { compiledUserContentDir: string }) => { return function (): string[] { const postList: string[] = require(`${compiledUserContentDir}/post-list`); const postSlugsList = postList.map(fileName => fileName.split('.').shift()).filter(isString); return postSlugsList; }; }, locateDeps: { compiledUserContentDir: 'MTB_COMPILED_USER_CONTENT_DIR', }, }; export default loadDictElement;