<% if (is_home() && page.current === 1) { %>
<%- partial('_partial/index-cover') %>
<% } else { %>
    <%- partial('_partial/bg-cover') %>
<% } %>

<main class="content">

    <% if (page.current === 1
            && ((theme.target.enable || theme.music.enable)
                    || theme.video.enable || theme.recommend.enable)) { %>
    <div id="indexCard" class="index-card">
        <div class="container ">
            <div class="card">
                <div class="card-content">
                    <% if (theme.target.enable) { %>
                        <%- partial('_widget/target') %>
                    <% } %>

                    <% if (theme.music.enable && !theme.music.fixed) { %>
                        <%- partial('_widget/music') %>
                        <% } %>

                    <% if (theme.video.enable && ( theme.video.url || theme.video.iframeUrl ) ) { %>
                        <%- partial('_widget/video') %>
                    <% } %>

                    <% if (theme.recommend.enable) { %>
                    <div id="recommend-sections" class="recommend">
                        <%- partial('_widget/recommend') %>
                    </div>
                    <% } %>
                </div>
            </div>
        </div>
    </div>
    <% }%>

    <%
    var hashCode = function (str) {
        if (!str && str.length === 0) {
            return 0;
        }

        var hash = 0;
        for (var i = 0, len = str.length; i < len; i++) {
            hash = ((hash << 5) - hash) + str.charCodeAt(i);
            hash |= 0;
        }
        return hash;
    };
    %>

    <!-- 所有文章卡片 -->
    <% if(theme.mode=="homecategory") { %>
        <style>
        .card-bar{
            width: 100%;
            border: none;
            margin-top: 65px;
            padding: 10px;
            background-color: #F0F0F0!important;
        }
        .category-bar .tag-title.center-align{
            display: none;
        }
        .categorychip{
            font-size: 20px;
            color: black!important;
            background-color: transparent!important;
            background-image: none!important;
            margin-left: 18px;
            margin-right: 18px;
        }
        .categorychip:hover{
            font-size: 20px;
            color: black!important;
            text-decoration: underline;
            background-color: transparent!important;
            background-image: none!important;
            margin-left: 18px;
            margin-right: 18px;
        }
        </style>
        <%- partial('_widget/category-cloud') %>
    <% } %>
    <article id="articles" class="container articles">
        <div class="row article-row">
            <% page.posts.forEach(post => { %>
            <% if (post.hide != true)  { %> <!-- 隐藏某个文章 -->
            <div class="article col s12 m6 l4" data-aos="zoom-in">
                <div class="card">
                    <a href="<%- url_for(post.path) %>">
                        <div class="card-image">
                            <% if (post.img) { %>
                            <img src="<%- url_for(post.img) %>" class="responsive-img" alt="<%= post.title %>">
                            <% } else { %>
                            <%
                                var featureimg = '/medias/featureimages/0.jpg';
                                var featureImages = theme.featureImages;
                                if (!featureImages || featureImages.length == 0) {
                                    return featureimg;
                                }
                                featureimg = featureImages[Math.abs(hashCode(post.title) % featureImages.length)]
                            %>
                            <img src="<%- theme.jsDelivr.url %><%- url_for(featureimg) %>" class="responsive-img" alt="<%= post.title %>">
                            <% } %>
                            <span class="card-title"><%= post.title %></span><button class="readm"><%- __('readMore') %></button>
                        </div>
                    </a>
                    <% if(theme.showTag) { %>
                    <div class="card-action article-tags" style="background-color: <%= theme.defaultbarcolor %>;">
                        <% post.tags.forEach(tag => { %>
                        <a href="<%- url_for(tag.path) %>">
                            <span class="chip bg-color"><%= tag.name %></span>
                        </a>
                        <% }); %>
                    </div>
                    <% } %>
                    
                </div>
            </div>
            <% } %>  <!-- 隐藏某个文章 -->
            <% }); %>
        </div>
    </article>
</main>
<hr style="color:transparent;background-color:transparent;border-color:transparent;">
<% if (page.total > 1) { %>
    <%- partial('_partial/paging') %>
<% } %>
<% if(theme.info.enable==true) { %>
<hr class="sepr">
<main class="infopg">
    <%- theme.info.content %>
</main>
<hr class="sepr">
<% } %>

