Skip to content

Commit

Permalink
chore: separate type result
Browse files Browse the repository at this point in the history
  • Loading branch information
dimaslanjaka committed Apr 23, 2023
1 parent 25b35ef commit 493fd35
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions lib/front_matter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,15 @@ function split(str: string) {
return { content: str };
}

export type ParseResult = Record<string, any> & Partial<{
_content: string;
title: string;
description: string;
thumbnail: string;
date: any;
updated: any;
}>

function parse(str: string, options: yaml.LoadOptions = {}) {
if (typeof str !== 'string') throw new TypeError('str is required!');

Expand All @@ -40,15 +49,7 @@ function parse(str: string, options: yaml.LoadOptions = {}) {

if (!raw) return { _content: str };

let data: Partial<{
[key: string]: any;
_content: string;
title: string;
description: string;
thumbnail: string;
date: any;
updated: any;
}>;
let data: ParseResult;

if (splitData.separator.startsWith(';')) {
data = parseJSON(raw);
Expand Down

0 comments on commit 493fd35

Please sign in to comment.