Skip to content

Commit

Permalink
refactor: Update Context layout
Browse files Browse the repository at this point in the history
hepplerj committed Dec 5, 2024
1 parent e485d03 commit 787e192
Showing 1 changed file with 23 additions and 172 deletions.
195 changes: 23 additions & 172 deletions bom-website/themes/dbn/layouts/context/list.html
Original file line number Diff line number Diff line change
@@ -1,57 +1,38 @@
{{ define "main" }}
<main>
<div
class="flex min-h-screen bg-white pt-7 items-start mx-auto w-full lg:max-w-screen-lg sm:max-w-screen-sm md:max-w-screen-md">
<div class="min-h-screen bg-white pt-7 mx-auto w-full lg:max-w-screen-lg sm:max-w-screen-sm md:max-w-screen-md">
<div class="container mx-auto px-4">
<h2 class="text-4xl font-medium pb-4">{{ .Title }}</h2>
<div class="flex flex-col mb-8 animated fadeIn sm:flex-row">
<div class="flex mb-8 sm:w-2/3">
<div class="flex flex-wrap w-3/4 prose prose-lg">
<div class="flex flex-col mb-8 sm:flex-row">
<!-- Main Content -->
<div class="sm:w-2/3 pr-4 border-r border-gray-200">
<div class="prose max-w-none">
{{ .Content }}
</div>
</div>

<!-- Sidebar -->
<div class="sm:w-1/3 sm:pl-8">
<!-- Latest Essays -->
<div class="mb-10">
<h3 class="text-lg font-medium pb-4">Recent Writings</h3>
{{ range where (.Paginator 4).Pages "Params.categories" "intersect" (slice "context") }}
<section class="flex prose">
<div class="flex-1 max-w-3xl mx-auto text-left">
<div class="section-content">
<h2 class="mb-4 text-xl font-semibold text-gray-600"><a href="{{.Permalink}}">{{ .Title }}</a></h2>
<div class="flex justify-between">
<div class="inline-block mb-2 text-xs font-semibold uppercase">
by
{{ range $i, $e := .Params.author }}{{ if $i }}, {{ end }}{{ $e }}{{ end }}
</div>
<span class="mb-2 text-xs">{{.Date.Format "2006-01-02"}}</span>
</div>
<div class="flex flex-wrap mb-4">
<a href="{{.Permalink}}" class="flex mb-2 mr-2 text-sm md:mb-0 items-center">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor"
class="w-4 h-4 mr-1 bi bi-folder" viewBox="0 0 16 16">
<path
d="M.54 3.87.5 3a2 2 0 0 1 2-2h3.672a2 2 0 0 1 1.414.586l.828.828A2 2 0 0 0 9.828 3h3.982a2 2 0 0 1 1.992 2.181l-.637 7A2 2 0 0 1 13.174 14H2.826a2 2 0 0 1-1.991-1.819l-.637-7a1.99 1.99 0 0 1 .342-1.31zM2.19 4a1 1 0 0 0-.996 1.09l.637 7a1 1 0 0 0 .995.91h10.348a1 1 0 0 0 .995-.91l.637-7A1 1 0 0 0 13.81 4H2.19zm4.69-1.707A1 1 0 0 0 6.172 2H2.5a1 1 0 0 0-1 .981l.006.139C1.72 3.042 1.95 3 2.19 3h5.396l-.707-.707z" />
</svg>
{{ range .Params.categories }}
<a class="prose-sm" href="/categories/{{ . | urlize }}">{{ . }}</a>
{{ end }}
</a>
<section class="prose">
<div class="text-left">
<h4 class="mb-4 font-semibold text-gray-600"><a href="{{.Permalink}}">{{ .Title }}</a></h4>
<div class="flex justify-between">
<div class="text-xs font-semibold uppercase">
by {{ range $i, $e := .Params.author }}{{ if $i }}, {{ end }}{{ $e }}{{ end }}
</div>
<p class="mb-4 text-sm text-black">
{{.Summary }}
{{ if .Truncated }}
<div>
<a href="{{ .Permalink }}">Read More...</a>
</div>
{{ end }}
</p>
</div>
<div class="mb-4">{{ .Date.Format "2006-01-02" }}</div>
</div>
</section>
<hr class="w-48 h-0.5 mx-auto my-4 bg-gray-700 border-0 rounded md:my-10">
{{ end }}
</div>
</div>
<div class="flex flex-col sm:w-1/3 sm:pr-16 p-3 m-3 rounded-lg">
<div class="container tagcloud">
<div class="mb-10">
{{ .Content }}
</div>

<div>
<h2 class="text-xl text-gray-600 text-center">{{ .Title }} Tags</h2>
{{ if ne (len $.Site.Taxonomies.tags) 0 }}
{{ $largestFontSize := 1.3 }}
@@ -92,140 +73,10 @@ <h2 class="text-xl text-gray-600 text-center">{{ .Title }} Tags</h2>
<p>No tags found.</p>
{{ end }}
</div>

</div>
</div>
</div>
</div>

