在 Ghost 中使用 2 {{navigations}}

问题描述 投票:0回答:1

这是我第一次使用 Ghost 并创建自己的主题。我注意到在管理面板中,有 2 个导航区域:主要和次要。 我想使用主要区域填充导航栏中的链接和页脚中的辅助区域。导航栏和页脚都是它们自己的部分。

感谢您的时间和协助

navigation.hbs 工作正常,我正在使用:

{{#foreach navigation}}
                  <li class="nav-{{slug}}{{#if current}} nav-current{{/if}}"><a href="{{url absolute="true"}}">{{label}}</a></li>
{{/foreach}}

footer.hbs 显示“即将推出!”我正在使用:

{{#if isSecondary}}
              <ul class="nav footer-nav" role="menu">
                {{#foreach navigation}}
                  <li class="nav-{{slug}}{{#if current}} nav-current{{/if}}"><a href="{{url absolute="true"}}">{{label}}</a></li>
                {{/foreach}}
             </ul>
{{else}}
             <p>Coming soon!</p>
{{/if}}

default.hbs有:

<!DOCTYPE html>
<html lang="{{@site.locale}}"{{#match @custom.color_scheme "Dark"}} class="dark-mode"{{else match @custom.color_scheme "Auto"}} class="auto-color"{{/match}}>
<head></head>
<body class="{{body_class}} is-head-{{#match @custom.navigation_layout "Logo on cover"}}left-logo{{else match @custom.navigation_layout "Logo in the middle"}}middle-logo{{else}}stacked{{/match}}{{#match @custom.title_font "=" "Elegant serif"}} has-serif-title{{/match}}{{#match @custom.body_font "=" "Modern sans-serif"}} has-sans-body{{/match}}{{#if @custom.show_publication_cover}} has-cover{{/if}}">
<div class="viewport">

    {{navigation}}


    <div class="site-content">
        {{!-- All other templates get inserted here, index.hbs, post.hbs, etc --}}
        {{{body}}}
    </div>
    {{!-- {{log @site.secondary_navigation}} --}}
    {{!-- The global footer at the very bottom of the screen --}}  
    {{> footer}}


</div>

{{!-- Scripts - handle member signups, responsive videos, infinite scroll, floating headers, and galleries --}}
<script
    src="https://code.jquery.com/jquery-3.5.1.min.js"
    integrity="sha256-9/aliU8dGd2tb6OSsuzixeV4y/faTqgFtohetphbbj0="
    crossorigin="anonymous">
</script>
<script src="{{asset "built/tb-theme.js"}}"></script>
<script>
$(document).ready(function () {
    // Mobile Menu Trigger
    $('.gh-burger').click(function () {
        $('body').toggleClass('gh-head-open');
    });
    // FitVids - Makes video embeds responsive
    {{!-- $(".gh-content").fitVids(); --}}
});
</script>

{{!-- Ghost outputs required functional scripts with this tag - it should always be the last thing before the closing body tag --}}
    {{!-- Below is a way to insert Ghost footer --}}
    {{ghost_foot}}

</body>

如果我将 {{navigation}} 切换为 {{navigation type="secondary"}} 那么导航栏和页脚都会显示页脚的链接。

handlebars.js ghost-blog
1个回答
0
投票

解决方法 -> 您可以在实际安装中添加一个新网站并使用其默认导航。

我一直在寻找相同的方法,这就是我开始研究的方法。

© www.soinside.com 2019 - 2024. All rights reserved.