Hi all, wondering if I could get some help with a DataviewJS query.
What I’m trying to do
I keep a database of words I’m trying to learn, with frontmatter formatted like
word: theWord
definition: "what the word means"
I’d like to pull one random word as well as its definition into my dashboard and link back to the word’s source, so I’d get:
[[Muqarnas]]: A form of ornamented vaulting in Islamic architecture.
Things I have tried
This code gets me partway there: it shows a random word whenever the page is reloaded, but I’m not sure how to access the YAML frontmatter to pull in the definition or how to link to the page source.
Try this! You can also access the word with .word the same as accessing .definition, but it seems like you were naming the file the same as the word so I simplified it to match the desired output
Do be aware that all of these solutions will provide a new word/defintion each time the query is executed. This means new words on each switch into live preview or reading mode, each the file is opened, or the view is refreshed/rebuilt.
It could be what is wanted, in that case everything is fine, but in the other case or could try looking into slightly different random generators which would only generate a new number each day (or hour) or something like that.
true! I have turned off my dataview re-evaluation and have a shortcut that inserts this templater code: <%*app.workspace.activeLeaf.rebuildView()%>
which makes life with random (and general interaction speed) overall faster, so long as I don’t mind manually refreshing