Skip to content

Latest commit

 

History

History
29 lines (28 loc) · 800 Bytes

x_DataviewJS Quote Snippet.md

File metadata and controls

29 lines (28 loc) · 800 Bytes

[!QUOTE]

// List of quotes 
let quotes = []; 

// Extract quotes from pages
dv.pages("#theme/zettelkasten") 
  .where(page => page.quote) 
  .forEach(page => { 
  	dv.array(page.quote) 
  		.forEach(quote => { quotes.push({ 
  			message: (quote), 
  			page: page }); 
  })}); 

// Select random quote
let text = quotes[Math.floor(Math.random() * quotes.length)] 

// Generate text with quote
dv.paragraph(text.message + " <br>- " 
  + text.page.author + " <br><br><small>From: " 
  + text.page.file.link) + "</small>";