-- 我在制作一个主题
-- 不会 freemarker 基本就不懂搜一下
-- 我在我的 link 友情链接页面 使用 sakura 评论组件
<#macro comment target,type>
<#if !post.disallowComment!false>
<script src="//cdn.jsdelivr.net/npm/vue@2.6.10/dist/vue.min.js"></script>
<script src="${options.comment_internal_plugin_js!'//cdn.jsdelivr.net/gh/LIlGG/halo-comment-sakura@v1.3.5/dist/halo-comment.min.js'}"></script>
<#assign
configs = '{
"autoLoad": true,
"showUserAgent": true
}'
>
<halo-comment id='${target.id?c}' type='${type}' configs='${configs}'/>
</#if>
</#macro>
这是评论组件
<#include "module/macro.ftl">
<@layout title="友情链接 - ${blog_title!}">
<section id="halo_link">
<div class="link container">
<div class="link_title">
<h1>友情链接</h1>
</div>
<ul>
<@linkTag method="list">
<#if links?? && links?size gt 0>
<#list links as link>
<li>
<img class="link_logo" src="${link.logo}" alt="${link.name}"/>
<a href="${link.url}" target="_blank" rel="external">${link.name}</a>
<#if link.description!=''>
– ${link.description}
</#if>
</li>
</#list>
</#if>
</@linkTag>
<#include "module/comment.ftl">
<@comment target=sheet type="sheet" />
</ul>
</div>
</section>
</@layout>
这是我友情链接页面
报错
FreeMarker template error (DEBUG mode; use RETHROW in production!): When calling macro "comment", required parameter "target" (parameter #1) was specified, but had null/missing value. ---- Tip: If the parameter value expression on the caller side is known to be legally null/missing, you may want to specify a default value for it with the "!" operator, like paramValue!defaultValue. ---- ---- FTL stack trace ("~" means nesting-related): - Failed at: #macro comment target type [in template "themes/halo-theme-quick-starter/module/comment.ftl" in macro "comment" at line 1, column 1] - Reached through: @comment target=sheet type="sheet" [in template "themes/halo-theme-quick-starter/links.ftl" at line 24, column 9] ~ Reached through: #nested [in template "themes/halo-theme-quick-starter/module/macro.ftl" in macro "layout" at line 21, column 3] ~ Reached through: @layout title="友情链接 - ${blog_title!}" [in template "themes/halo-theme-quick-starter/links.ftl" at line 2, column 1] ---- Java stack trace (for programmers): ---- freemarker.core._MiscTemplateException: [... Exception message was already printed; see it above ...] at freemarker.core.Macro$Context.checkParamsSetAndApplyDefaults(Macro.java:308) at freemarker.core.Environment.invokeMacroOrFunctionCommonPart(Environment.java:888) at freemarker.core.Environment.invokeMacro(Environment.java:825) at freemarker.core.UnifiedCall.accept(UnifiedCall.java:84) at freemarker.core.Environment.visit(Environment.java:383) at freemarker.core.Environment.invokeNestedContent(Environment.java:633) at
但是我在 sheet post 页面都能正常使用,我看到 sukura 主题他也能在友情链接放评论组件,我尝试看看代码,发现他是在 自定义页面加了个 if判断,可是我在halo系统 页面默认给我的 link 页面使用 不知道怎么办呢,求解决