generated from halo-dev/plugin-starter
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ca19e28
commit c22f68f
Showing
3 changed files
with
12 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
version=1.1.0 | ||
version=1.2.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
package xin.wenjing.halo.artalk; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import org.pf4j.PluginWrapper; | ||
import org.springframework.stereotype.Component; | ||
import org.thymeleaf.context.ITemplateContext; | ||
import org.thymeleaf.model.IModel; | ||
|
@@ -23,9 +24,12 @@ public class ArtalkStaticInject implements TemplateHeadProcessor { | |
|
||
private final SettingFetcher settingFetcher; | ||
|
||
private final PluginWrapper pluginWrapper; | ||
|
||
@Override | ||
public Mono<Void> process(ITemplateContext context, IModel model, IElementModelStructureHandler structureHandler) { | ||
Settings baseConf = settingFetcher.fetch(Settings.GROUP, Settings.class).orElse(new Settings()); | ||
|
||
String injectContent = ""; | ||
|
||
// 开启明暗模式后自定义css加入 | ||
|
@@ -51,23 +55,25 @@ public Mono<Void> process(ITemplateContext context, IModel model, IElementModelS | |
*/ | ||
private String pubScriptInject(boolean enableLatex, String cssUrl, String jsUrl){ | ||
if(jsUrl != null && cssUrl !=null) { | ||
|
||
String version = pluginWrapper.getDescriptor().getVersion(); | ||
if (enableLatex) { | ||
return | ||
""" | ||
<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/katex.min.css" /> | ||
<link rel="stylesheet" href="/plugins/plugin-artalk/assets/static/artalkBeautify.css" /> | ||
<link rel="stylesheet" href="/plugins/plugin-artalk/assets/static/artalkBeautify.css?version=%s" /> | ||
<script data-pjax src="/plugins/plugin-artalk/assets/static/katex.min.js"></script> | ||
<link rel="stylesheet" href="%s" /> | ||
<script data-pjax src="%s"></script> | ||
<script defer src="/plugins/plugin-artalk/assets/static/artalk-plugin-katex.js"></script> | ||
""".formatted(cssUrl, jsUrl); | ||
""".formatted(version, cssUrl, jsUrl); | ||
} else { | ||
return | ||
""" | ||
<link rel="stylesheet" href="/plugins/plugin-artalk/assets/static/artalkBeautify.css" /> | ||
<link rel="stylesheet" href="/plugins/plugin-artalk/assets/static/artalkBeautify.css?version=%s" /> | ||
<link rel="stylesheet" href="%s"> | ||
<script data-pjax src="%s"></script> | ||
""".formatted(cssUrl, jsUrl); | ||
""".formatted(version, cssUrl, jsUrl); | ||
} | ||
}else{ | ||
return null; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters