Advertisement
dhniceday

Untitled

Dec 18th, 2023
806
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. YAML Example:
  2. ---
  3. cardtitle: "Action Bias"
  4. definition: "Our tendency to _favor action over inaction_, often to our benefit."
  5. ---
  6.  
  7. 1. Show prompt. Enter search key.
  8. 2. Show suggester with all notes that have a desciption containing search key.
  9. 3. On selection, insert definition in current cursor position
  10.  
  11. <%*  
  12. const dv = this.app.plugins.plugins["dataview"].api;
  13.  
  14. let keyword = await tp.system.prompt("Look up Definition Card","",true,false);
  15. keyword = keyword.toLowerCase();
  16.  
  17. let query = dv.pages()
  18.     .where(page => page.cardtitle)
  19.     .where(page => page.cardtitle.toLowerCase().includes(keyword));
  20.  
  21. if (query.length > 0) {
  22.     let choice = await tp.system.suggester(query.cardtitle, query.cardtitle,  false, "Card Title", 30);
  23.  
  24.     if (choice) {
  25.         let result = dv.pages()
  26.             .where(page => page.cardtitle == choice);
  27.    
  28.         card = '[[' + result[0].file.name + '|' + choice + ']]';
  29.         tR += '>[!summary] ' + card + '\n>' + result.definition[0];
  30.     }
  31. }
  32. %>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement