Skip to content

Commit be61037

Browse files
authored
Merge pull request #292 from UW-Macrostrat/groups-page
Groups Page
2 parents 3160211 + 64020fb commit be61037

File tree

10 files changed

+71
-97
lines changed

10 files changed

+71
-97
lines changed

pages/columns/+Page.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { ContentPage } from "~/layouts";
22
import {
3-
AssistantLinks,
3+
Link,
44
DevLinkButton,
55
PageBreadcrumbs,
66
StickyHeader,
@@ -36,6 +36,8 @@ function ColumnListPage({ title = "Columns", linkPrefix = "/" }) {
3636
const [columnInput, setColumnInput] = useState("");
3737
const shouldFilter = columnInput.length >= 3;
3838

39+
console.log("columnGroups", columnGroups);
40+
3941
const filteredGroups = shouldFilter
4042
? columnGroups?.filter((group) => {
4143
const filteredColumns = group.columns.filter((col) => {
@@ -133,10 +135,12 @@ function ColumnGroup({ data, linkPrefix, columnInput, shouldFilter }) {
133135
{ className: "column-group", onClick: () => setIsOpen(!isOpen) },
134136
[
135137
h("div.column-group-header", [
136-
h(
137-
"h2.column-group-name",
138-
name + " (Group #" + filteredColumns[0].col_group_id + ")"
139-
),
138+
h(Link, { href: `/columns/groups/${data.id}`, target: "_blank" }, [
139+
h(
140+
"h2.column-group-name",
141+
name + " (Group #" + filteredColumns[0].col_group_id + ")"
142+
),
143+
]),
140144
]),
141145
h("div.column-list", [
142146
h("table.column-table", [
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import h from "@macrostrat/hyper";
2+
import { Page as ColumnListPage } from "#/columns/+Page.ts";
3+
4+
export function Page() {
5+
return h(ColumnListPage, {
6+
title: "Groups",
7+
});
8+
}

pages/columns/groups/+Page.ts

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

pages/columns/groups/+data.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { fetchAPIData } from "~/_utils/fetch-helpers";
2+
3+
export async function data() {
4+
const res = await fetchAPIData(`/columns`, { all: true });
5+
6+
const grouped = {};
7+
8+
for (const item of res) {
9+
const key = item.col_group_id;
10+
11+
if (!grouped[key]) {
12+
grouped[key] = {
13+
name: item.col_group,
14+
id: item.col_group_id,
15+
columns: [],
16+
};
17+
}
18+
19+
grouped[key].columns.push(item);
20+
}
21+
22+
const columnGroups = Object.values(grouped);
23+
24+
return {
25+
columnGroups,
26+
};
27+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { usePageContext } from "vike-react/usePageContext";
2+
import { IndividualPage } from "../../../lex/index";
3+
4+
export function Page() {
5+
const pageContext = usePageContext();
6+
const id = parseInt(pageContext.urlParsed.pathname.split("/")[3]);
7+
return IndividualPage(id, "col_group_id", "groups");
8+
}

pages/columns/groups/main.module.scss

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

pages/dev/lexicon/main.styl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ a:hover
6464

6565
.text
6666
text-align: right
67-
position:absolute
67+
position: absolute
6868
padding: 5px 20px
6969
z-index: 100
7070
background-color: rgba(0, 0, 0, 0.2)
@@ -78,7 +78,7 @@ a:hover
7878
color: white
7979

8080
.back-img
81-
position:absolute
81+
position: absolute
8282
z-index: 0
8383
height: 30vh
8484
object-fit: cover

pages/donate/main.module.sass

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ p
2626

2727
.donate-title
2828
a
29-
color:white
29+
color: white
3030
a:hover
3131
text-decoration: none
3232

@@ -64,14 +64,14 @@ p
6464
text-decoration: none
6565

6666
.donate-img
67-
position:absolute
67+
position: absolute
6868
z-index: 1
6969
height: 80vh
7070
width: 100%
7171
object-fit: cover
7272

7373
.text
74-
position:absolute
74+
position: absolute
7575
z-index: 100
7676
padding: 0 20px
7777

pages/lex/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ export function IndividualPage(id, type, header) {
6767
? "lithology"
6868
: header === "econs"
6969
? "economic"
70+
: header === "groups"
71+
? "group"
7072
: header === "strat_name_concepts"
7173
? "strat_name_concept"
7274
: "strat_name";

src/components/navigation/PageBreadcrumbs.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,18 @@ const columnsSubtree = {
114114
]);
115115
},
116116
},
117+
{
118+
slug: "groups",
119+
name: "Groups",
120+
children: [
121+
{
122+
param: "@id",
123+
name(urlPart, ctx) {
124+
return h("code", ctx.pageProps?.group?.group_id ?? urlPart);
125+
},
126+
},
127+
],
128+
},
117129
],
118130
};
119131

0 commit comments

Comments
 (0)