fix: some issues

This commit is contained in:
2023-08-02 18:13:31 +02:00
parent c8c745bb05
commit b95cfcc5b4
7 changed files with 78 additions and 45 deletions

View File

@@ -7,6 +7,7 @@ export type Movie = {
id: string;
name: string;
description: string;
type: "movie";
tags: string[];
meta: {
date: Date;
@@ -27,7 +28,11 @@ export function parseMovie(original: string, id: string): Movie {
for (const child of doc.children) {
if (child.type === "yaml") {
meta = parse(child.value) as Movie["meta"];
try {
meta = (parse(child.value) || {}) as Movie["meta"];
} catch (_) {
// ignore here
}
if (meta["rating"] && typeof meta["rating"] === "string") {
meta.rating = [...meta.rating?.matchAll("⭐")].length;
@@ -59,6 +64,7 @@ export function parseMovie(original: string, id: string): Movie {
}
return {
type: "movie",
id,
name,
tags,