From ae4ac17423aaea148e7cba41214a3187cc80f9ed Mon Sep 17 00:00:00 2001 From: xaoxuu Date: Sat, 6 Apr 2019 18:04:14 +0800 Subject: [PATCH] update --- layout/_partial/cover.ejs | 33 +++++++++++++++++++++++++++++++++ layout/layout.ejs | 13 +------------ 2 files changed, 34 insertions(+), 12 deletions(-) create mode 100644 layout/_partial/cover.ejs diff --git a/layout/_partial/cover.ejs b/layout/_partial/cover.ejs new file mode 100644 index 0000000..3ccdc62 --- /dev/null +++ b/layout/_partial/cover.ejs @@ -0,0 +1,33 @@ +<% +var showCover = false; +if (theme.cover) { + // 如果页面的Front-matter声明了cover,就取页面的值 + if (page.cover != undefined) { + showCover = page.cover; + } else { + // 否则,如果是首页,只有首页的第一页显示 + if (is_home()) { + if (page.prev) { + showCover = false; + } else { + showCover = true; + } + } else { + showCover = true; + } + } +} +%> + +<% if (showCover == true) { %> +
+
+ <% if (theme.cover.scheme == 'search') { %> + <%- partial('../_cover/search') %> + <% } %> +
+ <%- partial('header', null, {cache: !config.relative_link, path: path}) %> +
+<% } else { %> + <%- partial('header', null, {cache: !config.relative_link, path: path}) %> +<% } %> diff --git a/layout/layout.ejs b/layout/layout.ejs index 6b74a84..e15f045 100755 --- a/layout/layout.ejs +++ b/layout/layout.ejs @@ -2,18 +2,7 @@ <%- partial('_partial/head') %> - <% if (!page.prev && theme.cover) { %> -
-
- <% if (theme.cover.scheme == 'search') { %> - <%- partial('_cover/search') %> - <% } %> -
- <%- partial('_partial/header', null, {cache: !config.relative_link, path: path}) %> -
- <% } else { %> - <%- partial('_partial/header', null, {cache: !config.relative_link, path: path}) %> - <% } %> + <%- partial('_partial/cover') %>
<%- body %>