fix: some issues
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user