Skip to content

Commit 88a4646

Browse files
authored
Add missing tags (#26)
added missing tags
1 parent b160d38 commit 88a4646

File tree

15 files changed

+262
-1
lines changed

15 files changed

+262
-1
lines changed
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
---
2+
import { Fragment } from "astro/jsx-runtime";
3+
import "./Pagination.scss";
4+
const { pagination } = Astro.props;
5+
6+
const adjacentLinks = 2;
7+
const maxLinks = adjacentLinks * 2 + 1;
8+
const lowerLimit = adjacentLinks + 1;
9+
const upperLimit = pagination.totalPages - adjacentLinks;
10+
---
11+
12+
{
13+
pagination.totalPages > 1 && (
14+
<ul class="pagination">
15+
{/* First page */}
16+
{pagination.pageNumber !== 1 && (
17+
<li class="pagination__item pagination__item--first">
18+
<a class="pagination__link pagination__link--first" href={1}>
19+
««
20+
</a>
21+
</li>
22+
)}
23+
24+
{/* Previous page */}
25+
{pagination.hasPrev && (
26+
<li class="pagination__item pagination__item--previous">
27+
<a
28+
href={pagination.prev.url}
29+
class="pagination__link pagination__link--previous"
30+
>
31+
«
32+
</a>
33+
</li>
34+
)}
35+
36+
{/* Page numbers */}
37+
{pagination.pagers.map((page) => {
38+
return (
39+
<Fragment>
40+
{(() => {
41+
const isInRange =
42+
pagination.totalPages > maxLinks
43+
? pagination.pageNumber < lowerLimit + 1
44+
? page.pageNumber < maxLinks + 1
45+
: pagination.pageNumber >= upperLimit
46+
? page.pageNumber > pagination.totalPages - maxLinks
47+
: page.pageNumber >=
48+
pagination.pageNumber - adjacentLinks &&
49+
page.pageNumber <
50+
pagination.pageNumber + adjacentLinks + 1
51+
: true;
52+
53+
return (
54+
isInRange && (
55+
<li
56+
class={`pagination__item${page.pageNumber === pagination.pageNumber ? " pagination__item--current" : ""}`}
57+
>
58+
<a href={page.url} class="pagination__link">
59+
{page.pageNumber}
60+
</a>
61+
</li>
62+
)
63+
);
64+
})()}
65+
</Fragment>
66+
);
67+
})}
68+
69+
{/* Next page */}
70+
{pagination.hasNext && (
71+
<li class="pagination__item pagination__item--next">
72+
<a
73+
href={pagination.next.url}
74+
class="pagination__link pagination__link--next"
75+
>
76+
»
77+
</a>
78+
</li>
79+
)}
80+
81+
{/* Last page */}
82+
{pagination.pageNumber !== pagination.totalPages && (
83+
<li class="pagination__item pagination__item--last">
84+
<a
85+
class="pagination__link pagination__link--last"
86+
href={pagination.last.url}
87+
>
88+
»»
89+
</a>
90+
</li>
91+
)}
92+
</ul>
93+
)
94+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
.pagination {
2+
text-align: center;
3+
font-weight: bold;
4+
display: flex;
5+
justify-content: space-between;
6+
max-width: 10rem;
7+
margin: auto;
8+
padding: 0;
9+
10+
li {
11+
display: inline;
12+
text-align: center;
13+
}
14+
15+
a {
16+
text-decoration: auto;
17+
}
18+
19+
.pagination__item--current {
20+
color: black;
21+
}
22+
}

src/content/questions/comp2804/2019-fall-final/1/index.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,7 @@ solution: comp2804/2019-fall-final/1/solution.md
88
tags:
99
- comp2804
1010
- comp2804-final
11+
- comp2804-counting-bitstrings-of-length-n-(3.1.1)
12+
- comp2804-permutations-and-binomial-coefficients-(3.6.2)
13+
- comp2804-the-product-rule-(3.1)
1114
---

src/content/questions/comp2804/2019-fall-final/10/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ solution: comp2804/2019-fall-final/10/solution.md
88
tags:
99
- comp2804
1010
- comp2804-final
11+
- comp2804-a-recursively-defined-set-(4.3)
1112
---

src/content/questions/comp2804/2019-fall-final/11/index.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,8 @@ solution: comp2804/2019-fall-final/11/solution.md
88
tags:
99
- comp2804
1010
- comp2804-final
11+
- comp2804-permutations-and-binomial-coefficients-(3.6.2)
12+
- comp2804-the-product-rule-(3.1)
13+
- comp2804-basic-rules-of-probability-(5.3)
14+
- comp2804-independent-events-(5.11)
1115
---

src/content/questions/comp2804/2019-fall-final/2/index.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,7 @@ solution: comp2804/2019-fall-final/2/solution.md
88
tags:
99
- comp2804
1010
- comp2804-final
11+
- comp2804-counting-bitstrings-of-length-n-(3.1.1)
12+
- comp2804-permutations-and-binomial-coefficients-(3.6.2)
13+
- comp2804-the-product-rule-(3.1)
1114
---

src/content/questions/comp2804/2019-fall-final/21/index.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,6 @@ solution: comp2804/2019-fall-final/21/solution.md
88
tags:
99
- comp2804
1010
- comp2804-final
11+
- comp2804-independent-events-(5.11)
12+
- comp2804-indicator-random-variables-(6.8)
1113
---

src/content/questions/comp2804/2019-fall-final/22/index.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,6 @@ solution: comp2804/2019-fall-final/22/solution.md
88
tags:
99
- comp2804
1010
- comp2804-final
11+
- comp2804-determining-the-expected-value-(6.6.1)
12+
- comp2804-indicator-random-variables-(6.8)
1113
---

src/content/questions/comp2804/2019-fall-final/24/index.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,6 @@ solution: comp2804/2019-fall-final/24/solution.md
88
tags:
99
- comp2804
1010
- comp2804-final
11+
- comp2804-permutations-and-binomial-coefficients-(3.6.2)
12+
- comp2804-indicator-random-variables-(6.8)
1113
---

src/content/questions/comp2804/2019-fall-final/3/index.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,8 @@ solution: comp2804/2019-fall-final/3/solution.md
88
tags:
99
- comp2804
1010
- comp2804-final
11+
- comp2804-counting-bitstrings-of-length-n-(3.1.1)
12+
- comp2804-permutations-and-binomial-coefficients-(3.6.2)
13+
- comp2804-the-product-rule-(3.1)
14+
- comp2804-the-principle-of-inclusion-and-exclusion-(3.5)
1115
---

src/content/questions/comp2804/2019-fall-final/4/index.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,8 @@ solution: comp2804/2019-fall-final/4/solution.md
88
tags:
99
- comp2804
1010
- comp2804-final
11+
- comp2804-counting-bitstrings-of-length-n-(3.1.1)
12+
- comp2804-permutations-and-binomial-coefficients-(3.6.2)
13+
- comp2804-the-product-rule-(3.1)
14+
- comp2804-the-principle-of-inclusion-and-exclusion-(3.5)
1115
---

src/content/questions/comp2804/2019-fall-final/5/index.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,8 @@ solution: comp2804/2019-fall-final/5/solution.md
88
tags:
99
- comp2804
1010
- comp2804-final
11+
- comp2804-permutations-and-binomial-coefficients-(3.6.2)
12+
- comp2804-the-product-rule-(3.1)
13+
- comp2804-the-bijection-rule-(3.2.1)
14+
- comp2804-the-complement-rule-(3.3)
1115
---

src/content/questions/comp2804/2019-fall-final/9/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ solution: comp2804/2019-fall-final/9/solution.md
88
tags:
99
- comp2804
1010
- comp2804-final
11+
- comp2804-a-recursively-defined-set-(4.3)
1112
---

src/pages/evaluations.astro

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import Back from "@components/Back/Back.astro";
33
import RowCard from "@components/RowCard/RowCard.astro";
44
import { getCollection } from "astro:content";
55
import { default as Layout } from "src/layouts/Content/Content.astro";
6+
import Pagination from "@components/Pagination/Pagination.astro";
67
const evaluations = await getCollection("evaluations");
78
89
const courseCodes = {
@@ -11,7 +12,10 @@ const courseCodes = {
1112
1213
const comp2804Evaluations = evaluations
1314
.filter((evaluation) => evaluation.data.course === "comp2804")
14-
.sort((a, b) => Number(b.data.created_at) - Number(a.data.created_at));
15+
.sort((a, b) => Number(b.data.created_at) - Number(a.data.created_at))
16+
.slice(0, 8);
17+
18+
const numberOfPages = Math.ceil(comp2804Evaluations.length / 8);
1519
---
1620

1721
<Layout title="Evaluations">
@@ -45,6 +49,22 @@ const comp2804Evaluations = evaluations
4549
))
4650
}
4751
</div>
52+
<Pagination
53+
pagination={{
54+
pageNumber: 1,
55+
totalPages: numberOfPages,
56+
hasPrev: false,
57+
prev: { url: "" },
58+
hasNext: numberOfPages > 1,
59+
next: { url: "/evaluations/2" },
60+
first: { url: "/evaluations/1" },
61+
last: { url: `/evaluations/${numberOfPages}` },
62+
pagers: Array.from({ length: numberOfPages }, (_, i) => ({
63+
pageNumber: i + 1,
64+
url: `/evaluations/${i + 1}`,
65+
})),
66+
}}
67+
/>
4868
</Layout>
4969

5070
<style>

src/pages/evaluations/[page].astro

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
---
2+
import Back from "@components/Back/Back.astro";
3+
import RowCard from "@components/RowCard/RowCard.astro";
4+
import { getCollection } from "astro:content";
5+
import { default as Layout } from "src/layouts/Content/Content.astro";
6+
import Pagination from "@components/Pagination/Pagination.astro";
7+
const evaluations = await getCollection("evaluations");
8+
9+
const courseCodes = {
10+
comp2804: "COMP 2804",
11+
};
12+
13+
const comp2804Evaluations = evaluations
14+
.filter((evaluation) => evaluation.data.course === "comp2804")
15+
.sort((a, b) => Number(b.data.created_at) - Number(a.data.created_at));
16+
17+
export async function getStaticPaths({ paginate }) {
18+
const evaluations = await getCollection("evaluations");
19+
20+
const comp2804Evaluations = evaluations
21+
.filter((evaluation) => evaluation.data.course === "comp2804")
22+
.sort((a, b) => Number(b.data.created_at) - Number(a.data.created_at));
23+
24+
// turn the above into a list
25+
const evaluationPages = comp2804Evaluations.map((evaluation) => ({
26+
evaluation,
27+
}));
28+
29+
// Generate pages from our array of evaluations, with 5 to a page
30+
return paginate(evaluationPages, { pageSize: 8 });
31+
}
32+
// All paginated data is passed on the "page" prop
33+
const { page } = Astro.props;
34+
---
35+
36+
<Layout title="Evaluations">
37+
<div class="Question__bar">
38+
<div><Back href={`/`} label="Home" /></div>
39+
</div>
40+
<h1>Evaluations</h1>
41+
<p>
42+
Practice previous evaluations from Carleton University's Computer Science
43+
courses.
44+
</p>
45+
<div style="margin-top:2.5rem"></div>
46+
<!-- <h2>COMP 2804: Discrete Structures II</h2>
47+
<p>
48+
Topics include: counting, sequences and sums, discrete probability, basic
49+
statistics, recurrence relations, randomized algorithms. Material is
50+
illustrated through examples from computing.
51+
</p>
52+
<br /> -->
53+
<div class="Evaluations__list" style="margin-bottom:0.75rem">
54+
{
55+
page.data.map(({ evaluation }) => (
56+
<div>
57+
<a href={`/evaluations/${evaluation.slug}`}>
58+
<RowCard
59+
title={`${courseCodes.comp2804}: ${evaluation.data.title}`}
60+
icon="mdi mdi-book-open-variant"
61+
/>
62+
</a>
63+
</div>
64+
))
65+
}
66+
</div>
67+
<Pagination
68+
pagination={{
69+
pageNumber: page.currentPage,
70+
totalPages: page.lastPage,
71+
hasPrev: !!page.url.prev,
72+
prev: { url: page.url.prev || "" },
73+
hasNext: !!page.url.next,
74+
next: { url: page.url.next || "" },
75+
first: { url: "/evaluations/1" },
76+
last: { url: page.lastPage ? `/evaluations/${page.lastPage}` : "" },
77+
pagers: Array.from({ length: page.lastPage }, (_, i) => ({
78+
pageNumber: i + 1,
79+
url: `/evaluations/${i + 1}`,
80+
})),
81+
}}
82+
/>
83+
</Layout>
84+
85+
<style>
86+
p {
87+
color: gray;
88+
}
89+
90+
.Evaluations__list {
91+
display: flex;
92+
flex-direction: column;
93+
gap: 0.75rem;
94+
}
95+
</style>

0 commit comments

Comments
 (0)