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') | |
} |
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
This was the missing step, thank you!