Skip to content

Commit b55f262

Browse files
committed
feat: initial commit
First commit, basic functionality, not complete
1 parent 04e0fdd commit b55f262

24 files changed

Lines changed: 5848 additions & 0 deletions

.editorconfig

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# top-most EditorConfig file
2+
root = true
3+
4+
[*]
5+
charset = utf-8
6+
end_of_line = lf
7+
insert_final_newline = true
8+
indent_style = tab
9+
indent_size = 4
10+
tab_width = 4

.github/workflows/lint.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Node.js build
2+
3+
on:
4+
push:
5+
branches: ["**"]
6+
pull_request:
7+
branches: ["**"]
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
13+
strategy:
14+
matrix:
15+
node-version: [20.x, 22.x]
16+
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
17+
18+
steps:
19+
- uses: actions/checkout@v4
20+
- name: Use Node.js ${{ matrix.node-version }}
21+
uses: actions/setup-node@v4
22+
with:
23+
node-version: ${{ matrix.node-version }}
24+
cache: "npm"
25+
- run: npm ci
26+
- run: npm run build --if-present
27+
- run: npm run lint
28+

.gitignore

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# vscode
2+
.vscode
3+
4+
# Intellij
5+
*.iml
6+
.idea
7+
8+
# npm
9+
node_modules
10+
11+
# Don't include the compiled main.js file in the repo.
12+
# They should be uploaded to GitHub releases instead.
13+
main.js
14+
15+
# Exclude sourcemaps
16+
*.map
17+
18+
# obsidian
19+
data.json
20+
21+
# Exclude macOS Finder (System Explorer) View States
22+
.DS_Store

.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
tag-version-prefix=""

.wakatime-project

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
note-thumbnails

LICENSE

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Copyright (C) 2020-2025 by Dynalist Inc.
2+
3+
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted.
4+
5+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

