-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcatalog.js
More file actions
52 lines (48 loc) · 1.29 KB
/
Copy pathcatalog.js
File metadata and controls
52 lines (48 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
dv.el("b", "executing it from external script");
const len = 60;
const eval_foldername = `"${dv.current().file.folder}"`;
const foldername = dv.current().file.folder;
function get_depth(path) { return path.split("/").length; }
const depth = get_depth(foldername);
function filelink(file,noteText) {
let fllink = "";
let regex = /## .*/;
let found = noteText.match(regex);
let headerName = file.path;
if (found != null) {
headerName = found[0].slice(3).slice(0,len);
}
fllink = "[[" + file.path + "|" + headerName + "]]"
return fllink;
}
function ddclong(ddc) {
let ddclong = "";
ddclong = "DDC" + ddc
return ddclong;
}
function media(m) {
return m ? typeof m === 'string' ? m : m.join(", ") : "";
}
const asypages = await Promise.all(
dv.pages(eval_foldername)
.where(p => (p.file.name.substring(0,1) != "-")
&& (get_depth(p.file.folder)==depth)
)
.map(async (page) => {
const content = await dv.io.load(page.file.path);
return {
fl: filelink(page.file, content),
ddckey: page.ddckey,
ddc: ddclong(page.ddckey),
mstr: media(page.media)
};
})
);
dv.table(["Filelink", "ddclong", "Media"], asypages
.sort((a,b) => a.ddckey - b.ddckey)
.map(asyp => [
asyp.fl,
asyp.ddc,
asyp.mstr
])
);