mirror of
https://github.com/nathonius/obsidian-github-link.git
synced 2026-07-22 09:20:25 +00:00
commit
201099127c
7 changed files with 61 additions and 4180 deletions
48
README.md
48
README.md
|
|
@ -2,10 +2,56 @@
|
|||
|
||||
**Obsidian + GitHub ❤️**
|
||||
|
||||
Transform boring GitHub links in notes into badges with rich content from GitHub's API.
|
||||
Transform boring GitHub links in notes into tags with rich content from GitHub's API.
|
||||
|
||||
## Use
|
||||
|
||||
### Links
|
||||
|
||||
Github links are automatically transformed into tags. For example, pasting `https://github.com/nathonius/obsidian-github-link/issues/1` into a note will become:
|
||||
|
||||

|
||||
|
||||
### Table
|
||||
|
||||
You can also include a table with results from a search query using a `github-query` codeblock. For example:
|
||||
|
||||
````
|
||||
```github-query
|
||||
outputType: table
|
||||
queryType: pull-request
|
||||
query: "is:pr repo:nathonius/obsidian-github-link"
|
||||
columns: [number, title, author, status]
|
||||
```
|
||||
````
|
||||
|
||||
This produces a table of results that refreshes upon opening the note.
|
||||
|
||||

|
||||
|
||||
The codeblock must be valid YAML. The following options are currently supported:
|
||||
|
||||
| Option | Values | Description |
|
||||
| ------------ | ---------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
||||
| `outputType` | `table` | Required. Only table is currently supported. |
|
||||
| `queryType` | `pull-request` | Required. Only pull requests are currently supported. |
|
||||
| `query` | A valid GitHub search query. | Required. See the [GitHub docs](https://docs.github.com/en/search-github/searching-on-github/searching-issues-and-pull-requests) for more information. |
|
||||
| `columns` | See list below. | Required. Should be an array of values. |
|
||||
|
||||
#### Supported Columns
|
||||
|
||||
Any column not listed below can still be used if it is included in the API response. Nested values can be used by giving the json object notation string to reference the value. For example, `user.login` will get the raw value of the username from the API query response.
|
||||
|
||||
| Column | Types | Description |
|
||||
| ------------------------------ | -------------- | -------------------------------------------------------------- |
|
||||
| `number` | `pull-request` | The PR number and a link to the PR. |
|
||||
| `repo` | `pull-request` | A link to the repository. |
|
||||
| `author` | `pull-request` | The user who created the PR along with a small avatar. |
|
||||
| `status` | `pull-request` | The current status of the pull request. |
|
||||
| `created`, `updated`, `closed` | `pull-request` | Formatted versions of the create, last update, and close date. |
|
||||
|
||||
## Setup
|
||||
|
||||
For public repositories, no extra configuration is required. For private repos, you'll need to log in through GitHub.
|
||||
|
||||
### Authentication
|
||||
|
|
|
|||
BIN
doc/ExampleInlineTag.png
Executable file
BIN
doc/ExampleInlineTag.png
Executable file
Binary file not shown.
|
After Width: | Height: | Size: 3.6 KiB |
BIN
doc/ExampleQueryResult.png
Executable file
BIN
doc/ExampleQueryResult.png
Executable file
Binary file not shown.
|
After Width: | Height: | Size: 66 KiB |
|
|
@ -3,6 +3,8 @@ import type { CodeResponse, IssueResponse, PullResponse, SearchIssueResponse, Se
|
|||
import type { RequestUrlParam } from "obsidian";
|
||||
import { requestUrl } from "obsidian";
|
||||
|
||||
const debug = false;
|
||||
|
||||
const baseApi = "https://api.github.com";
|
||||
|
||||
async function githubRequest(config: RequestUrlParam, token?: string) {
|
||||
|
|
@ -14,8 +16,14 @@ async function githubRequest(config: RequestUrlParam, token?: string) {
|
|||
if (token) {
|
||||
config.headers.Authorization = `Bearer ${token}`;
|
||||
}
|
||||
if (debug) {
|
||||
console.log(config);
|
||||
}
|
||||
try {
|
||||
const response = await requestUrl(config);
|
||||
if (debug) {
|
||||
console.log(response);
|
||||
}
|
||||
return response;
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
|
|
|
|||
|
|
@ -1,8 +1,7 @@
|
|||
import { type MarkdownPostProcessorContext } from "obsidian";
|
||||
import { isTableParams, processParams } from "./params";
|
||||
import samplePRResponse from "./samplePRResponse";
|
||||
import { isPullRequestParams, isTableParams, processParams } from "./params";
|
||||
import { renderTable } from "./output";
|
||||
import type { SearchIssueResponse } from "src/github/response";
|
||||
import { searchIssues } from "src/github/github";
|
||||
|
||||
export async function QueryProcessor(
|
||||
source: string,
|
||||
|
|
@ -17,9 +16,10 @@ export async function QueryProcessor(
|
|||
return;
|
||||
}
|
||||
|
||||
// TODO: Get result
|
||||
|
||||
if (isTableParams(params)) {
|
||||
renderTable(params, samplePRResponse as SearchIssueResponse, el);
|
||||
if (isPullRequestParams(params)) {
|
||||
const response = await searchIssues(params.query);
|
||||
renderTable(params, response, el);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue