当前位置: 首页 > news >正文

Logseq 插件开发实战四:发布到官方插件市场

🚩系列回顾

  • 初识插件机制并实现自动压缩粘贴的图片
  • 国际化 I18N 与配置多语言
  • 自定义斜线命令 SlashCommand
  • 发布到官方插件市场

开源地址:logseq-plugin-image-tiny,欢迎来⭐。


🐞 插件上线问题记录

问题描述
本地插件开发完成后,我打包package.jsonindex.jslogo.png文件到另一台电脑(未联网),结果发现插件加载失败,从控制台上看,是因为无法从互联网下载所需要的依赖(lsplugin.user.min.js)。

解决办法

经过一番探索,发现每个插件其实都是一个iframe加载对应的index.html(如果插件本身没有此文件,logseq 会自动创建)。而我的插件没有用到打包工具,发布时没有打包@logseq/libs依赖,所以需要从互联网下载,导致了上述的问题。

所以解决方案就很明了啦,一是增加打包配置,二是手动依赖。这里我果断选择后者,等之后有时间再研究怎么配置打包工具。

index.html 内容如下:

<!DOCTYPE html>
<html lang="en"><head><meta charset="UTF-8" /><meta http-equiv="X-UA-Compatible" content="IE=edge" /><meta name="viewport" content="width=device-width, initial-scale=1.0" /><title>logseq-image-tiny</title><script src="lsplugin.user.min.js"></script>
</head><body><script type="module" src="index.js"></script>
</body></html>

📦 插件市场

logseq 插件开发完成后,我们可以发布到官方插件市场。之后,用户在 logseq 内可以检索并安装我们的插件(想想就满满的成就感😎)。

此时,我们需要安装官方教程进行配置。

✅ 发布流程

  1. Fork this repo to your Github account.
  2. Create a package directory under ./packages root based on your plugin name.
  3. Write a manifest.json file to the package root. Valid fields as follows:
    • title- A title for plugin list item display.
    • description- A short description about your plugin.
    • author- The author’s name.
    • repo- The GitHub repository identifier, like {user}/{repo}.
    • icon- [optional] A logo for better recognition. default: ""
    • theme- [optional] A theme plugin? default: false
    • sponsors - [optional] Sponsor external links. default: []
    • web - [optional] Whether the web browser platform is supported. default: false
    • effect - [optional] Whether the sandbox is running under the same origin with host. default: false
    • unsupportedGraphType - [optional] Flag to indicate that which graph type does not to be supported. value: file | db
  4. Make a Github Pull Request 😃

🚀 发布自己的插件

Fork官方插件市场仓库




这样我们就能修改仓库内容啦。

编写插件信息

我们在./packages目录下新建插件同名目录,并添加manifest.json文件,内容如下:

{"title": "Image Auto Tiny","description": "粘贴图片到笔记时,自动转换为 WebP/AVIF 格式。A plugin that automatically converts images to webp/avi format to reduce image storage volume.","author": "0604hx/集成显卡","repo": "0604hx/logseq-plugin-image-tiny","icon": "./icon.png","effect": true
}

配置工作流

logseq 插件需要配置一个有效的 github CI 工作流,我们在项目根目录下创建文件.github/workflows/main.yml,内容如下(根据实际情况填写):

# This is a basic workflow to help you get started with Actionsname: Releaseenv:PLUGIN_NAME: logseq-image-tiny# Controls when the workflow will run
on:push:tags:- "*" # Push events to matching any tag format, i.e. 1.0, 20.15.10# Allows you to run this workflow manually from the Actions tabworkflow_dispatch:# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:release:# The type of runner that the job will run onruns-on: ubuntu-latest# Steps represent a sequence of tasks that will be executed as part of the jobsteps:# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it- uses: actions/checkout@v2- uses: actions/setup-node@v2with:node-version: "14.x"- name: Buildid: buildrun: |mkdir ${{ env.PLUGIN_NAME }}cp README.md package.json logo.png lsplugin.user.min.js index.js ${{ env.PLUGIN_NAME }}zip -r ${{ env.PLUGIN_NAME }}.zip ${{ env.PLUGIN_NAME }}lsecho "::set-output name=tag_name::$(git tag --sort version:refname | tail -n 1)"- name: Create Releaseid: create_releaseuses: actions/create-release@v1env:GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}VERSION: ${{ github.ref }}with:tag_name: ${{ github.ref }}release_name: ${{ github.ref }}draft: falseprerelease: false- name: Upload zip fileid: upload_zipuses: actions/upload-release-asset@v1env:GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}with:upload_url: ${{ steps.create_release.outputs.upload_url }}asset_path: ./${{ env.PLUGIN_NAME }}.zipasset_name: ${{ env.PLUGIN_NAME }}-${{ steps.build.outputs.tag_name }}.zipasset_content_type: application/zip

提交时出现如下错误:

refusing to allow a Personal Access Token to create or update workflow `.github/workflows/main.yml` without `workflow` scope

是因为我们的 token 没有相应权限,请到TOKEN管理页添加对应权限即可。

提交Pull Request

插件信息填写完成后,提交(commit)变动到 github,然后发起一个 Pull Request,接着等待官方的审核(通常需要几天)。

发布版本


官方同意 PR 后,就能通过插件市场检索到我们的插件啦🎉。

温馨提示
插件应该填写README.md,清晰描述插件的功能及使用方式,最好有英文噢。

http://www.dtcms.com/a/268940.html

相关文章:

  • 【VSCode 插件离线安装包下载方法分享】
  • 【PyTorch】PyTorch中torch.nn模块的循环层
  • Microsoft Visual Studio离线安装(以2022/2019为例)
  • Python脚本保护工具库之pyarmor使用详解
  • Redis常用数据结构以及多并发场景下的使用分析:list类型
  • Qt的第一个程序(2)
  • Karmada Multi-Ingress(MCI)技术实践
  • verilog中timescale指令的使用
  • javaweb———html
  • 【taro react】 ---- RuiVerifySlider 行为验证码之滑动拼图使用【天爱验证码 tianai-captcha 】实现
  • android ui thread和render thread
  • 上海新华医院奉贤院区:以元宇宙技术重构未来医疗生态
  • RAG 之 Prompt 动态选择的三种方式
  • 华为OD机试 2025B卷 - 小明减肥(C++PythonJAVAJSC语言)
  • 编辑器Vim的快速入门
  • Session的工作机制及安全性分析
  • Qt(信号槽机制)
  • 解数独(C++版本)
  • 永磁同步电机PMSM的无传感器位置控制
  • dotnet publish 发布后的项目,例如asp.net core mvc项目如何在ubuntu中运行,并可外部访问
  • 自动化运维:使用Ansible简化日常任务
  • Word 怎么让字变大、变粗、换颜色?
  • 运维打铁: PostgreSQL 数据库性能优化与高可用方案
  • Flutter 入门
  • 能源管理综合平台——分布式能源项目一站式监控
  • 海岛分布式能源系统调度 粒子群算法优化
  • 基于拉普拉斯变换与分离变量法的热传导方程求解
  • 网安系列【10】之深入浅出CSRF攻击:从原理到实战(DVWA靶场演示)
  • 商城小程序的UI设计都有哪些风格
  • 磷酸镧:多功能稀土材料,助力未来科技