mirror of
https://github.com/gapmiss/substack-clipper.git
synced 2026-07-22 07:48:24 +00:00
feat: add obsidian:// URI handler for saving posts via protocol link
This commit is contained in:
parent
cd4cfb0802
commit
882487103f
2 changed files with 28 additions and 0 deletions
16
README.md
16
README.md
|
|
@ -61,6 +61,22 @@ Substacks/
|
|||
|
||||
The main note includes frontmatter with title, subtitle, type, audience, date, comment count, and links to all media. Comments are embedded via `![[slug-comments]]`.
|
||||
|
||||
### URI protocol
|
||||
|
||||
You can save a post directly via an `obsidian://` URI without opening the command palette:
|
||||
|
||||
```
|
||||
obsidian://substack-clipper?vault=MyVault&url=https://alice.substack.com/p/my-article
|
||||
```
|
||||
|
||||
| Parameter | Required | Description |
|
||||
|-----------|----------|-------------|
|
||||
| `vault` | no | Target vault name (Obsidian prompts if omitted and multiple vaults exist) |
|
||||
| `url` | yes | Full Substack post URL (must contain `/p/`) |
|
||||
| `open` | no | `true` or `false` — override the "open after saving" setting |
|
||||
|
||||
Spaces in vault names should be percent-encoded (`%20`). This works from browsers, scripts, iOS Shortcuts, bookmarklets, and anywhere else that can open a URL.
|
||||
|
||||
## Settings
|
||||
|
||||
| Setting | Default | Description |
|
||||
|
|
|
|||
12
src/main.ts
12
src/main.ts
|
|
@ -40,6 +40,18 @@ export default class SubstackClipperPlugin extends Plugin {
|
|||
void this.activateHistoryView();
|
||||
},
|
||||
});
|
||||
|
||||
this.registerObsidianProtocolHandler('substack-clipper', (params) => {
|
||||
const url = params.url;
|
||||
if (!url || !url.includes('/p/')) {
|
||||
new Notice('Invalid substack-clipper uri — a "URL" parameter containing /p/ is required.');
|
||||
return;
|
||||
}
|
||||
const openAfterClip = params.open === 'true' ? true
|
||||
: params.open === 'false' ? false
|
||||
: this.settings.openAfterClip;
|
||||
void this.clipPost(url, openAfterClip);
|
||||
});
|
||||
}
|
||||
|
||||
async activateHistoryView(): Promise<void> {
|
||||
|
|
|
|||
Loading…
Reference in a new issue