If this plugin helps you, I'd really appreciate your support. You can buy me a coffee here.
This plugin enables advanced templating workflows within logseq.
Currently porting features from the official Smartblocks from Roam plugin. Feel free to ping me on twitter @aryansawhney17, or file a github issue for any feedback or feature requests.
- Use the slash menu and type
Create smartblock button block
- Update the values through the input
- In version 3.0.0, you can now expand and select a smartblock while inserting, similar to how Logseq's templates work.
- Simply type mod+t or /insert smartblocks and navigate to the desired Smartblock and then hit enter or click it
- You can search to filter in this view
- You can either expand by creating a templater button or create an inline smartblock expansion
- Running smartblocks expansion templater
- Use the slash command to insert templater or templater guided
- Follow the below syntax for flags and setup of the original template
- Running smartblocks expansion inline
- Use the slash command to insert templater inline
- Follows slightly different syntax for flags with the format being
{{renderer :smartblockInline, templateName, sibling?}}
- Sample:
{{renderer :smartblockInline, journalTemplate, true}}
- When this is in a block marked template, then this won't auto expand to allow for usage in regular logseq templates or as a daily note template
- You can configure the templater in the following ways
- Set template(required)
- Set title(required for button)
- Set sibling true or false(required for button)
- Whether you want the template to be inserted as a sibling(as a new bullet not a child of the button), or as a child (indented under the button)
- Basic structure of the button expansion is as such
{{renderer :smartblock, journalTemplate, New Journal, false}}
- A useful application for SmartBlocks is automatically generating URLs or iFrame embeds based on things like the page name
- In this case it becomes useful to format variables into page names.
- Hence, by simply adding a second
%
you can have it encoded into URL format.<%%currentPage%>
- In the templates, wherever you want a dynamic date, one that shows a different value based on the date it was inserted, use this syntax
<%NLP Input%>
<%Today%>
<%Last monday%>
<%current time%>
<%30th of december%>
- Automatically respects your date settings
- Your format will automatically generate a specific date
- Support Aliases
- If you want an item in a template to only show up on a certain day of the week
- Follow the below syntax
- if the day of the week is monday
<%if dayofweek = 1: text to be entered%>
- if it's the 22th
<%if dayofmonth = 22: text to be entered%>
- if it's the 100th day of the year
<%if dayofyear = 100: text to be entered%>
- if it's July
<%month%> = 7: text to be entered
- if the day of the week is monday
- As of the latest release, you can now have OR statements to result in insertion if any of the properties are in action. Simply separate the parameters with
||
. Some examples are as follows- if it's either january or a monday
<%if month = 1|| if dayofweek = 1 : text to be entered%>
- if it's a weekend
<%if dayofweek = 6|| if dayofweek = 7 : text to be entered%>
- if it's either january or a monday
- Limited scope at the moment, can currently fetch a random block linking to a page and create a reference to the random block
- Use
<randomblock Name of page/tag>
-<randomblock twitter>
-<randomblock Tasks Inbox>
- If you'd like to integrate things like the wordcount plugin, you can do so by generating a random alphanumeric using using <%randUUID%>
- {{renderer :wordcount_<%randUUID%>}} will insert a new word counter whenever the smartblock is called provided the word counter plugin is installed
- You can ask the user for inputs. You can then reuse this input multiple times in the smartblock
- To set an input, use
<setInput: variableName%>
- If you'd like you give a dropdown list of options, use
<%setInput: variableName:comma,separated,options%>
- To get the input of an already set input, i.e. if you want to use something twice, do
<%getInput: variableName%>
- Makes it possible to grab the current weather from Open Weather Map API
- Format used is
<%weatherf Dubai%>
- Start with weather
- Add the desired format, either
f
for farenheight orc
for celcius - Add your current location, don't be too speciifc, weather data may not always be available for more specific searches
- Format returned is
30° 🌧
- If you want to import the current page into the template as a dynamic variable, simply insert the placeholder
<%currentPage%>
- Study <%currentPage%> on <%tomorrow%>
- Will return
Study [[Nuclear Physics]] [[Feb 3, 2022]]
Only works with dynamic variables up to 4 blocks deepfixed in latest update
- Enable support for natural language processing for dates allowing for dynamic dates (different date auto added based on current date)
- Allow user to set variables via inputs
- Allow NLP dates in if statements
- If you update to the latest version, you can create inputs and variables
- To set an input use the variable <%setinput: inputName%>
- When you call the smartblock, you will then be able to define inputs for those inputs, they will auto replace these blocks
- To access the property of an existing input, let's say you've already set the input
people
using <%setinput: people%>- You can now access the already defined input via the line <%getinput: people%> without it prompting you again.
- You can even pass dynamic variables like <%current page%> as an input!
Has been shifted to it's own plugin: https://github.com/sawhney17/logseq-property-visualizer
If you like the work I'm doing, consider buying me a coffee :)
- Sherlockjs
- Thanks a ton to hkgnp and his NLP plugin for implementation inspiration
- Credits to the original SmartBlocks plugin for Roam by @tfthacker
- Thanks to OpenWeatherMap for weather data