Created
February 23, 2022 03:40
-
-
Save davish/90935658e1a43dc4e0e22e61b3eaf2eb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = async (params) => { | |
const {app} = params; | |
let file = app.workspace.getMostRecentLeaf()?.view?.file; | |
if (!file) { | |
return; | |
} | |
let frontmatter = app.metadataCache.getFileCache(file)?.frontmatter; | |
let repo = frontmatter["gh-repo"] | |
if (!repo) { | |
return; | |
} | |
const url = `https://api.github.com/repos/${repo}/issues` | |
const text = await request({ url, method: "GET" }); | |
let issues = null; | |
try { | |
issues = JSON.parse(text) | |
} catch (e) { | |
return; | |
} | |
let fileContent = await app.vault.cachedRead(file) | |
const marker = (number) => `gh${number}` | |
return issues | |
.filter(issue => fileContent.indexOf(marker(issue.number)) === -1) | |
.map(issue => `- [ ] ([${marker(issue.number)}](${issue.html_url})) ${issue.title}`) | |
.join('\n') | |
} |
This was the missing step, thank you!
Wanted to leave this here in case it was interested. I adapted your code to make a general "GitHub Inbox" of all your repos that puts them in a file with headings.
https://gist.github.com/amichuda/bb5405031c302f657d0bfb950fa98a11
This is awesome, @amichuda! Thanks for sharing :D
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You need to hook this up to the
QuickAdd
plugin. The documentation is kind of scattered, but I'd recommend watching the video in the README (https://github.com/chhoumann/quickadd) to get an idea of how to use it. I'll post my configuration below:In addition to adding this as a "Choice", you'll also need to download this file into your vault, and add it as a macro. QuickAdd has some documentation on how to do that.
I hope that helps @amichuda!