Insert easily random blocks (targeting a page, a block or a time period) in your workflows!
Insert a choosen number of random blocks (from a given page, or mentioning a page, or children of a block mentioning a page, or all 3 at once) and reload at will new random blocks by clicking a button if the chance did not make things well.
You can run it without any SmartBlock experience: just focus in a block, open the native Roam command palette (Ctrl-Cmd + P) and search for "Random Kit". Press Enter. A dropdown menu allows you to choose among all the available features. You will then be asked to specify the page that will generally be used to target a set of blocks, and then the number of random blocks you wish to insert.
Each SmartBlock can of course be triggered inline (pressing jj
by default).
The interest of SmartBlocks is that the whole process can be automated with your preferred settings, in each of your workflows (your roam/templates or your SmartBlocks)
There is two options:
-
You can insert a button with variables in your workklow: The main syntax for a button is
{{Title you choose:SmartBlock:Name of the SmartBlock:variable1=value,variable2=value}}
Variables are optional. The main variables are:pageName=page name
(page name with or without brackets)repeat=x
(x is the number of block that you want to insert)button=on
orbutton=off
(if you want or not display the button to reload a random block) Example of a button running block mention Smartblock, which mentions [[quote]] page, 3 times, without button:{{My random button:SmartBlock:Random block mention:pageName=quote,repeat=3,button=no}}
-
You can insert an automated SmartBlock command (so the choosen SmartBlock will be run automatically) (fore more experienced users) Earch SmartBlock can be run from another SmartBlock (but not roam/templates) with
<%SMARTBLOCK:name of the Smartbloc%>
command. Variables, if needed, have to be set before the <%SMARTBLOCK%> command. Same example as above:<%SET:pageName,quote%><%SET:repeat,3%><%SET:button=no%><%SMARTBLOCK:Random block mention%>
Insert blocks which mention a given page/tag (in other words, from the 'Linked references' of a given page).
Insert blocks from a given page (in other words, from its body).
Insert blocks that have as parent (direct or not) a block which mentions a given page/tag.
Open a dropdown menu to choose between the 3 previous options or to use all three alternatively, in a random way.
Insert blocks from a given list, in others words from the children of a given block (e.g. draw a list of people to form teams for a game).
Insert a date which links to the corresponding DNP (Daily Note Page) in the past. Specify the number of days within which the random date will be drawn. If you run this SmartBlock on a past DNP and say, e.g. "30 days before", the interval will be relative to this date, so you can specify any interval in the past.
Insert blocks from a random DNP, according to the same principle as the previous SmartBlock.
Insert a random number within a given (inclusive) range.
Smartblock command (to insert in your own smartBlocks and can be found in the autocomplete box when typing <%
) and returning a random number, with the following arguments:
- minimum limit of the range (1 by default)
- maximum limit of the range (100 by default)
Example:
<%RANDOMNUMBER:50,200%>
If you find my work useful and want to encourage me to continue and improve the existing extensions or produce new ones, you can buy me a coffee ☕ https://buymeacoffee.com/fbgallet and follow me on Twitter: @fbgallet. Thanks in advance for your support! 🙏