obsidian-daily-notes-interface
Advanced tools
Comparing version 0.8.4 to 0.9.0
@@ -185,8 +185,7 @@ 'use strict'; | ||
} | ||
async function getTemplateContents(template) { | ||
const app = window.app; | ||
const { metadataCache, vault } = app; | ||
async function getTemplateInfo(template) { | ||
const { metadataCache, vault } = window.app; | ||
const templatePath = obsidian.normalizePath(template); | ||
if (templatePath === "/") { | ||
return Promise.resolve(""); | ||
return Promise.resolve(["", null]); | ||
} | ||
@@ -196,3 +195,5 @@ try { | ||
const contents = await vault.cachedRead(templateFile); | ||
return contents; | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
const IFoldInfo = window.app.foldManager.load(templateFile); | ||
return [contents, IFoldInfo]; | ||
} | ||
@@ -202,3 +203,3 @@ catch (err) { | ||
new obsidian.Notice("Failed to read the daily note template"); | ||
return ""; | ||
return ["", null]; | ||
} | ||
@@ -221,3 +222,3 @@ } | ||
const { template, format, folder } = getDailyNoteSettings(); | ||
const templateContents = await getTemplateContents(template); | ||
const [templateContents, IFoldInfo] = await getTemplateInfo(template); | ||
const filename = date.format(format); | ||
@@ -247,2 +248,4 @@ const normalizedPath = await getNotePath(folder, filename); | ||
.replace(/{{\s*tomorrow\s*}}/gi, date.clone().add(1, "d").format(format))); | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
app.foldManager.save(createdFile, IFoldInfo); | ||
return createdFile; | ||
@@ -308,3 +311,3 @@ } | ||
const { template, format, folder } = getWeeklyNoteSettings(); | ||
const templateContents = await getTemplateContents(template); | ||
const [templateContents, IFoldInfo] = await getTemplateInfo(template); | ||
const filename = date.format(format); | ||
@@ -335,2 +338,4 @@ const normalizedPath = await getNotePath(folder, filename); | ||
})); | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
window.app.foldManager.save(createdFile, IFoldInfo); | ||
return createdFile; | ||
@@ -378,3 +383,3 @@ } | ||
const { template, format, folder } = getMonthlyNoteSettings(); | ||
const templateContents = await getTemplateContents(template); | ||
const [templateContents, IFoldInfo] = await getTemplateInfo(template); | ||
const filename = date.format(format); | ||
@@ -397,2 +402,4 @@ const normalizedPath = await getNotePath(folder, filename); | ||
.replace(/{{\s*title\s*}}/gi, filename)); | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
window.app.foldManager.save(createdFile, IFoldInfo); | ||
return createdFile; | ||
@@ -478,4 +485,4 @@ } | ||
exports.getMonthlyNoteSettings = getMonthlyNoteSettings; | ||
exports.getTemplateContents = getTemplateContents; | ||
exports.getTemplateInfo = getTemplateInfo; | ||
exports.getWeeklyNote = getWeeklyNote; | ||
exports.getWeeklyNoteSettings = getWeeklyNoteSettings; |
@@ -19,4 +19,14 @@ import type { Moment } from "moment"; | ||
export type IGranularity = "day" | "week" | "month"; | ||
interface IFold { | ||
from: number; | ||
to: number; | ||
} | ||
interface IFoldInfo { | ||
folds: IFold[]; | ||
} | ||
// Utils | ||
export type IGranularity = "day" | "week" | "month"; | ||
export function getDateFromFile( | ||
@@ -27,3 +37,3 @@ file: TFile, | ||
export function getDateUID(date: Moment, granularity: IGranularity): string; | ||
export function getTemplateContents(template: string): Promise<string>; | ||
export function getTemplateInfo(template: string): Promise<[string, IFoldInfo]>; | ||
@@ -30,0 +40,0 @@ // Daily |
{ | ||
"name": "obsidian-daily-notes-interface", | ||
"version": "0.8.4", | ||
"version": "0.9.0", | ||
"description": "Interface for creating daily notes in Obsidian", | ||
@@ -5,0 +5,0 @@ "author": "liamcain", |
@@ -52,3 +52,3 @@ [](https://npmjs.org/package/obsidian-daily-notes-interface) | ||
### getTemplateContents | ||
### getTemplateInfo | ||
@@ -55,0 +55,0 @@ Generic utility for reading the contents of a file given it's relative path. This does not apply any transformations. |
26586
567