Added 'created' attribute to files and pages

This commit is contained in:
Zef Hemel
2023-11-03 09:38:04 +01:00
parent 3f1aa45b5d
commit 509683c537
16 changed files with 39 additions and 2 deletions
+2
View File
@@ -25,6 +25,7 @@ async function responseToFileMeta(
: 0,
contentType: r.headers.get("Content-type")!,
perm,
created: +(r.headers.get("X-Created") || "0"),
lastModified: +(r.headers.get("X-Last-Modified") || "0"),
};
}
@@ -147,6 +148,7 @@ function errorResult(
meta: {
name,
contentType: "text/markdown",
created: 0,
lastModified: 0,
size: 0,
perm: "ro",
+3 -1
View File
@@ -8,7 +8,8 @@ import { indexObjects } from "./api.ts";
export type PageObject = ObjectValue<
// The base is PageMeta, but we override lastModified to be a string
Omit<PageMeta, "lastModified"> & {
Omit<Omit<PageMeta, "lastModified">, "created"> & {
created: string; // indexing it as a string
lastModified: string; // indexing it as a string
} & Record<string, any>
>;
@@ -23,6 +24,7 @@ export async function indexPage({ name, tree }: IndexTreeEvent) {
ref: name,
tags: [], // will be overridden in a bit
...pageMeta,
created: new Date(pageMeta.created).toISOString(),
lastModified: new Date(pageMeta.lastModified).toISOString(),
};
+2
View File
@@ -73,6 +73,7 @@ export async function readFileSearch(
name,
contentType: "text/markdown",
size: text.length,
created: 0,
lastModified: 0,
perm: "ro",
},
@@ -91,6 +92,7 @@ export function getFileMetaSearch(name: string): FileMeta {
name,
contentType: "text/markdown",
size: -1,
created: 0,
lastModified: 0,
perm: "ro",
};
+5 -1
View File
@@ -40,6 +40,7 @@ export async function instantiateTemplateCommand() {
const tempPageMeta: PageMeta = {
name: "",
created: 0,
lastModified: 0,
perm: "rw",
};
@@ -207,6 +208,7 @@ export async function dailyNoteCommand() {
pageName,
await replaceTemplateVars(dailyNoteTemplateText, {
name: pageName,
created: 0,
lastModified: 0,
perm: "rw",
}),
@@ -251,6 +253,7 @@ export async function weeklyNoteCommand() {
pageName,
await replaceTemplateVars(weeklyNoteTemplateText, {
name: pageName,
created: 0,
lastModified: 0,
perm: "rw",
}),
@@ -272,7 +275,8 @@ export async function insertTemplateText(cmdDef: any) {
// Likely page not yet created
pageMeta = {
name: page,
lastModified: -1,
created: 0,
lastModified: 0,
perm: "rw",
};
}