Files
docs/versioned_docs/version-2.18/developer-guide/theme/finder-apis/plugin.md
Ryan Wang dd6cc4848a docs: update documentation for Halo 2.18 (#389)
为 [Halo 2.18](https://github.com/halo-dev/halo/releases/tag/v2.18.0) 更新文档。

/kind documentation

```release-note
None
```
2024-08-01 02:50:10 +00:00

1.4 KiB
Raw Blame History

title, description
title description
插件 插件 - PluginFinder

available(pluginName)

pluginFinder.available(pluginName)

描述

判断一个插件是否可用,会同时判断插件是否安装和启用。

参数

  1. pluginName:string - 插件的唯一标识 metadata.name

返回值

boolean - 插件是否可用

示例

<!-- https://github.com/halo-sigs/plugin-search-widget -->
<li th:if="${pluginFinder.available('PluginSearchWidget')}">
  <a href="javascript:SearchWidget.open()" title="搜索">
    搜索
  </a>
</li>

available(pluginName, requiresVersion)

pluginFinder.available('fake-plugin', '>=2.3.0')

描述

判断一个插件是否可用,会同时判断插件是否安装和启用且插件的版本符合 requiresVersion 要求,

参数

  1. pluginName:string - 插件的唯一标识 metadata.name,不能为空。
  2. requiresVersion:string - 插件的版本要求,不能为空,例如:>1.2.0requiresVersion 的格式遵循 Semantic Range Expressions

返回值

boolean - 插件是否可用

示例

<!-- https://github.com/halo-sigs/plugin-search-widget -->
<li th:if="${pluginFinder.available('PluginSearchWidget', '>=2.3.0')}">
  <a href="javascript:SearchWidget.open()" title="搜索">
    搜索
  </a>
</li>