Skip to content

Commit

Permalink
Add search box for icons; fixes #37
Browse files Browse the repository at this point in the history
  • Loading branch information
mgmeyers committed Oct 15, 2023
1 parent 0f69137 commit fdca177
Show file tree
Hide file tree
Showing 7 changed files with 4,885 additions and 75 deletions.
78 changes: 21 additions & 57 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,70 +1,34 @@
name: Release Obsidian Plugin
name: Release Obsidian plugin

on:
push:
tags:
- '*'

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0 # otherwise, you will failed to push refs to dest repo
- uses: actions/checkout@v3

- name: Use Node.js
uses: actions/setup-node@v1
uses: actions/setup-node@v3
with:
node-version: '14.x'
- name: Get Version
id: version
run: |
echo "::set-output name=tag::$(git describe --abbrev=0)"
- name: Build
id: build
node-version: '18.x'

- name: Build plugin
run: |
yarn
yarn run build
# Create the release on github
- name: Create Release
id: create_release
uses: actions/create-release@v1
npm install
npm run build
- name: Create release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
VERSION: ${{ github.ref }}
with:
tag_name: ${{ github.ref }}
release_name: ${{ github.ref }}
draft: false
prerelease: false
# Upload the main.js
- name: Upload main.js
id: upload-main
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./main.js
asset_name: main.js
asset_content_type: text/javascript
# Upload the manifest.json
- name: Upload manifest.json
id: upload-manifest
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./manifest.json
asset_name: manifest.json
asset_content_type: application/json
# Upload the style.css
- name: Upload styles.css
id: upload-css
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./styles.css
asset_name: styles.css
asset_content_type: text/css
run: |
tag="${GITHUB_REF#refs/tags/}"
gh release create "$tag" \
--title="$tag" \
--notes-file="release-notes.md" \
main.js manifest.json styles.css
62 changes: 62 additions & 0 deletions make-icon-list.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import fs from 'fs';

function readFiles(dirname, onFileContent, onError, done) {
fs.readdir(dirname, function (err, filenames) {
if (err) {
onError(err);
return;
}

for (let filename of filenames) {
if (!filename.endsWith('.json')) continue;
const content = fs.readFileSync(dirname + filename);
onFileContent(filename, JSON.parse(content.toString()));
}

done();
});
}

const iconList = [];

readFiles(
'../lucide/icons/',
function (filename, content) {
const id = filename.split('.')[0];
const tags = content.tags || [];
const aliases = content.aliases || [];

iconList.push({
id: 'lucide-' + id,
aliases: [...tags, ...aliases],
});
},
function (err) {
throw err;
},
function () {
fs.writeFileSync(
'./src/iconList.ts',
`import Fuse from 'fuse.js';
import { getIconIds } from 'obsidian';
export const iconListRaw = ${JSON.stringify(iconList, null, 2)};
getIconIds().forEach(id => {
if (!/^lucide/.test(id)) {
iconListRaw.push({
id,
aliases: [],
})
}
})
export const iconList = new Fuse(iconListRaw, {
threshold: 0.1,
minMatchCharLength: 2,
keys: ['id', 'aliases'],
});
`
);
}
);
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "obsidian-list-callouts",
"version": "1.1.5",
"version": "1.2.0",
"description": "Create simple callouts in lists.",
"main": "main.js",
"scripts": {
Expand Down Expand Up @@ -34,6 +34,7 @@
"typescript": "4.4.4"
},
"dependencies": {
"escape-string-regexp": "^5.0.0"
"escape-string-regexp": "^5.0.0",
"fuse.js": "^6.6.2"
}
}
Loading

0 comments on commit fdca177

Please sign in to comment.