Use case or problem
random Insert other file heading in CurrentFile as a link
-
Use the code quickadd or daveview
-
heading level can be modified in the code
-
The number of random titles can be modified in the code
Proposed solution
I want to open the current file, at any time insert another file title link, the title is random, and in the code can control the random title
Due to the use of translation software in this post, there may be grammar or unclear expressions. If there is that place that is not clear, please pay attention, thank you
Current workaround list code
### Use case or problem
random Insert other file heading in CurrentFile as a link
1. Use the code quickadd or daveview
2. heading level can be modified in the code
3. The number of random titles can be modified in the code
### Proposed solution
I want to open the current file, at any time insert another file title link, the title is random, and in the code can control the random title
Due to the use of translation software in this post, there may be grammar or unclear expressions. If there is that place that is not clear, please pay attention, thank you
### Current workaround list code
<%*
const dv = this.app.plugins.plugins["dataview"].api;
const noOfNotes = 3
const result = await dv.query(`
LIST rows[0].item.children.text
FROM "北海道.md"
FLATTEN file.lists as item
WHERE !item.parent
GROUP BY "<!-- " + item.position.start.line + "-->" + item.text
`)
for (let i = 0; i < noOfNotes; i++) {
// Pick one random item
const oneItem = result.value.values[ Math.trunc((Math.random()* result.value.values.length))]
tR += "\n" + dv.markdownList(dv.array(oneItem))
.replace(/<!--.*-->/, "")
.replace(/(- .*):\s*$/gm, "$1")
}
%>