Sorry, your browser cannot access this site
This page requires browser support (enable) JavaScript
Learn more >

知识

  • source/目录下的index.md的链接:source/about/index.md的访问链接为博客链接/about,在.yml文件中导航栏处配置url时写about/

  • font-matterlayout: docs指定使用themes/layout/下哪个ejs文件作为模板,比如上述的index.md文件

  • post.<name>可以获取每篇博客的font-matter中的值

举例:新建类似首页的显示个人随笔的页面

新增页面

首先在source下新建目录writing,然后在source/writing下新建index.md,内容:
```markdown

layout: writing
title: 所有随笔
sidebar: [blogger]

其中layout指定模板使用`themes/layout/writing.ejs`,`sidebar`是定制侧边栏的内容

### 文章的控制传参
对于仅在这个页面显示而不在博客首页显示的文章,在font-matter中新增一个键:
```markdown
---
is_writing: true
---

模板文件

新增themes/layout/writing.ejs文件内容如下:参考首页(index.ejs)

<%- partial('_pre') %>
<div id="l_main" class='<%- page.sidebar == false ? ' no_sidebar' : '' %>'>
  <%- partial('_partial/writing') %>
</div>
<%- partial('_partial/side') %>

以及themes/layout/_partial/writing.ejs文件:参考首页(_partial/archive.ejs),主要是根据post.is_writing来判断文章性质

<% if (site.posts && site.posts.length > 0) { %>
  <section class="post-list">
    <% site.posts.each(function(post){ %>
      <% if (post.pin && post.is_writing) { %>
        <div class='post-wrapper'>
          <%- partial('post', {post: post}) %>
        </div>
      <% } %>
    <% }) %>
    <% site.posts.each(function(post){ %>
      <% if (!post.pin && post.is_writing) { %>
        <div class='post-wrapper'>
          <%- partial('post', {post: post}) %>
        </div>
      <% } %>
    <% }) %>
  </section>
<% } %>

导航栏增加一项

导航栏增加一项指向新增的页面:修改_config.volantis.yml

navbar:
  menu:
    - name: 随笔
      icon: fa-solid fa-info-circle
      url: writing/

评论