Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

如果想在主页隐藏某些文章。 #483

Closed
4 of 6 tasks
jskyzero opened this issue Aug 10, 2017 · 1 comment
Closed
4 of 6 tasks

如果想在主页隐藏某些文章。 #483

jskyzero opened this issue Aug 10, 2017 · 1 comment

Comments

@jskyzero
Copy link

I certify that I have first consulted (check all with "x")

我确认我已经查看了 (使用 "x" 选择)


I'm submitting a (check one with "x")

我正在申请 (使用 "x" 选择)

  • bug report | 反馈一个 bug
  • feature request | 申请添加新的特性或功能
  • support request | 请求技术支持

Material 原质 主题提供了很好的归档功能,但是出于若干需求,有时候可能不希望某些文章出现在首页(当然可以在文章的归档中找到它)因而建议增加一个隐藏在主页显示的设置。例如文章头中添加visible: hide即可以在主页隐藏这篇文章
Hexo的某主题的对应实现可以参考这个. 这里我们对应的找到themes/layout/index.ejs 然后将

            <% if(theme.scheme === 'Paradox') { %>
                <!-- Paradox Thumbnail -->
                <%- partial('_partial/Paradox-post_entry', { post: post, index: true }) %>
            <% } %>
            <% if(theme.scheme === 'Isolation') { %>
                <!-- Isolation Thumbnail -->
                <%- partial('_partial/Isolation-post_entry', { post: post, index: true }) %>
            <% } %>

修改为:

        <% if ( !( (post.visible === 'hide') && (page.path === "index.html") ) )   { %>
            <% if(theme.scheme === 'Paradox') { %>
                <!-- Paradox Thumbnail -->
                <%- partial('_partial/Paradox-post_entry', { post: post, index: true }) %>
            <% } %>
            <% if(theme.scheme === 'Isolation') { %>
                <!-- Isolation Thumbnail -->
                <%- partial('_partial/Isolation-post_entry', { post: post, index: true }) %>
            <% } %>
        <% } %>

即可。

只是增加了一个判断。

(希望主题越来越好w)

@neoFelhz
Copy link
Collaborator

We suggest you to create a new page instead of post, then it will not be shown in the archives.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants