mirror of
https://github.com/decaf-dev/obsidian-vault-explorer.git
synced 2026-07-22 10:10:31 +00:00
Fix load tags (#320)
This commit is contained in:
parent
818d6d8170
commit
b49a28f247
6 changed files with 22 additions and 22 deletions
|
|
@ -897,11 +897,7 @@
|
|||
) {
|
||||
formatted = filteredCustom.map((loadedFile) => {
|
||||
const { id, file } = loadedFile;
|
||||
const frontmatter =
|
||||
plugin.app.metadataCache.getFileCache(file)?.frontmatter;
|
||||
|
||||
const isFavorite = favoritesCache.get(file.path) ?? null;
|
||||
|
||||
const content = contentCache.get(file.path) ?? null;
|
||||
|
||||
return formatFileDataForRender({
|
||||
|
|
@ -909,7 +905,6 @@
|
|||
settings: plugin.settings,
|
||||
fileId: id,
|
||||
file,
|
||||
fileFrontmatter: frontmatter,
|
||||
fileContent: content,
|
||||
fileFavorite: isFavorite,
|
||||
});
|
||||
|
|
|
|||
|
|
@ -45,7 +45,6 @@ export const formatFileDataForRender = ({
|
|||
settings,
|
||||
file,
|
||||
fileId,
|
||||
fileFrontmatter,
|
||||
fileContent,
|
||||
fileFavorite,
|
||||
}: {
|
||||
|
|
@ -53,12 +52,13 @@ export const formatFileDataForRender = ({
|
|||
settings: VaultExplorerPluginSettings;
|
||||
file: TFile;
|
||||
fileId: string;
|
||||
fileFrontmatter: FrontMatterCache | undefined;
|
||||
fileContent: string | null;
|
||||
fileFavorite: boolean | null;
|
||||
}): FileRenderData => {
|
||||
const { name, basename, extension, path } = file;
|
||||
|
||||
const fileFrontmatter = app.metadataCache.getFileCache(file)?.frontmatter;
|
||||
|
||||
const { loadBodyTags } = settings;
|
||||
const { coverImageSources } = settings.views.grid;
|
||||
const {
|
||||
|
|
@ -78,15 +78,14 @@ export const formatFileDataForRender = ({
|
|||
"tags",
|
||||
PropertyType.LIST
|
||||
);
|
||||
if (fileContent && loadBodyTags) {
|
||||
const body = removeFrontmatter(fileContent);
|
||||
const TAG_REGEX = /#\w+(\/\w+)*/g;
|
||||
const bodyTags = body.match(TAG_REGEX);
|
||||
|
||||
if (loadBodyTags) {
|
||||
const bodyTags = app.metadataCache.getFileCache(file)?.tags;
|
||||
|
||||
//Keep the tags array null if there are no tags in the frontmatter or body
|
||||
if (bodyTags !== null && bodyTags.length > 0) {
|
||||
if (bodyTags) {
|
||||
//Remove the hash from the tags
|
||||
const tagsWithoutHash = bodyTags.map((tag) => tag.slice(1));
|
||||
const tagsWithoutHash = bodyTags.map((t) => t.tag.slice(1));
|
||||
tags = Array.from(new Set([...(tags ?? []), ...tagsWithoutHash]));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
"canvas": true,
|
||||
"outgoing-link": true,
|
||||
"tag-pane": true,
|
||||
"properties": false,
|
||||
"properties": true,
|
||||
"page-preview": true,
|
||||
"daily-notes": false,
|
||||
"templates": false,
|
||||
|
|
|
|||
1
test-vault/.obsidian/core-plugins.json
vendored
1
test-vault/.obsidian/core-plugins.json
vendored
|
|
@ -7,6 +7,7 @@
|
|||
"canvas",
|
||||
"outgoing-link",
|
||||
"tag-pane",
|
||||
"properties",
|
||||
"page-preview",
|
||||
"note-composer",
|
||||
"command-palette",
|
||||
|
|
|
|||
|
|
@ -8,7 +8,8 @@
|
|||
"creationDate": "creation",
|
||||
"modifiedDate": "modification",
|
||||
"createdDate": "creation",
|
||||
"image": "image"
|
||||
"image": "image",
|
||||
"coverImageFit": ""
|
||||
},
|
||||
"filters": {
|
||||
"search": {
|
||||
|
|
@ -60,7 +61,8 @@
|
|||
"type": "body",
|
||||
"isEnabled": true
|
||||
}
|
||||
]
|
||||
],
|
||||
"coverImageFit": "cover"
|
||||
},
|
||||
"list": {
|
||||
"isEnabled": true,
|
||||
|
|
@ -103,6 +105,6 @@
|
|||
"feed"
|
||||
],
|
||||
"configDir": ".vaultexplorer",
|
||||
"pluginVersion": "1.40.0",
|
||||
"pluginVersion": "1.41.0",
|
||||
"logLevel": "trace"
|
||||
}
|
||||
|
|
@ -1,10 +1,11 @@
|
|||
---
|
||||
tags:
|
||||
- tag1
|
||||
- tag2
|
||||
- tag3
|
||||
- tag1
|
||||
- tag2
|
||||
- tag3
|
||||
---
|
||||
#tag4
|
||||
|
||||
#tag4
|
||||
|
||||
Some text #tag5
|
||||
|
||||
|
|
@ -12,4 +13,6 @@ Some text #tag5
|
|||
|
||||
This is some text #tag6
|
||||
|
||||
#tag/subtag
|
||||
#tag/subtag
|
||||
|
||||
#1111
|
||||
|
|
|
|||
Loading…
Reference in a new issue