timrogers / obsidian-share-as-gist

An Obsidian (https://obsidian.md/) plugin for sharing your notes as a GitHub gist - either privately or publicly.
MIT License
75 stars 7 forks source link
github obsidian obsidian-md obsidian-plugin

"Share as Gist" Obsidian plugin

This plugin for Obsidian (https://obsidian.md) allows you to share your notes as GitHub Gists

Usage

  1. Install the plugin.
  2. Create a GitHub personal access token on GitHub.com or your GitHub Enterprise Server instance. You can use a classic personal access token (PAT) with the gist scope, or a new fine-grained token with read-write access to your Gists.
Screenshot 2022-06-09 at 09 47 43
  1. Open "Settings" in Obsidian, then go to "Share as Gist" in the "Plugin Options" tab.
Screenshot 2022-07-21 at 09 10 52
  1. Paste the access token into the relevant field. There are different sections for GitHub.com and GitHub Enterprise Server.

  2. If you're using GitHub Enterprise Server, fill in the API base URL of your instance, ending with /api/v3 (e.g. https://github.business.com/api/v3).

  3. To share a note, open the Command Palette and type "gist". You'll see commands for creating a public and private link. Pick the one you want and hit enter.

Screenshot 2022-07-21 at 09 12 16
  1. Optionally, add a custom description for your gist, and hit Enter. You can skip this and accept the default by hitting Enter immediately.

Screenshot 2024-05-16 at 20 35 55

  1. Your gist will be created, and the URL for sharing will be added to your clipboard.

  2. Make a change to your note.

  3. If the "Enable auto-saving Gists after edit" setting is turned on, your changes will automatically be reflected in your gist. If not, you can use the "Share as [public|private] gist on GitHub.com" command" again to update your gist, or create a fresh one.

  4. If you want to get the URL of your gist after creating it, open the Command Palette and type "gist". Pick the "Copy gist URL" command. If you have multiple gists for your note, you'll have to pick which one you want the URL for.

  5. To open your gist after creating it, open the Command Palette and find the "Open gist" command. If you have multiple gists for your note, you'll have to pick which one you want to open.

Customisable settings

Securing your GitHub personal access token(s)

Your GitHub access token(s) will be stored in Obsidian's localStorage.

This means that it will not be stored in a file and will not be backed up or synced with the rest of your Vault. But it is theoretically possible for other Obsidian plugins to access it.

For your security, you should make sure that you give your personal access token the lowest possible permissions. This will mean that your token will not have access to your code or other sensitive data.

Contributing

  1. Clone this repo into the .obsidian/plugins directory in your Obsidian vault.
  2. Navigate to the obsidian-share-as-gist directory you've just cloned.
  3. Install the dependencies by running npm i.
  4. Start a process to automatically build your plugin when you make changes by running npm run dev.
  5. Make changes, and test them in Obsidian. You will have to manually reload the plugin from the "Community plugins" screen when you make a change.
  6. Push your changes to the repo if you have access or your own fork, and create a pull request.

Releasing

  1. Work out the next version number. We use semantic versioning.
  2. Add an entry to CHANGELOG.md, describing your changes.
  3. Update the version number in package.json.
  4. Update versions.json, defining what minimum Obsidian version your plugin is compatible with. In general, copying the last entry in the file should be fine.
  5. Run npm run version.
  6. Commit manifest.json and package.json. In the commit message, make the version number the title, (e.g. 1.0.1) and copy your changelog entry into the body.
  7. Tag your commit with the version number, e.g. git tag -a 1.0.1 -m '1.0.1'.
  8. Push your changes, including tags.
  9. A workflow will automatically run in GitHub Actions to build and publish a release.