zeon-studio / hugoplate

Hugoplate is a free starter template built with Hugo and TailwindCSS that will save you hours of work.
https://zeon.studio/preview?project=hugoplate
MIT License
798 stars 218 forks source link

list blog posts on home page #99

Closed psalphabeta closed 6 months ago

psalphabeta commented 6 months ago

tried to show blogposts on homepage by copying the section code in blog/list.html to layouts/index.html but its only showing sidebar section like below WhatsApp Image 2024-02-24 at 12 30 17 PM how to implement this. Is there any detailed documentation as this theme a bit different from other hugo themes

psalphabeta commented 6 months ago

Added the below code in layouts/index.html and it worked

 {{ define "main" }}

  {{ with .Params.banner }}
    <section class="section pt-14">
      <div class="container">
        <div class="row justify-center">
          <div class="lg:col-7 md:col-9 mb-8 text-center">
            <h1 class="mb-4 text-h3 lg:text-h1">
              {{ .title | markdownify }}
            </h1>
            <p class="mb-8">
              {{ .content | markdownify }}
            </p>
            {{ with .button }}
              {{ if .enable }}
                <a
                  class="btn btn-primary"
                  href="{{ .link | absURL }}"
                  {{ if strings.HasPrefix .link `http` }}
                    target="_blank" rel="noopener"
                  {{ end }}>
                  {{ .label }}
                  <i class="fa fa-arrow-right pl-2"></i>
                </a>
              {{ end }}
            {{ end }}
          </div>
          <div class="col-12">
            {{ partial "image" (dict "Src" .image "Alt" "Banner image" "Loading" "eager" "Class" "mx-auto lg:!max-w-[800px]" "DisplayXL" "800x" ) }}
          </div>
        </div>
      </div>
    </section>
  {{ end }}

  <section class="section">
    <div class="container">
      <div class="row gx-5">

        <div class="lg:col-8">
          <div class="row">

            {{ $frontBundle := .Site.Params.frontBundle | default "blog" }}

            {{ range first 2 (where .Site.RegularPages.ByDate.Reverse "Type" $frontBundle)  }}
              <div class="md:col-6 mb-14">

                {{ partial "components/blog-card" . }}
              </div>
              {{ end }}
              <div class="text-center mb-8">
                <a href="/blog" class="btn btn-primary">
                  More Posts
                </a>
              </div>

          </div>

        </div>
        <div class="lg:col-4">
          {{ $widget:= site.Params.widgets.sidebar }}
          {{ partialCached "widgets/widget-wrapper" ( dict "Widgets" $widget "Scope" . ) }}
        </div>
      </div>
    </div>
  </section>

{{ end }}