README.md

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
# Obsidian Sample Plugin
2+
3+
This is a sample plugin for Obsidian (https://obsidian.md).
4+
5+
This project uses TypeScript to provide type checking and documentation.
6+
The repo depends on the latest plugin API (obsidian.d.ts) in TypeScript Definition format, which contains TSDoc comments describing what it does.
7+
8+
This sample plugin demonstrates some of the basic functionality the plugin API can do.
9+
- Adds a ribbon icon, which shows a Notice when clicked.
10+
- Adds a command "Open modal (simple)" which opens a Modal.
11+
- Adds a plugin setting tab to the settings page.
12+
- Registers a global click event and output 'click' to the console.
13+
- Registers a global interval which logs 'setInterval' to the console.
14+
15+
## First time developing plugins?
16+
17+
Quick starting guide for new plugin devs:
18+
19+
- Check if [someone already developed a plugin for what you want](https://obsidian.md/plugins)! There might be an existing plugin similar enough that you can partner up with.
20+
- Make a copy of this repo as a template with the "Use this template" button (login to GitHub if you don't see it).
21+
- Clone your repo to a local development folder. For convenience, you can place this folder in your `.obsidian/plugins/your-plugin-name` folder.
22+
- Install NodeJS, then run `npm i` in the command line under your repo folder.
23+
- Run `npm run dev` to compile your plugin from `main.ts` to `main.js`.
24+
- Make changes to `main.ts` (or create new `.ts` files). Those changes should be automatically compiled into `main.js`.
25+
- Reload Obsidian to load the new version of your plugin.
26+
- Enable plugin in settings window.
27+
- For updates to the Obsidian API run `npm update` in the command line under your repo folder.
28+
29+
## Releasing new releases
30+
31+
- Update your `manifest.json` with your new version number, such as `1.0.1`, and the minimum Obsidian version required for your latest release.
32+
- Update your `versions.json` file with `"new-plugin-version": "minimum-obsidian-version"` so older versions of Obsidian can download an older version of your plugin that's compatible.
33+
- Create new GitHub release using your new version number as the "Tag version". Use the exact version number, don't include a prefix `v`. See here for an example: https://github.com/obsidianmd/obsidian-sample-plugin/releases
34+
- Upload the files `manifest.json`, `main.js`, `styles.css` as binary attachments. Note: The manifest.json file must be in two places, first the root path of your repository and also in the release.
35+
- Publish the release.
36+
37+
> You can simplify the version bump process by running `npm version patch`, `npm version minor` or `npm version major` after updating `minAppVersion` manually in `manifest.json`.
38+
> The command will bump version in `manifest.json` and `package.json`, and add the entry for the new version to `versions.json`
39+
40+
## Adding your plugin to the community plugin list
41+
42+
- Check the [plugin guidelines](https://docs.obsidian.md/Plugins/Releasing/Plugin+guidelines).
43+
- Publish an initial version.
44+
- Make sure you have a `README.md` file in the root of your repo.
45+
- Make a pull request at https://github.com/obsidianmd/obsidian-releases to add your plugin.
46+
47+
## How to use
48+
49+
- Clone this repo.
50+
- Make sure your NodeJS is at least v16 (`node --version`).
51+
- `npm i` or `yarn` to install dependencies.
52+
- `npm run dev` to start compilation in watch mode.
53+
54+
## Manually installing the plugin
55+
56+
- Copy over `main.js`, `styles.css`, `manifest.json` to your vault `VaultFolder/.obsidian/plugins/your-plugin-id/`.
57+
58+
## Improve code quality with eslint
59+
- [ESLint](https://eslint.org/) is a tool that analyzes your code to quickly find problems. You can run ESLint against your plugin to find common bugs and ways to improve your code.
60+
- This project already has eslint preconfigured, you can invoke a check by running`npm run lint`
61+
- Together with a custom eslint [plugin](https://github.com/obsidianmd/eslint-plugin) for Obsidan specific code guidelines.
62+
- A GitHub action is preconfigured to automatically lint every commit on all branches.
63+
64+
## Funding URL
65+
66+
You can include funding URLs where people who use your plugin can financially support it.
67+
68+
The simple way is to set the `fundingUrl` field to your link in your `manifest.json` file:
69+
70+
```json
71+
{
72+
"fundingUrl": "https://buymeacoffee.com"
73+
}
74+
```
75+
76+
If you have multiple URLs, you can also do:
77+
78+
```json
79+
{
80+
"fundingUrl": {
81+
"Buy Me a Coffee": "https://buymeacoffee.com",
82+
"GitHub Sponsor": "https://github.com/sponsors",
83+
"Patreon": "https://www.patreon.com/"
84+
}
85+
}
86+
```
87+
88+
## API Documentation
89+
90+
See https://docs.obsidian.md

esbuild.config.mjs

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import esbuild from "esbuild";
2+
import process from "process";
3+
import { builtinModules } from 'node:module';
4+
5+
const banner =
6+
`/*
7+
THIS IS A GENERATED/BUNDLED FILE BY ESBUILD
8+
if you want to view the source, please visit the github repository of this plugin
9+
*/
10+
`;
11+
12+
const prod = (process.argv[2] === "production");
13+
14+
const context = await esbuild.context({
15+
banner: {
16+
js: banner,
17+
},
18+
entryPoints: ["src/main.ts"],
19+
bundle: true,
20+
external: [
21+
"obsidian",
22+
"electron",
23+
"@codemirror/autocomplete",
24+
"@codemirror/collab",
25+
"@codemirror/commands",
26+
"@codemirror/language",
27+
"@codemirror/lint",
28+
"@codemirror/search",
29+
"@codemirror/state",
30+
"@codemirror/view",
31+
"@lezer/common",
32+
"@lezer/highlight",
33+
"@lezer/lr",
34+
...builtinModules],
35+
format: "cjs",
36+
target: "es2018",
37+
logLevel: "info",
38+
sourcemap: prod ? false : "inline",
39+
treeShaking: true,
40+
outfile: "main.js",
41+
minify: prod,
42+
});
43+
44+
if (prod) {
45+
await context.rebuild();
46+
process.exit(0);
47+
} else {
48+
await context.watch();
49+
}

eslint.config.mts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import tseslint from 'typescript-eslint';
2+
import obsidianmd from "eslint-plugin-obsidianmd";
3+
import globals from "globals";
4+
import { globalIgnores } from "eslint/config";
5+
6+
export default tseslint.config(
7+
{
8+
languageOptions: {
9+
globals: {
10+
...globals.browser,
11+
},
12+
parserOptions: {
13+
projectService: {
14+
allowDefaultProject: [
15+
'eslint.config.js',
16+
'manifest.json'
17+
]
18+
},
19+
tsconfigRootDir: import.meta.dirname,
20+
extraFileExtensions: ['.json']
21+
},
22+
},
23+
},
24+
...obsidianmd.configs.recommended,
25+
globalIgnores([
26+
"node_modules",
27+
"dist",
28+
"esbuild.config.mjs",
29+
"eslint.config.js",
30+
"version-bump.mjs",
31+
"versions.json",
32+
"main.js",
33+
]),
34+
);

manifest.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"id": "note-thumbnails",
3+
"name": "Note Thumbnails",
4+
"version": "0.1.0",
5+
"minAppVersion": "0.15.0",
6+
"description": "Generates snapshots of notes to use as thumbnails in the cards layout for Bases.",
7+
"author": "infinity6542",
8+
"authorUrl": "https://obsidiahttps://github.com/infinity6542",
9+
"isDesktopOnly": false
10+
}

0 commit comments

Comments
 (0)