Advertisement
dhniceday

Untitled

Nov 21st, 2022
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JavaScript 0.64 KB | Software | 0 0
  1. <%*  
  2. const dv = this.app.plugins.plugins["dataview"].api;
  3.  
  4. let keyword = await tp.system.prompt("Look up Definition Card","",true,false);
  5. keyword = keyword.toLowerCase();
  6.  
  7. let query = dv.pages()
  8.     .where(page => page.cardtitle)
  9.     .where(page => page.cardtitle.toLowerCase().includes(keyword));
  10.  
  11. if (query.length > 0) {
  12.     let choice = await tp.system.suggester(query.cardtitle, query.cardtitle,  false, "Card Title", 15);
  13.  
  14.     if (choice) {
  15.         let result = dv.pages()
  16.         .where(page => page.cardtitle == choice);
  17.    
  18.         card = '[[' + result[0].file.name + '|' + choice + ']]';
  19.         tR += '>[!summary] ' + card + '\n>' + result.definition[0];
  20.     }
  21. }
  22. %>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement