Coder Social home page Coder Social logo

Comments (1)

singhkays avatar singhkays commented on June 2, 2024 4

@nishanths I figured this out, here's the index.html I am using on my site. I wasn't sure if you want this to be the default behavior for everyone but it made send for my site as I had other categories than just "blog". Hopefully it helps others looking to do this.

{{ partial "header.html" . }}
<section class="main">
    <div class="container">
        <div class="content">
            {{ if .Content }}
                <div class="markdown">
                    {{ .Content }}
                </div>
            {{ end }}
            <!--{{ $totalpostscount := len (where .Data.Pages "Section" "blog") }}-->
            {{ $totalpostscount := len (.Data.Pages) }}
            {{ $latestpostscount := .Site.Params.latestpostscount | default $totalpostscount }}
            {{ if gt $latestpostscount 0 }}
              <div class="page-heading">{{ i18n "latestPosts" }}</div>
                <ul>
                    {{ range (first $latestpostscount ( .Data.Pages.ByPublishDate.Reverse )) }}
                        {{ partial "li.html" . }}
                    {{ end }}
                    {{ if gt $totalpostscount $latestpostscount }}
                        {{ range where .Site.Menus.main "Identifier" "blog" }}
                            <li class="post-item no-bullet">
                                <a id="see-more" {{ printf "href=%q " .URL | safeHTMLAttr }}><span>See more&hellip;</span></a>
                            </li>
                        {{ end }}
                    {{ end }}
                </ul>
              </div>
            {{ end }}
    </div>
</section>
{{ partial "footer.html" . }}

from cocoa-hugo-theme.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.