首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >hugo pipes的问题

hugo pipes的问题
EN

Stack Overflow用户
提问于 2021-05-13 12:11:48
回答 1查看 128关注 0票数 0

我正在尝试使用管道来捆绑我的插件和脚本模块。到目前为止,这是我的代码。

代码语言:javascript
复制
{{ $jsBundle := slice }}
{{ $jsBundle = $jsBundle | append resources.Get  "plugins/google-map/map.js"}}
{{ $jsBundle = $jsBundle | append resources.Get "plugins/jquery/jquery.min.js"}}
{{ $jsBundle = $jsBundle | append resources.Get "plugins/lazy-load/lozad.min.js"}}
{{ $jsBundle = $jsBundle | append resources.Get "plugins/magnific-popup/jquery.magnific-popup.min.js" }}
{{ $jsBundle = $jsBundle | append resources.Get "plugins/shuffle/shuffle.min.js"}}
{{ $jsBundle = $jsBundle | append resources.Get "plugins/slick/slick.min.js"}}
{{ $jsBundle = $jsBundle | append resources.Get "js/script.js"}}
{{ $jsBundle = $jsBundle | append resources.Get "js/pricing/boosting.js" }}
{{ $jsBundle = $jsBundle | append resources.Get "js/pricing/coaching.js" }}
{{ $jsBundle = $jsBundle | append resources.Get "js/pricing/placements.js" }}
{{ $jsBundle = $jsBundle | append resources.Get "js/pricing/tourneyTitle.js" }}
-->
{{ $jsBundle := $jsBundle | resources.Concat "js/bundle.js" | fingerprint "sha384" }}
<script src="{{ $jsBundle.Permalink | absURL }}"></script>

每当我运行这段代码时,我都会得到这个错误,

代码语言:javascript
复制
executing "partials/footer.html" at <resources>: wrong number of args for Get: want 1 got 0

因此,在尝试解决这个问题并尝试使用filepath而不是Get之后,我决定回到我第一次看的教程中的方法。这个链接就在这里。https://www.youtube.com/watch?v=A20U7KbA4tA您可以跳到17:00查看他在哪里得到相同的错误,然后修复它。但是这个修复方法对我不起作用。

代码语言:javascript
复制
{{ $jsBundle := slice }}
{{ range .Site.Params.plugins.js}}
{{ $jsFile := resources.Get .link | minify }}
{{ $jsBundle := $jsBundle | append $jsFile }}
{{ end }}
{{ $jsBundle := $jsBundle | resources.Concat "js/bundle.js" | fingerprint "sha384" }}
<script src="{{ $jsBundle.Permalink | absURL }}"></script>

当我以这种方式尝试时,我得到的错误信息是

代码语言:javascript
复制
executing "partials/footer.html" at <resources.Concat>: error calling Concat: slice []interface {} not supported in concat

如果需要,我可以链接repo。但是rn它并没有被完全推送。我更喜欢使用我列出的第一种方式,我不需要有插件和模块的多个范围,它让我很容易地选择我想要使用的,而不是自动所有的东西。

EN

回答 1

Stack Overflow用户

发布于 2021-05-13 14:25:50

更改此设置:

代码语言:javascript
复制
{{ $jsBundle = $jsBundle | append resources.Get "foo" }}

要这样做:

代码语言:javascript
复制
{{ $jsBundle = $jsBundle | append (resources.Get "foo") }}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/67513802

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档