Skip to content

Commit

Permalink
docs: add examples for tp.obsidian module
Browse files Browse the repository at this point in the history
  • Loading branch information
Zachatoo committed Dec 2, 2023
1 parent dacf320 commit 84cc6b3
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion docs/src/internal-functions/internal-modules/obsidian-module.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,27 @@

This is mostly useful when writing scripts.

Refer to the obsidian API [declaration file](https://github.com/obsidianmd/obsidian-api/blob/master/obsidian.d.ts) for more information.
Refer to the Obsidian API [declaration file](https://github.com/obsidianmd/obsidian-api/blob/master/obsidian.d.ts) for more information.

## Examples

```javascript
// Get all folders
<%
app.vault.getAllLoadedFiles()
.filter(x => x instanceof tp.obsidian.TFolder)
.map(x => x.name)
%>

// Normalize path
<% tp.obsidian.normalizePath("Path/to/file.md") %>

// Html to markdown
<% tp.obsidian.htmlToMarkdown("\<h1>Heading\</h1>\<p>Paragraph\</p>") %>

// HTTP request
<%*
const response = await tp.obsidian.requestUrl("https://jsonplaceholder.typicode.com/todos/1");
tR += response.json.title;
%>
```

0 comments on commit 84cc6b3

Please sign in to comment.