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 :
Logseq_bjarke_ingels_20220808_navvFHIV95
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 https://en.wikipedia.org/wiki/}}}" {:backward-pos 3}]]]
  ["iframe-google" [[:editor/input "{{{iframe https://www.google.com/search?q=}}}" {:backward-pos 3}]]]
  ["iframe-google-images" [[:editor/input "{{{iframe https://www.google.com/search?tbm=isch&q=}}}" {: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

4 Likes

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