www/src/markmark/types.ts

29 lines
698 B
TypeScript

import {hasOwnProperty} from '@extollo/lib'
export type MarkMark = {
frontmatter: FrontMatter,
sections: Section[],
}
export type FrontMatter = {
syntax: 'v1',
authorName?: string,
authorEmail?: string,
authorHref?: string,
}
export type AnonymousSection = { links: Link[] }
export type NamedSection = { title: string, description?: string, links: Link[] }
export type Section = AnonymousSection | NamedSection
export const isNamedSection = (what: Section): what is NamedSection =>
hasOwnProperty(what, 'title') && (typeof what.title === 'string')
export type Link = {
hash: string,
title: string,
date?: Date,
tags: string[],
urls: string[],
}