Let’s say I’d like to have a page [[Weekly Snippets]]
with all my weekly notes (Journal/Week/YYYY-MM-DD) inside it, sorted by date descendant.
How could I build that query so it would automatically pull all those pages?
Thanks for your help
Let’s say I’d like to have a page [[Weekly Snippets]]
with all my weekly notes (Journal/Week/YYYY-MM-DD) inside it, sorted by date descendant.
How could I build that query so it would automatically pull all those pages?
Thanks for your help
How about this?
```query
page
where name =~ /^Journal\/Week\//
render [[Library/Core/Query/Page]]
order by name desc
```
This seems to show the page names themselves, but not the content.
I am interested on seeing the content
Alright, how about this: create a new template called something like Weekly Snippet
:
---
tags: template
---
## {{replace(name, "Journal\/Week\/", "")}}
```template
page: "[[{{name}}]]"
raw: true
```
(the replaceRegexp
thing removes the Journal/Week/ prefix from the page name in the title if that’s what you want)
Then use that to render the query instead:
```query
page
where name =~ /^Journal\/Week\//
render [[Weekly Snippet]]
order by name desc
```
Example:
Awesome!
This works
I need to mentally process and learn this workflow so i can create new use cases on my own later
Thanks!
You can clean up the titles a bit too:
## {{replaceRegexp name "Journal\/Week\/" ""}}
Will update this in the previous message.
Thanks!
I realize how much I forget overtime, SB is so powerful and packed with features that, if i don’t use them, i forget them, like everything else.
I need to write notes on how to do this in Silverbullet
I am experimenting with a title like this:
My latest template for the Weekly Snippets to make it compliant with the new Query language:
---
tags: template
---
**-----------------------------**
## {{replace(name, "Journal\/Week\/", "Week of: ")}}
**-----------------------------**
```template
page: "[[{{name}}]]"
raw: true
```
---
---
I’m cheating a little by using a function readPage
(which reads in the content of a page) that I just pushed to Edge a few minutes ago, but this is how I’d do this with the new template engine:
```template
{{#each { page where name =~ /^Journal\/Week\// order by name desc } }}
## {{replace(name, "Journal/Week/", "Week of: ")}}
{{readPage(name)}}
{{/each}}
```
Better huh?
Actually this would be an excellent use case of Proposal: Virtual Page Templates
Crazy timing. I was just trying to get something like this to work, and couldn’t quite get it right. Then I saw your two new proposals (virtual pages and script-space) and saw this post, and bingo, this is what I was interested in, and it’s working.
Silverbullet is amazing, thanks Zef!
Wow, this is cool!
This template avoids the need to have a Weekly Snippet
template and just render directly in the page I want it.
I want to learn this magic!!!
When a workshop @zef ?
Just slightly modified the template to keep the same style and formatting
```template
{{#each { page where name =~ /^Journal\/Week\// order by name desc } }}
**-----------------------------**
## {{replace(name, "Journal/Week/", "Week of: ")}}
**-----------------------------**
{{readPage(name)}}
---
---
{{/each}}
```
Would there be a way to allow for the embedded content to be edited and the changes to affect the respective Journal file?
I think that would mean changing some fundamental behaviors from SB
SB shows you live results when you move the cursor away from the query/template/markdown/etc but allows you to edit the underlying content of the .md page when you click inside.
In this case, the underlying content is the template language not the output of the query.
To edit the content I guess one would need to import&replace the underlying .md file with the query result, and therefore not making it live anymore.
One would need to replace manually that content each time they’d want to refresh the content.
It seems the status of a task can be updated from it’s query - no? Could something similar be done for normal pages?
From Plugs/Tasks:
When you use this template, you can even cycle through the states of the task by click on its state inside the rendered query, and it will update the state of the original task automatically (although not yet in reverse) — this works across pages.
I’m using the same live query as you for journal pages, but it would be nice to be able to edit them right there, like in Logseq. Not sure how viable this idea is, however.
For the time being I just changed the line in the query that adds the heading to link to the page.
## [{{replace(name, "Journal/Week/", "Week of: ")}}]({{name}})
That’s a fair point, though I assume that one thing is provide the capability to cycle through a task state (available) versus providing fully writable access to the tasks (not available).
Probably the latter may need a complete redesign of live queries.
I’m not able to give an elaborate answer to this now, but a while ago we had a long discussion about introducing two-way data binding in SB, which is effectively what you’re asking for. At this time queries were implemented differently, so not all of it applies anymore, but still worth a read to understand the complexities and to an extent impossibility to do this fully:
This is a great idea, but this query didn’t work for me.
The one below would work
## {{replace(name, "Journal/Week/", "Week of: ")}}[[{{name}}]]
though it would look a bit weird:
However, you could adjust it, if you use regex to the following:
## {{replace(name, /Journal\/Week.+/, "Week of: ")}}[[{{name}}]]
which would look like this:
The whole template would end up looking like this:
```template
{{#each { page where name =~ /^Journal\/Week\// order by name desc } }}
**-----------------------------**
## {{replace(name, /Journal\/Week.+/, "Week of: ")}}[[{{name}}]]
**-----------------------------**
{{readPage(name)}}
---
---
{{/each}}
```