Skip to content

Commit 9077f99

Browse files
Fix small issue, more params for RANDOMCHILDOF and new smartblock command FIRSTCHILDOFMENTION (#125)
* fix recursion bug for smartblocks which accept `levelsIncluded` param * add params `levelsIncluded`, `format` and optional filter values i.e. `search` in SB `RANDOMCHILDOF` * add `FIRSTCHILDOFMENTION` smartblock * prettier * rm console.logs * add RANDOMCHILDOFMENTION, deprecate RANDOMCHILDOF * Documentation * 1.9.0 * Previously called `RANDOMCHILDOF` --------- Co-authored-by: Baibhav Bista <baibhavbista@gmail.com>
1 parent 0f9e6de commit 9077f99

File tree

5 files changed

+165
-77
lines changed

5 files changed

+165
-77
lines changed

docs/050-command-reference.md

+49-48
Original file line numberDiff line numberDiff line change
@@ -149,18 +149,42 @@ Serendipity commands are commands that help resolve to a random block from your
149149

150150
- `<%RANDOMBLOCKMENTION:Evergreen Notes%>`
151151

152-
## RANDOMCHILDOF
152+
## RANDOMCHILDOFMENTION
153+
154+
_Previously called `RANDOMCHILDOF`_
153155

154156
**Purpose**: Returns a random child block of a block that's referencing the input page
155157

156-
**Parameters**: One parameter that could be either:
158+
**Parameters**:
159+
160+
1. One parameter that could be either:
161+
- Option 1: **Page name** or **tag name** (brackets `[[]]` or hashtag `#` are optional)
162+
- Option 2: Parent block UID
163+
2. Levels within the page to include. Specifying 0 includes all blocks
164+
3. Format to output the block in. See our [Formatting](050-command-reference.md#formatting) section for more info.
165+
4. Optional filter parameter. See our [Filtering](050-command-reference.md#filtering) section for more info.
166+
167+
**Examples**:
168+
169+
- `<%RANDOMCHILDOFMENTION:Evergreen Notes%>`
170+
- `<%RANDOMCHILDOFMENTION:[[ONE BLOG POST A DAY/Candidates]],1,{{embed-path:(({uid}))}},-[[DONE]]%>`
157171

158-
- Option 1: **Page name** or **tag name** (brackets `[[]]` or hashtag `#` are optional)
159-
- Option 2: Parent block UID
172+
## FIRSTCHILDOFMENTION
160173

161-
**Example**:
174+
**Purpose**: Returns the first child block of a block that's referencing the input page
162175

163-
- `<%RANDOMCHILDOF:Evergreen Notes%>`
176+
**Parameters**:
177+
178+
1. One parameter that could be either:
179+
- Option 1: **Page name** or **tag name** (brackets `[[]]` or hashtag `#` are optional)
180+
- Option 2: Parent block UID
181+
2. Format to output the block in. See our [Formatting](050-command-reference.md#formatting) section for more info.
182+
3. Optional filter parameter. See our [Filtering](050-command-reference.md#filtering) section for more info.
183+
184+
**Examples**:
185+
186+
- `<%FIRSTCHILDOFMENTION:Evergreen Notes%>`
187+
- `<%FIRSTCHILDOFMENTION:[[ONE BLOG POST A DAY/Candidates]],{{embed-path:(({uid}))}},-[[DONE]]%>`
164188

165189
## RANDOMNUMBER
166190

@@ -197,13 +221,7 @@ TODO commands are multi-block commands that query multiple TODOs from your graph
197221

198222
1. Maximum amount of block references to return. Default value is `20`
199223
2. Format to output the block in. See our [Formatting](050-command-reference.md#formatting) section for more info.
200-
3. optional filter parameter based on a comma separated list (case-sensitive). Can use - in front of a word to exclude it. Examples:
201-
- toRead,Pinnacle
202-
- returns blocks with toRead AND Pinnacle in the text
203-
- toRead|Pinaccle
204-
- returns blocks with toRead OR Pinnacle in the text
205-
- toRead,-Pinnacle
206-
- returns blocks with toRead but not if they have pinnacle
224+
3. Optional filter parameter. See our [Filtering](050-command-reference.md#filtering) section for more info.
207225

208226
**Example**: `<%TODOTODAY:20,(({uid}))%>`
209227

@@ -215,13 +233,9 @@ TODO commands are multi-block commands that query multiple TODOs from your graph
215233

216234
1. Maximum amount of block references to return. Default value is `20`
217235
2. Format to output the block in. See our [Formatting](050-command-reference.md#formatting) section for more info.
218-
3. optional filter parameter based on a comma separated list (case-sensitive). Can use - in front of a word to exclude it. Examples:
219-
- toRead,Pinnacle
220-
- returns blocks with toRead AND Pinnacle in the text
221-
- toRead|Pinaccle
222-
- returns blocks with toRead OR Pinnacle in the text
223-
- toRead,-Pinnacle - returns blocks with toRead but not if they have pinnacle
224-
**Examples**: `<%TODOOVERDUE:20,(({uid}))%>`
236+
3. Optional filter parameter. See our [Filtering](050-command-reference.md#filtering) section for more info.
237+
238+
**Examples**: `<%TODOOVERDUE:20,(({uid}))%>`
225239

226240
## TODOOVERDUEDNP
227241

@@ -231,13 +245,7 @@ TODO commands are multi-block commands that query multiple TODOs from your graph
231245

232246
1. Maximum amount of block references to return. Default value is `20`
233247
2. Format to output the block in. See our [Formatting](050-command-reference.md#formatting) section for more info.
234-
3. optional filter parameter based on a comma separated list (case-sensitive). Can use - in front of a word to exclude it. Examples:
235-
- toRead,Pinnacle
236-
- returns blocks with toRead AND Pinnacle in the text
237-
- toRead|Pinaccle
238-
- returns blocks with toRead OR Pinnacle in the text
239-
- toRead,-Pinnacle
240-
- returns blocks with toRead but not if they have pinnacle
248+
3. Optional filter parameter. See our [Filtering](050-command-reference.md#filtering) section for more info.
241249

242250
**Examples**: `<%TODOOVERDUEDNP:20,(({uid}))%>`
243251

@@ -249,13 +257,7 @@ TODO commands are multi-block commands that query multiple TODOs from your graph
249257

250258
1. Maximum amount of block references to return. Default value is `20`
251259
2. Format to output the block in. See our [Formatting](050-command-reference.md#formatting) section for more info.
252-
3. optional filter parameter based on a comma separated list (case-sensitive). Can use - in front of a word to exclude it. Examples:
253-
- toRead,Pinnacle
254-
- returns blocks with toRead AND Pinnacle in the text
255-
- toRead|Pinaccle
256-
- returns blocks with toRead OR Pinnacle in the text
257-
- toRead,-Pinnacle
258-
- returns blocks with toRead but not if they have pinnacle
260+
3. Optional filter parameter. See our [Filtering](050-command-reference.md#filtering) section for more info.
259261

260262
**Examples**:`<%TODOFUTURE:20,(({uid}))%>`
261263

@@ -267,13 +269,7 @@ TODO commands are multi-block commands that query multiple TODOs from your graph
267269

268270
1. Maximum amount of block references to return. Default value is `20`
269271
2. Format to output the block in. See our [Formatting](050-command-reference.md#formatting) section for more info.
270-
3. optional filter parameter based on a comma separated list (case-sensitive). Can use - in front of a word to exclude it. Examples:
271-
- toRead,Pinnacle
272-
- returns blocks with toRead AND Pinnacle in the text
273-
- toRead|Pinaccle
274-
- returns blocks with toRead OR Pinnacle in the text
275-
- toRead,-Pinnacle
276-
- returns blocks with toRead but not if they have pinnacle
272+
3. Optional filter parameter. See our [Filtering](050-command-reference.md#filtering) section for more info.
277273

278274
**Examples**: `<%TODOFUTUREDNP:20,(({uid}))%>`
279275

@@ -285,13 +281,7 @@ TODO commands are multi-block commands that query multiple TODOs from your graph
285281

286282
1. Maximum amount of block references to return. Default value is `20`
287283
2. Format to output the block in. See our [Formatting](050-command-reference.md#formatting) section for more info.
288-
3. optional filter parameter based on a comma separated list (case-sensitive). Can use - in front of a word to exclude it. Examples:
289-
- toRead,Pinnacle
290-
- returns blocks with toRead AND Pinnacle in the text
291-
- toRead|Pinaccle
292-
- returns blocks with toRead OR Pinnacle in the text
293-
- toRead,-Pinnacle
294-
- returns blocks with toRead but not if they have pinnacle
284+
3. Optional filter parameter. See our [Filtering](050-command-reference.md#filtering) section for more info.
295285

296286
**Examples**: `<%TODOUNDATED:20,(({uid}))%>`
297287

@@ -1383,3 +1373,14 @@ Several commands support a "Format" argument that allow you to specify exactly h
13831373
- `{path}` - resolves to the uids of blocks that are parents of the current block, delimited by `>`
13841374
- `{attr:name:format}` - resolves the attribute value of the attribute found on the page with the block. Replace `name` with the name of the attribute. The `format` is optional and could be used to specify additional text that only appears if the attribute is on the page.
13851375
- `{text}` - resolves to the raw text of the block
1376+
1377+
## Filtering
1378+
1379+
Several commands support an optional filter parameter based on a comma separated list (case-sensitive). Can use `-` in front of a word to exclude it. Examples:
1380+
1381+
- toRead,Pinnacle
1382+
- returns blocks with toRead AND Pinnacle in the text
1383+
- toRead|Pinaccle
1384+
- returns blocks with toRead OR Pinnacle in the text
1385+
- toRead,-Pinnacle
1386+
- returns blocks with toRead but not if they have pinnacle

package-lock.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "smartblocks",
3-
"version": "1.8.0",
3+
"version": "1.9.0",
44
"description": "Create custom and programmable templates from within Roam!",
55
"main": "./build/main.js",
66
"scripts": {

src/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,7 @@ export default runExtension(async ({ extensionAPI }) => {
389389
} else if (COMMAND_ENTRY_REGEX.test(valueToCursor)) {
390390
renderCursorMenu({
391391
initialItems: COMMANDS.filter((c) => !c.illegal)
392+
.filter((c) => !c.hidden)
392393
.map(({ text, help }) => ({
393394
text,
394395
id: text,

0 commit comments

Comments
 (0)