on master help sign in
pages/id: show all known groups, applications on id pages
commit28a00111c7a346fc6dc15023f6cbe69b39ba1145 authorMatilde Park <matilde.park@urbit.org> dateTue 26 Apr 2022, 18:18 (5 years ago) parenta86bba2
2 files changed+52−4
content/application/_index.md+3 pages/id/[id].js+49−4
content/application/_index.mdnew file+3
@@ -0,0 +1,3 @@
1++++
2+title = "Application Directory"
3++++
pages/id/[id].js+49−4
@@ -1,11 +1,9 @@
11import Head from "next/head";
22import Link from "next/link";
3−import { getPage } from "../../lib/lib";
3+import { getPage, getAllPosts } from "../../lib/lib";
44import { join } from "path";
5−import Meta from "../../components/Meta";
65import Container from "../../components/Container";
76import SingleColumn from "../../components/SingleColumn";
8−import ErrorPage from "../404";
97import Section from "../../components/Section";
108import ob from "urbit-ob";
119import Markdown from "../../components/Markdown";
@@ -17,7 +15,7 @@ import MetadataLink from "../../components/gateway/MetadataLink";
1715import Description from "../../components/gateway/Description";
1816import axios from "axios";
1917
20−const IdPage = ({ data, markdown, network, params }) => {
18+const IdPage = ({ data, markdown, applications, groups, network, params }) => {
2119 const { id } = params;
2220 if (!ob.isValidPatp(id) || id.length > 14) {
2321 return <Gateway404 type="ID" />;
@@ -97,6 +95,18 @@ const IdPage = ({ data, markdown, network, params }) => {
9795 />
9896 )}
9997 </div>
98+ <Creations
99+ title="Applications"
100+ id={id}
101+ parentSlug="application"
102+ data={applications}
103+ />
104+ <Creations
105+ title="Hosted Groups"
106+ id={id}
107+ parentSlug="group"
108+ data={groups}
109+ />
100110 <Description
101111 description={data.description}
102112 fallback="An Urbit ID."
@@ -157,6 +167,33 @@ const IdPage = ({ data, markdown, network, params }) => {
157167 );
158168};
159169
170+const Creations = ({ id, title, data, parentSlug }) => {
171+ return (
172+ data?.length > 0 && (
173+ <div className="flex flex-col space-y-2">
174+ <p className="text-wall-400 font-semibold">{title}</p>
175+ <div className="flex flex-wrap space-x-4">
176+ {data.map((each) => (
177+ <Link href={`/${parentSlug}/${id}/${each.slug}`}>
178+ <div className="cursor-pointer flex flex-col items-center space-y-1">
179+ <img
180+ className="overflow-hidden rounded-xl"
181+ style={{ width: 100, height: 100 }}
182+ src={
183+ each?.image ||
184+ "https://media.urbit.org/logo/urbit-logo-card.png"
185+ }
186+ />
187+ <a className="text-green-400 font-semibold">{each.title}</a>
188+ </div>
189+ </Link>
190+ ))}
191+ </div>
192+ </div>
193+ )
194+ );
195+};
196+
160197function deSig(string) {
161198 return string.startsWith("~") ? string.substring(1) : string;
162199}
@@ -171,6 +208,12 @@ export const getServerSideProps = async ({ params, res }) => {
171208 join(process.cwd(), "content/id/", params.id.slice(1))
172209 ) || { data: {}, content: "" };
173210
211+ const applications = getAllPosts(
212+ ["title", "slug", "image"],
213+ `application/${params.id}`
214+ );
215+ const groups = getAllPosts(["title", "slug", "image"], `group/${params.id}`);
216+
174217 if (!data.ship && ob.isValidPatp(params.id)) {
175218 data = { ship: params.id, description: "An Urbit ID." };
176219 }
@@ -188,6 +231,8 @@ export const getServerSideProps = async ({ params, res }) => {
188231 return {
189232 props: {
190233 data,
234+ applications,
235+ groups,
191236 markdown,
192237 network,
193238 params,