-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e244d1c
commit 4cff744
Showing
8 changed files
with
246 additions
and
31 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { NoteProvider } from '.' | ||
|
||
export default class Stashpad extends NoteProvider { | ||
apiKey: string | ||
|
||
constructor(apiKey) { | ||
super() | ||
this.apiKey = apiKey | ||
} | ||
|
||
create({ content }) { | ||
return fetch('https://api.stashpad.live/v1/docs', { | ||
method: 'POST', | ||
headers: { | ||
'Content-Type': 'application/json', | ||
'X-API-Key': this.apiKey, | ||
}, | ||
body: JSON.stringify({ | ||
content, | ||
access: 'public', | ||
permission: 'write', | ||
}), | ||
}) | ||
.then(response => response.json()) | ||
.then(({ uri }) => uri) | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
enum NoteProviders { | ||
Stashpad = 'stashpad', | ||
Obsidian = 'obsidian', | ||
} | ||
|
||
export abstract class NoteProvider { | ||
abstract create({ content }): Promise<string> | ||
} | ||
|
||
export default NoteProviders |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import useSettings from '../settings/useSettings' | ||
import NoteProviders from './providers' | ||
import Stashpad from './providers/Stashpad' | ||
|
||
export default function useNoteProvider() { | ||
const noteProviderSettings = useSettings('#noteProvider') | ||
|
||
if (noteProviderSettings?.type === NoteProviders.Stashpad) { | ||
return new Stashpad(noteProviderSettings.apiKey) | ||
} | ||
return null | ||
} |
Oops, something went wrong.