11package run .halo .comment .widget ;
22
3+ import java .util .Properties ;
34import lombok .RequiredArgsConstructor ;
4- import org .pf4j .PluginWrapper ;
55import org .springframework .stereotype .Component ;
66import org .springframework .util .PropertyPlaceholderHelper ;
77import org .thymeleaf .context .ITemplateContext ;
88import org .thymeleaf .model .IModel ;
99import org .thymeleaf .model .IModelFactory ;
1010import org .thymeleaf .processor .element .IElementModelStructureHandler ;
1111import reactor .core .publisher .Mono ;
12+ import run .halo .app .plugin .PluginContext ;
1213import run .halo .app .theme .dialect .TemplateHeadProcessor ;
1314
14- import java .util .Properties ;
15-
1615@ Component
1716@ RequiredArgsConstructor
1817public class CommentWidgetHeadProcessor implements TemplateHeadProcessor {
1918
2019 static final PropertyPlaceholderHelper PROPERTY_PLACEHOLDER_HELPER = new PropertyPlaceholderHelper ("${" , "}" );
2120
22- private final PluginWrapper pluginWrapper ;
21+ private final PluginContext pluginContext ;
2322
2423 @ Override
2524 public Mono <Void > process (ITemplateContext context , IModel model ,
@@ -32,13 +31,13 @@ public Mono<Void> process(ITemplateContext context, IModel model,
3231 private String commentWidgetScript () {
3332
3433 final Properties properties = new Properties ();
35- properties .setProperty ("version" , pluginWrapper . getDescriptor () .getVersion ());
34+ properties .setProperty ("version" , pluginContext .getVersion ());
3635
3736 return PROPERTY_PLACEHOLDER_HELPER .replacePlaceholders ("""
38- <!-- plugin-comment-widget start -->
39- <script src="/plugins/PluginCommentWidget/assets/static/comment-widget.iife.js?version=${version}"></script>
40- <link rel="stylesheet" href="/plugins/PluginCommentWidget/assets/static/style.css?version=${version}" />
41- <!-- plugin-comment-widget end -->
42- """ , properties );
37+ <!-- plugin-comment-widget start -->
38+ <script src="/plugins/PluginCommentWidget/assets/static/comment-widget.iife.js?version=${version}"></script>
39+ <link rel="stylesheet" href="/plugins/PluginCommentWidget/assets/static/style.css?version=${version}" />
40+ <!-- plugin-comment-widget end -->
41+ """ , properties );
4342 }
4443}
0 commit comments