sawhney17 / logseq-smartblocks

MIT License
171 stars 12 forks source link

If this plugin helps you, I'd really appreciate your support. You can buy me a coffee here.

SmartBlocks for Logseq

GitHub all releases version

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.

Features

Template Inserter

Setup

  1. Use the slash menu and type Create smartblock button block
  2. Update the values through the input

Usage in action

Screen Recording 2022-01-16 at 5 19 50 PM Screen Recording 2022-01-30 at 12 48 51 AM Screen Recording 2022-03-31 at 10 54 10 AM

Expand from smartblock expander

Accessing page properties

Encode URL method

  1. A useful application for SmartBlocks is automatically generating URLs or iFrame embeds based on things like the page name
  2. In this case it becomes useful to format variables into page names.
  3. Hence, by simply adding a second % you can have it encoded into URL format.
    • <%%currentPage%>

      Using NLP

  4. 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%>
  5. Automatically respects your date settings
    • Your format will automatically generate a specific date
  6. Support Aliases
    • [tomorrow](<%tomorrow%>) in the template generates [tomorrow]([[Jan 19th, 2022]]) Screen Recording 2022-01-18 at 12 36 29 PM

      Using if statements with dates

  7. If you want an item in a template to only show up on a certain day of the week
  8. 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
  9. 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%>

        Using the Random Function

    • 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>

Call renderers using randUUID

Limitations

TODO

Using variables and inputs

Screen Recording 2022-02-08 at 11 58 41 AM

Credits

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