Macros and Commands - let's share

do you use custom macros and commands ? let’s share !

I’ll start:

making it easier to add iframes:

in my workflow I often use iframes to embed web references in logseq pages :
then I can quickly pull text or images

  1. define a macro named ‘iframe’ in config.edn
 :macros {
 "iframe" "<iframe src=\"$1\" style=\"width:calc(100% - 4px);height:650px\"></iframe>" 
  1. then define related commands :
:commands [
  ["iframe" [[:editor/input "{{{iframe }}}" {:backward-pos 3}]]]
  ["iframe-wikipedia" [[:editor/input "{{{iframe}}}" {:backward-pos 3}]]]
  ["iframe-google" [[:editor/input "{{{iframe}}}" {:backward-pos 3}]]]
  ["iframe-google-images" [[:editor/input "{{{iframe}}}" {:backward-pos 3}]]]

**usage: ** now everytime I use slash command /iframe I can quickly embed a url or I can use /iframe-wikipedia | /iframe-google | /iframe-google-images followed by a search term and get embedded results from which I can pull data without switching to a browser window


Hello. I am new to LoqSeq, jumping from Roam.
Where do you place this code?
thanks in advance

Welcome to the community @DavidPlummerMD! :wave:

Depending on how technically proficient you are, I’d warn against using macros if you’re new to Logseq.

As the OP points out, you’d need to change the config.edn file. If you don’t know what that is, I suggest you first get some more experience with simpler stuff like a daily template: How to Set Up an Automated Daily Template in Logseq

It also helps if you get experience with queries, starting with simple queries and then slowly move up to Datalog queries. See #learning-sprints:queries for learning resources.

1 Like