Skip to content

Commit ef1ea47

Browse files
authored
Fix Wants page not rendering due to Eleventy 3.x pagination circular dependency (#802)
1 parent 5511e1a commit ef1ea47

File tree

3 files changed

+47
-20
lines changed

3 files changed

+47
-20
lines changed

_includes/layouts/wants.njk

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
11
---
22
layout: layouts/base.njk
3-
section: wants
4-
permalink: "/wants/{% if pagination.pageNumber > 0 %}page/{{ pagination.pageNumber + 1 }}{% else %}index{% endif %}.html"
5-
pagination:
6-
data: collections.wants
7-
size: 10
8-
alias: wants
93
---
104
{% from "macros.njk" import paginate %}
115

@@ -27,9 +21,13 @@ pagination:
2721
});
2822
</script>
2923

30-
{% if wants.length > 0 %}
24+
{% set wantsToShow = wants if wants else collections.wantsBySubmissionDate %}
25+
{% if wantsToShow.length > 0 %}
26+
{% set wants = wantsToShow %}
3127
{% include "components/wants.njk" %}
32-
{{ paginate( "Page", pagination ) }}
28+
{% if pagination %}
29+
{{ paginate( "Page", pagination ) }}
30+
{% endif %}
3331
{% else %}
3432
<p>No one has submitted a want yet. <a href="/#submit">Wanna be the first?</a></p>
3533
{% endif %}

pages/wants.md

Lines changed: 0 additions & 12 deletions
This file was deleted.

wants/index.njk

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
---
2+
layout: layouts/base.njk
3+
title: What We Want
4+
description: Here is a run-down of all of the "wants" submitted as part of this program.
5+
date: 2019-01-02T00:00:00.000Z
6+
permalink: /wants/
7+
navtitle: Wants
8+
tags:
9+
- nav
10+
includeInSitemap: true
11+
section: wants
12+
---
13+
{% from "macros.njk" import want %}
14+
15+
<h1>{{ title | widont }}</h1>
16+
17+
<p>Here is a run-down of the {{ collections.wants.length }} "wants" submitted as part of this program. Check 'em out and if there's something you want, <a href="/#submit">send it in</a>!</p>
18+
19+
<div id="search"><p>Search existing wants:</p></div>
20+
21+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@algolia/algoliasearch-netlify-frontend@1/dist/algoliasearchNetlify.css" />
22+
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/@algolia/algoliasearch-netlify-frontend@1/dist/algoliasearchNetlify.js"></script>
23+
<script type="text/javascript">
24+
algoliasearchNetlify({
25+
appId: 'DHNCDDF8RA',
26+
apiKey: 'b8b628b83ba4b077f0d1225dd553f18f',
27+
siteId: '770267f7-c04f-4418-aca2-3a377b1059e0',
28+
branch: 'main',
29+
selector: 'div#search',
30+
});
31+
</script>
32+
33+
{% if collections.wants.length > 0 %}
34+
<ul class="wants">
35+
{% for w in collections.wants %}
36+
{{ want( 'li', '', w.url, 'h2', w.data.title, w.data.submitter ) }}
37+
{% endfor %}
38+
</ul>
39+
{% else %}
40+
<p>No one has submitted a want yet. <a href="/#submit">Wanna be the first?</a></p>
41+
{% endif %}

0 commit comments

Comments
 (0)