Skip to content

Commit

Permalink
fix: adding more check for changing filename to frontmatter title
Browse files Browse the repository at this point in the history
  • Loading branch information
Mara-Li committed Aug 6, 2022
1 parent 38b7806 commit 3944e88
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions plugin/src/filePathConvertor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ function createObsidianPath(
}
const folderDefault = settings.folderDefaultName;
let fileName = folderNoteIndex(file, vault, settings);
if (fileName === file.name && settings.useFrontmatterTitle && frontmatter['title']) {
if (fileName === file.name && settings.useFrontmatterTitle && frontmatter['title'] && fileName !== frontmatter['title']) {
fileName = frontmatter['title'] + '.md';
}
const rootFolder = folderDefault.length > 0 ? folderDefault + "/" : ''
Expand Down Expand Up @@ -129,7 +129,7 @@ function createFrontmatterPath(
const category = frontmatter[settings.yamlFolderKey]
const parentCatFolder = !category.endsWith('/') ? category.split('/').at(-1): category.split('/').at(-2);
let fileName = settings.folderNote && parentCatFolder === file.name.replace('.md', '') ? 'index.md' : file.name
if (fileName != "index.md" && frontmatter['title'] && frontmatter['title'] !== file.name) {
if (fileName === file.name && frontmatter['title'] && frontmatter['title'] !== file.name) {
fileName = frontmatter['title'] + '.md';
}
path = folderRoot + frontmatter[settings.yamlFolderKey] + "/" + fileName;
Expand All @@ -144,7 +144,7 @@ function getReceiptFolder(
vault: Vault) {
if (file.extension === 'md') {
let fileName = file.name
if (settings.useFrontmatterTitle && metadataCache.getCache(file.path).frontmatter['title']) {
if (settings.useFrontmatterTitle && metadataCache.getCache(file.path).frontmatter['title'] && metadataCache.getCache(file.path).frontmatter['title'] !== file.name) {
fileName = metadataCache.getCache(file.path).frontmatter['title'] + '.md'
}
let path = settings.folderDefaultName.length > 0 ? settings.folderDefaultName + "/" + fileName : fileName;
Expand Down

0 comments on commit 3944e88

Please sign in to comment.