let pages = dv.pages("")
.where(p => p.file.outlinks.includes(dv.current().file.link)) // Filter documents linking to this one
.filter(p => p.tags && p.tags.length > 0); // Ensure they have tags
let tagTree = {};
// Organize documents into a nested tag structure
pages.forEach(page => {
page.tags.forEach(tag => {
let parts = tag.split("/"); // Split tag by "/"
let rootTag = parts[0]; // First part of tag (e.g., #mongodb from #mongodb/migration)
let subPath = parts.slice(1).join("/"); // Everything after root (e.g., migration)
if (!tagTree[rootTag]) tagTree[rootTag] = {}; // Ensure root exists
let currentLevel = tagTree[rootTag];
if (subPath) {
let subParts = subPath.split("/");
subParts.forEach((sub, index) => {
if (!currentLevel[sub]) currentLevel[sub] = {}; // Create subtags if missing
if (index === subParts.length - 1) {
if (!currentLevel[sub].docs) currentLevel[sub].docs = [];
currentLevel[sub].docs.push(page);
}
currentLevel = currentLevel[sub]; // Move deeper into the structure
});
} else {
if (!currentLevel.docs) currentLevel.docs = [];
currentLevel.docs.push(page);
}
});
});
function indent(count = 0) {
return ' '.repeat(count * 8);
}
// Recursive function to render tree structure
function renderTree(tree, depth = 0) {
for (let [tag, value] of Object.entries(tree)) {
if (tag !== "docs") {
// Render tag
dv.paragraph(`${indent(depth)} #${tag}`);
// Recursively render subtags
renderTree(value, depth + 1);
} else {
// Render documents
dv.list(value.map((doc) => `${indent(depth)} ${doc.file.link}`));
}
}
}
// Render the full tag tree
renderTree(tagTree);
SELECT "funding"."fundId" AS "funding_fundId", "funding"."fundUuid" AS "funding_fundUuid", "funding"."fundTitle" AS "funding
_fundTitle", "funding"."fundCont" AS "funding_fundCont", "funding"."fundTheme" AS "funding_fundTheme", "funding"."fundPubl" AS "funding_fundPubl",
"funding"."fundGoal" AS "funding_fundGoal", "funding"."fundSum" AS "funding_fundSum", "funding"."fundAddrRoad" AS "funding_fundAddrRoad", "funding"."fundAddrDetl" AS "funding_fundAddrDetl", "funding"."fundAddrZip" AS "funding_fundAddrZip", "funding"."fundRecvName" AS "funding_fundRecvName", "funding"."fundRecvPhone" AS "funding_fundRecvPhone", "funding"."fundRecvReq" AS "funding_fundRecvReq", "funding"."endAt" AS "funding_endAt", "funding"."regAt" AS "funding_regAt", "funding"."uptAt" AS "funding_uptAt", "funding"."defaultImgId" AS "funding_defaultImgId", "funding"."fundUser"AS "funding_fundUser", "comment"."comId" AS "comment_comId", "comment"."fundId" AS "comment_fundId", "comment"."authorId" AS "comment_authorId", "comment"."content" AS "comment_content", "comment"."regAt" AS "comment_regAt", "comment"."isMod" AS "comment_isMod", "comment"."isDel" AS "comment_isDel", "author"."userId" AS "author_userId", "author"."authId" AS "author_authId", "author"."authType" AS "author_authType", "author"."userNick" AS "author_userNick", "author"."userPw" AS "author_userPw", "author"."userName" AS "author_userName", "author"."userPhone" AS "author_userPhone", "author"."userEmail" AS "author_userEmail", "author"."userBirth" AS "author_userBirth", "author"."regAt" AS "author_regAt", "author"."uptAt" AS "author_uptAt", "author"."delAt" AS "author_delAt", "author"."defaultImgId" AS "author_defaultImgId", "author"."isAdmin" AS "author_isAdmin", "author"."userAcc" AS "author_userAcc", "authorImage"."imgId" AS "authorImage_imgId", "authorImage"."imgUrl" AS "authorImage_imgUrl", "authorImage"."imgType" AS "authorImage_imgType", "authorImage"."subId" AS "authorImage_subId", "authorImage"."creatorUserId" AS "authorImage_creatorUserId"
FROM "funding" "funding"
LEFT JOIN "comment" "comment"
ON "comment"."fundId"="funding"."fundId" AND ("comment"."isDel" = $1)
LEFT JOIN "user" "author"
ON "author"."userId"="comment"."authorId" AND ("author"."delAt" IS NULL)
LEFT JOIN "image" "authorImage"
ON
("author"."defaultImgId" IS NOT NULL AND "authorImage"."imgId" = "author"."defaultImgId")
OR
("author"."defaultImgId" IS NULL AND "authorImage"."subId" = "author"."userId" AND "authorImage"."imgType" = $2)
WHERE "funding"."fundUuid" = $3 ORDER BY "comment"."regAt" DESC -- PARAMETERS: [false,"User","ca79d647-099f-4a25-9dd3-235f968e
fbcc"]