Skip to content

Commit 01ccbec

Browse files
committed
fix: fix tags.map is not a function error
1 parent 05e99ce commit 01ccbec

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/react/index.tsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import Checkbox from "./checkbox";
99
import Flex from "./flex";
1010
import Stack from "./stack";
1111
import EventManager from "src/event/event-manager";
12+
import { isArray } from "lodash";
1213

1314
export default function ReactView() {
1415
const [folderPath, setFolderPath] = React.useState<string>("");
@@ -145,7 +146,16 @@ export default function ReactView() {
145146
const frontmatter = app.metadataCache.getFileCache(
146147
file as TFile
147148
)?.frontmatter;
148-
const tags: string[] = frontmatter?.tags ?? [];
149+
150+
let tags: string[] = [];
151+
//Tags can be an array or just a string
152+
//This seems like a bug in Obsidian
153+
if (typeof frontmatter?.tags === "string") {
154+
tags = [frontmatter?.tags];
155+
} else if (Array.isArray(frontmatter?.tags)) {
156+
tags = frontmatter?.tags;
157+
}
158+
149159
const url: string | null = frontmatter?.[urlPropertyName] ?? null;
150160
const favorite = frontmatter?.[favoritePropertyName] ?? false;
151161
const source = frontmatter?.[sourcePropertyName] ?? null;

0 commit comments

Comments
 (0)