{"id":19476210,"url":"https://github.com/siyuan-note/plugin-sample-vite-svelte","last_synced_at":"2025-04-25T14:32:15.028Z","repository":{"id":167225014,"uuid":"642805526","full_name":"siyuan-note/plugin-sample-vite-svelte","owner":"siyuan-note","description":"SiYuan plugin sample with vite and svelte","archived":false,"fork":false,"pushed_at":"2024-12-10T10:00:26.000Z","size":239,"stargazers_count":42,"open_issues_count":0,"forks_count":19,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-03T22:41:41.576Z","etag":null,"topics":["plugin","siyuan","svelte","vite"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/siyuan-note.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-05-19T11:40:28.000Z","updated_at":"2025-04-01T14:41:38.000Z","dependencies_parsed_at":"2024-04-19T12:27:31.815Z","dependency_job_id":"584747ca-dc8f-4efb-8308-99c966a4395b","html_url":"https://github.com/siyuan-note/plugin-sample-vite-svelte","commit_stats":null,"previous_names":["siyuan-note/plugin-sample-vite-svelte"],"tags_count":20,"template":true,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/siyuan-note%2Fplugin-sample-vite-svelte","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/siyuan-note%2Fplugin-sample-vite-svelte/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/siyuan-note%2Fplugin-sample-vite-svelte/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/siyuan-note%2Fplugin-sample-vite-svelte/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/siyuan-note","download_url":"https://codeload.github.com/siyuan-note/plugin-sample-vite-svelte/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250834153,"owners_count":21494919,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["plugin","siyuan","svelte","vite"],"created_at":"2024-11-10T19:37:32.082Z","updated_at":"2025-04-25T14:32:13.354Z","avatar_url":"https://github.com/siyuan-note.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# SiYuan plugin sample with vite and svelte\n\n[中文版](./README_zh_CN.md)\n\n\u003e Consistent with [siyuan/plugin-sample](https://github.com/siyuan-note/plugin-sample) [v0.3.5](https://github.com/siyuan-note/plugin-sample/tree/v0.3.5)\n\n\n\n1. Using vite for packaging\n2. Use symbolic linking instead of putting the project into the plugins directory program development\n3. Built-in support for the svelte framework\n\n     \u003e **If don't want svelte, turn to this template**: [frostime/plugin-sample-vite](https://github.com/frostime/plugin-sample-vite)\n     \u003e\n     \u003e **We also provide with a vite+solidjs template**: [frostime/plugin-sample-vite-solidjs](https://github.com/frostime/plugin-sample-vite-solidjs)\n\n4. Provides a github action template to automatically generate package.zip and upload to new release\n\n\n\u003e [!TIP]\n\u003e You can also use our maintained [siyuan-plugin-cli](https://www.npmjs.com/package/siyuan-plugin-cli) command-line tool to directly build plugins in your local terminal.\n\u003e\n\u003e Additionally, for the `make-link` related commands mentioned in this plugin, all future updates will be made in [siyuan-plugin-cli](https://www.npmjs.com/package/siyuan-plugin-cli).\n\u003e\n\u003e The built-in `make-link` scripts may also be removed in a future version, in favor of using the `siyuan-plugin-cli` tool, aiming to simplify the workload of maintaining multiple plugin templates.\n\n\n## Get started\n\n1. Use the \u003ckbd\u003eUse this template\u003c/kbd\u003e button to make a copy of this repo as a template. Note that the repository name should match the plugin name, and the default branch must be `main`.\n2. Clone your repository to the local development folder.\n    * Note: Unlike `plugin-sample`, this example does not recommend directly downloading the code to `{workspace}/data/plugins/`.\n3. Install [NodeJS](https://nodejs.org/en/download) and [pnpm](https://pnpm.io/installation), then run `pnpm i` in the development folder to install the required dependencies.\n4. Run the `pnpm run make-link` command to create a symbolic link (Windows developers, please refer to the \"make-link on Windows\" section below).\n5. Execute `pnpm run dev` for real-time compilation.\n6. Open the marketplace in SiYuan and enable the plugin in the download tab.\n\n### Setting the Target Directory for the make-link Command\n\nThe `make-link` command creates a symbolic link that binds your `dev` directory to the SiYuan plugin directory. You can configure the target SiYuan workspace and create the symbolic link in three ways:\n\n1. **Select Workspace**\n    - Open SiYuan, ensure the SiYuan kernel is running.\n    - Run `pnpm run make-link`, the script will automatically detect all SiYuan workspaces, please manually enter the number to select the workspace.\n        ```bash\n        \u003e\u003e\u003e pnpm run make-link\n        \u003e plugin-sample-vite-svelte@0.0.3 make-link H:\\SrcCode\\开源项目\\plugin-sample-vite-svelte\n        \u003e node  --no-warnings ./scripts/make_dev_link.js\n\n        \"targetDir\" is empty, try to get SiYuan directory automatically....\n        Got 2 SiYuan workspaces\n        [0] H:\\Media\\SiYuan\n        [1] H:\\临时文件夹\\SiYuanDevSpace\n        Please select a workspace[0-1]: 0\n        Got target directory: H:\\Media\\SiYuan/data/plugins\n        Done! Created symlink H:\\Media\\SiYuan/data/plugins/plugin-sample-vite-svelte\n        ```\n2. **Manually Configure Target Directory**\n    - Open the `./scripts/make_dev_link.js` file, change `targetDir` to the SiYuan plugin directory `\u003csiyuan workspace\u003e/data/plugins`.\n    - Run the `pnpm run make-link` command. If you see a message similar to the one below, it indicates successful creation:\n\n3. **Set Environment Variable to Create Symbolic Link**\n    - Set the system environment variable `SIYUAN_PLUGIN_DIR` to the path `workspace/data/plugins`.\n\n### make-link on Windows\n\nDue to SiYuan upgrading to Go 1.23, the old version of junction links cannot be recognized normally on Windows, so it has been changed to create `dir` symbolic links.\n\n\u003e https://github.com/siyuan-note/siyuan/issues/12399\n\nHowever, creating directory symbolic links on Windows using NodeJs may require administrator privileges. You have the following options:\n\n1. Run `pnpm run make-link` in a command line with administrator privileges.\n2. Configure Windows settings, enable developer mode in [System Settings - Update \u0026 Security - Developer Mode] then run `pnpm run make-link`.\n3. Run `pnpm run make-link-win`, this command will use a PowerShell script to request administrator privileges, requiring the system to enable PowerShell script execution permissions.\n\n## I18n\n\nIn terms of internationalization, our main consideration is to support multiple languages. Specifically, we need to\ncomplete the following tasks:\n\n* Meta information about the plugin itself, such as plugin description and readme\n    * `description` and `readme` fields in plugin.json, and the corresponding README*.md file\n* Text used in the plugin, such as button text and tooltips\n    * public/i18n/*.json language configuration files\n    * Use `this.i18.key` to get the text in the code\n* YAML Support\n  * This template specifically supports I18n based on YAML syntax, see `public/i18n/zh_CN.yaml`\n  * During compilation, the defined YAML files will be automatically translated into JSON files and placed in the dist or dev directory.\n\nIt is recommended that the plugin supports at least English and Simplified Chinese, so that more people can use it more\nconveniently.\n\n## plugin.json\n\n```json\n{\n  \"name\": \"plugin-sample-vite-svelte\",\n  \"author\": \"frostime\",\n  \"url\": \"https://github.com/siyuan-note/plugin-sample-vite-svelte\",\n  \"version\": \"0.1.3\",\n  \"minAppVersion\": \"2.8.8\",\n  \"backends\": [\"windows\", \"linux\", \"darwin\"],\n  \"frontends\": [\"desktop\"],\n  \"displayName\": {\n    \"en_US\": \"Plugin sample with vite and svelte\",\n    \"zh_CN\": \"插件样例 vite + svelte 版\"\n  },\n  \"description\": {\n    \"en_US\": \"SiYuan plugin sample with vite and svelte\",\n    \"zh_CN\": \"使用 vite 和 svelte 开发的思源插件样例\"\n  },\n  \"readme\": {\n    \"en_US\": \"README_en_US.md\",\n    \"zh_CN\": \"README.md\"\n  },\n  \"funding\": {\n    \"openCollective\": \"\",\n    \"patreon\": \"\",\n    \"github\": \"\",\n    \"custom\": [\n      \"https://ld246.com/sponsor\"\n    ]\n  },\n  \"keywords\": [\n    \"sample\", \"示例\"\n  ]\n}\n```\n\n* `name`: Plugin name, must be the same as the repo name, and must be unique globally (no duplicate plugin names in the\n  marketplace)\n* `author`: Plugin author name\n* `url`: Plugin repo URL\n* `version`: Plugin version number, it is recommended to follow the [semver](https://semver.org/) specification\n* `minAppVersion`: Minimum version number of SiYuan required to use this plugin\n* `backends`: Backend environment required by the plugin, optional values are `windows`, `linux`, `darwin`, `docker`, `android`, `ios` and `all`\n  * `windows`: Windows desktop\n  * `linux`: Linux desktop\n  * `darwin`: macOS desktop\n  * `docker`: Docker\n  * `android`: Android APP\n  * `ios`: iOS APP\n  * `all`: All environments\n* `frontends`: Frontend environment required by the plugin, optional values are `desktop`, `desktop-window`, `mobile`, `browser-desktop`, `browser-mobile` and `all`\n  * `desktop`: Desktop\n  * `desktop-window`: Desktop window converted from tab\n  * `mobile`: Mobile APP\n  * `browser-desktop`: Desktop browser\n  * `browser-mobile`: Mobile browser\n  * `all`: All environments\n* `displayName`: Template display name, mainly used for display in the marketplace list, supports multiple languages\n    * `default`: Default language, must exist\n    * `zh_CN`, `en_US` and other languages: optional, it is recommended to provide at least Chinese and English\n* `description`: Plugin description, mainly used for display in the marketplace list, supports multiple languages\n    * `default`: Default language, must exist\n    * `zh_CN`, `en_US` and other languages: optional, it is recommended to provide at least Chinese and English\n* `readme`: readme file name, mainly used to display in the marketplace details page, supports multiple languages\n    * `default`: Default language, must exist\n    * `zh_CN`, `en_US` and other languages: optional, it is recommended to provide at least Chinese and English\n* `funding`: Plugin sponsorship information\n    * `openCollective`: Open Collective name\n    * `patreon`: Patreon name\n    * `github`: GitHub login name\n    * `custom`: Custom sponsorship link list\n* `keywords`: Search keyword list, used for marketplace search function\n\n## Package\n\nNo matter which method is used to compile and package, we finally need to generate a package.zip, which contains at\nleast the following files:\n\n* i18n/*\n* icon.png (160*160)\n* index.css\n* index.js\n* plugin.json\n* preview.png (1024*768)\n* README*.md\n\n## List on the marketplace\n\n* `pnpm run build` to generate package.zip\n* Create a new GitHub release using your new version number as the \"Tag version\". See here for an\n  example: https://github.com/siyuan-note/plugin-sample/releases\n* Upload the file package.zip as binary attachments\n* Publish the release\n\nIf it is the first release, please create a pull request to\nthe [Community Bazaar](https://github.com/siyuan-note/bazaar) repository and modify the plugins.json file in it. This\nfile is the index of all community plugin repositories, the format is:\n\n```json\n{\n  \"repos\": [\n    \"username/reponame\"\n  ]\n}\n```\n\nAfter the PR is merged, the bazaar will automatically update the index and deploy through GitHub Actions. When releasing\na new version of the plugin in the future, you only need to follow the above steps to create a new release, and you\ndon't need to PR the community bazaar repo.\n\nUnder normal circumstances, the community bazaar repo will automatically update the index and deploy every hour,\nand you can check the deployment status at https://github.com/siyuan-note/bazaar/actions.\n\n## Use Github Action\n\nThe github action is included in this sample, you can use it to publish your new realse to marketplace automatically:\n\n1. In your repo setting page `https://github.com/OWNER/REPO/settings/actions`, down to **Workflow Permissions** and open the configuration like this:\n\n    ![](asset/action.png)\n\n2. Push a tag in the format `v*` and github will automatically create a new release with new bulit package.zip\n\n3. By default, it will only publish a pre-release, if you don't think this is necessary, change the settings in release.yml\n\n    ```yaml\n    - name: Release\n        uses: ncipollo/release-action@v1\n        with.\n            allowUpdates: true\n            artifactErrorsFailBuild: true\n            artifacts: 'package.zip'\n            token: ${{ secrets.GITHUB_TOKEN }}\n            prerelease: true # change this to false\n    ```\n\n\n## How to remove svelte dependencies\n\n\u003e Pure vite without svelte: https://github.com/frostime/plugin-sample-vite\n\nThis plugin is packaged in vite and provides a dependency on the svelte framework. However, in practice some developers may not want to use svelte and only want to use the vite package.\n\nIn fact you can use this template without using svelte without any modifications at all. The compilation-related parts of the svelte compilation are loaded into the vite workflow as plugins, so even if you don't have svelte in your project, it won't matter much.\n\nIf you insist on removing all svelte dependencies so that they do not pollute your workspace, you can perform the following steps. 1.\n\n1. delete the\n    ```json\n    {\n      \"@sveltejs/vite-plugin-svelte\": \"^2.0.3\",\n      \"@tsconfig/svelte\": \"^4.0.1\",\n      \"svelte\": \"^3.57.0\"\n    }\n    ```\n2. delete the `svelte.config.js` file\n3. delete the following line from the `vite.config.js` file\n    - Line 6: `import { svelte } from \"@sveltejs/vite-plugin-svelte\"`\n    - Line 20: `svelte(),`\n4. delete line 37 of `tsconfig.json` from `\"svelte\"` 5.\n5. re-run `pnpm i`\n\n## Developer's Guide\n\nDevelopers of SiYuan need to pay attention to the following specifications.\n\n### 1. File Reading and Writing Specifications\n\nIf plugins or external extensions require direct reading or writing of files under the `data` directory, please use the kernel API to achieve this. **Do not call `fs` or other electron or nodejs APIs directly**, as it may result in data loss during synchronization and cause damage to cloud data.\n\nRelated APIs can be found at: `/api/file/*` (e.g., `/api/file/getFile`).\n\n### 2. Daily Note Attribute Specifications\n\nWhen creating a daily note in SiYuan, a custom-dailynote-yyyymmdd attribute will be automatically added to the document to distinguish it from regular documents.\n\n\u003e For more details, please refer to [Github Issue #9807](https://github.com/siyuan-note/siyuan/issues/9807).\n\nDevelopers should pay attention to the following when developing the functionality to manually create Daily Notes:\n\n* If `/api/filetree/createDailyNote` is called to create a daily note, the attribute will be automatically added to the document, and developers do not need to handle it separately\n* If a document is created manually by developer's code (e.g., using the `createDocWithMd` API to create a daily note), please manually add this attribute to the document\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsiyuan-note%2Fplugin-sample-vite-svelte","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsiyuan-note%2Fplugin-sample-vite-svelte","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsiyuan-note%2Fplugin-sample-vite-svelte/lists"}