<!-- pagination numbers -->
{{ $paginator := .Paginator }}

<!-- Number of links either side of the current page. -->
{{ $adjacent_links := 2 }}

<!-- $max_links = ($adjacent_links * 2) + 1 -->
{{ $max_links := (add (mul $adjacent_links 2) 1) }}

<!-- $lower_limit = $adjacent_links + 1 -->
{{ $lower_limit := (add $adjacent_links 1) }}

<!-- $upper_limit = $paginator.TotalPages - $adjacent_links -->
{{ $upper_limit := (sub $paginator.TotalPages $adjacent_links) }}

<div class="max-w-2xl mx-auto p-9">

<!-- If there's more than one page. -->
{{ if gt $paginator.TotalPages 1 }}

<ul class="inline-flex -space-x-px">


<!-- First page. -->
{{ if ne $paginator.PageNumber 1 }}
<li class="pagination__item pagination__item--first">
<a class="bg-white border border-gray-300 text-gray-500 hover:bg-gray-100 hover:text-gray-700 ml-0 rounded-l-lg leading-tight py-2 px-3 dark:bg-gray-800 dark:border-gray-700 dark:text-gray-400 dark:hover:bg-gray-700 dark:hover:text-white"
href="{{ $paginator.First.URL }}">
««
</a>
</li>
{{ end }}

<!-- Previous page. -->
{{ if $paginator.HasPrev }}
<li class="pagination__item pagination__item--previous">
<a href="{{ $paginator.Prev.URL }}"
class="bg-white border border-gray-300 text-gray-500 hover:bg-gray-100 hover:text-gray-700 leading-tight py-2 px-3 dark:bg-gray-800 dark:border-gray-700 dark:text-gray-400 dark:hover:bg-gray-700 dark:hover:text-white">
«
</a>
</li>
{{ end }}

<!-- Page numbers. -->
{{ range $paginator.Pagers }}

{{ $.Scratch.Set "page_number_flag" false }}


<!-- Advanced page numbers. -->
{{ if gt $paginator.TotalPages $max_links }}


<!-- Lower limit pages. -->
<!-- If the user is on a page which is in the lower limit. -->
{{ if le $paginator.PageNumber $lower_limit }}

<!-- If the current loop page is less than max_links. -->
{{ if le .PageNumber $max_links }}
{{ $.Scratch.Set "page_number_flag" true }}
{{ end }}


<!-- Upper limit pages. -->
<!-- If the user is on a page which is in the upper limit. -->
{{ else if ge $paginator.PageNumber $upper_limit }}

<!-- If the current loop page is greater than total pages minus $max_links -->
{{ if gt .PageNumber (sub $paginator.TotalPages $max_links) }}
{{ $.Scratch.Set "page_number_flag" true }}
{{ end }}


<!-- Middle pages. -->
{{ else }}

{{ if and ( ge .PageNumber (sub $paginator.PageNumber $adjacent_links) ) ( le .PageNumber (add
$paginator.PageNumber $adjacent_links) ) }}
{{ $.Scratch.Set "page_number_flag" true }}
{{ end }}

{{ end }}


<!-- Simple page numbers. -->
{{ else }}

{{ $.Scratch.Set "page_number_flag" true }}

{{ end }}

<!-- Output page numbers. -->
{{ if eq ($.Scratch.Get "page_number_flag") true }}
<li class="pagination__item{{ if eq . $paginator }} pagination__item--current{{ end }}">
<a href="{{ .URL }}"
class="bg-white border border-gray-300 text-gray-500 hover:bg-gray-100 hover:text-gray-700 leading-tight py-2 px-3 dark:bg-gray-800 dark:border-gray-700 dark:text-gray-400 dark:hover:bg-gray-700 dark:hover:text-white">
{{ .PageNumber }}
</a>
</li>
{{ end }}

{{ end }}

<!-- Next page. -->
{{ if $paginator.HasNext }}
<li class="pagination__item pagination__item--next">
<a href="{{ $paginator.Next.URL }}"
class="bg-white border border-gray-300 text-gray-500 hover:bg-gray-100 hover:text-gray-700 leading-tight py-2 px-3 dark:bg-gray-800 dark:border-gray-700 dark:text-gray-400 dark:hover:bg-gray-700 dark:hover:text-white">
»
</a>
</li>
{{ end }}

<!-- Last page. -->
{{ if ne $paginator.PageNumber $paginator.TotalPages }}
<li class="pagination__item pagination__item--last">
<a class="bg-white border border-gray-300 text-gray-500 hover:bg-gray-100 hover:text-gray-700 rounded-r-lg leading-tight py-2 px-3 dark:bg-gray-800 dark:border-gray-700 dark:text-gray-400 dark:hover:bg-gray-700 dark:hover:text-white"
href="{{ $paginator.Last.URL }}">
»»
</a>
</li>
{{ end }}

</ul><!-- .pagination -->
{{ end }}
</div>


</div>
</div>
</main>
{{ end }}

0 comments on commit 787e192

Please sign in to comment.