Advertisement
dhniceday

Random Definition

Dec 18th, 2022
601
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ```dataviewjs
  2. // Show random definition
  3. let definitionList = [];
  4. let cardtitleList = [];
  5. let fileList = [];
  6.  
  7. let query = dv.pages()
  8.     .where(page => page.cardtitle)
  9.     .where(page => page.cardtitle != "N/A");
  10.  
  11. for (q of query) {
  12.     fileList.push(q.file.name);
  13.     definitionList.push(q.definition);
  14.     cardtitleList.push(q.cardtitle);
  15. };
  16.  
  17. // o = once per day
  18. // H = once per hour
  19. // m = once per minute
  20. // s = once per second
  21. const rnd = DateTime.now().toFormat("o") % cardtitleList.length;
  22.  
  23. dv.span('[[' + fileList[rnd] + '|' + cardtitleList[rnd] + ']]' + '<br><br>'+ definitionList[rnd]);
  24. ```
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement