SmartBlocks
SmartBlocks copied to clipboard
Return a random top level block from a page
✂️ Copy of your #42SmartBlock from Roam
-
#42SmartBlock Get top level blocks from page
-
<%SET:pageName,test data%><%NOBLOCKOUTPUT%>
-
<%JAVASCRIPTASYNC:```javascript var results = await roamAlphaAPI.q(` [:find (rand 1 ?t) :in $ ?page_title :where [?e :node/title ?page_title] [?e :block/children ?x] [?x :block/string ?t] ] `, roam42.sb.vars['pageName']); return results[0][0]; ```%>
-
-
📋 Describe the SmartBlock
The command RANDOMBLOCKFROM returns any block on a page. This SmartBlock will grab from the page defined in the first block using the SET command and return just top level blocks from a page.
✅ Describe any prerequisites or dependencies that are required for this SmartBlock
Change the first block to point to the page that interests you.