How can I creat numbered lists?

I couldn’t think of a way to display a list as a numbered list using a regular Dataview query, but it’s easy to do using DataviewJS:

%%
Data:: item
Data:: item
Data:: item
Data:: item
Data:: item
Data:: item
Data:: item
Data:: item
Data:: item
Data:: item
Data:: item
Data:: item
%%

```dataviewjs
dv.pages('"Inbox/Dataview Numbered List Example"')
  .forEach(page => {
      dv.header(3, page.file.link);
      let output = "";
      dv.array(page.Data).forEach(data => {
          output += "1. " + data + "\n";
      });
      dv.paragraph(output);
  });
```

To use with your own data, you’d need to turn on DataviewJS in your Dataview settings if you haven’t already, then replace the “Inbox/Dataview Numbered List Example” with your own query.

This approach makes use of the fact that in Markdown, only the first item of a numbered list matters; subsequent numbers are calculated automatically. So starting each line with "1. " is enough to get it to render as a numbered list.

Hope this helps!

1 Like