on master help sign in
applications: get org title if present, take precedence over dev field
9ff72b9Matilde Park
pages/applications/[[...application]].js+37−16
@@ -1,6 +1,6 @@
1import Head from "next/head";
1import Head from "next/head";
2import Link from "next/link";
2import Link from "next/link";
3−import { getPage } from "../../lib/lib";
3+import { getPage, getAllPosts } from "../../lib/lib";
4import { join } from "path";
4import { join } from "path";
5import CopyLink from "../../components/CopyLink";
5import CopyLink from "../../components/CopyLink";
6import {
6import {
@@ -16,7 +16,7 @@ import MetadataBlock from "../../components/gateway/MetadataBlock";
16import MetadataLink from "../../components/gateway/MetadataLink";
16import MetadataLink from "../../components/gateway/MetadataLink";
17import Description from "../../components/gateway/Description";
17import Description from "../../components/gateway/Description";
18
18
19−const ApplicationPage = ({ data, markdown, params }) => {
19+const ApplicationPage = ({ data, markdown, organisation, params }) => {
20 const { application } = params;
20 const { application } = params;
21 if (!ob.isValidPatp(application[0])) {
21 if (!ob.isValidPatp(application[0])) {
22 return <Gateway404 type="application" />;
22 return <Gateway404 type="application" />;
@@ -29,6 +29,31 @@ const ApplicationPage = ({ data, markdown, params }) => {
29 data.title
29 data.title
30 }.png?${reqParams.join("&")}`;
30 }.png?${reqParams.join("&")}`;
31
31
32+ let devLink;
33+
34+ if (organisation) {
35+ devLink = (
36+ <MetadataLink
37+ title="Developer"
38+ href={`/organizations/${organisation.slug}`}
39+ content={organisation.title}
40+ />
41+ );
42+ } else {
43+ devLink =
44+ ob.isValidPatp(data?.developer || "") && data?.developer.length <= 14 ? (
45+ <MetadataLink
46+ title="Developer"
47+ href={`/ids/${data.developer}`}
48+ content={data.developer}
49+ />
50+ ) : (
51+ <MetadataBlock
52+ title="Developer"
53+ content={data.developer ? data.developer : "Unknown"}
54+ />
55+ );
56+ }
32 return (
57 return (
33 <Container>
58 <Container>
34 <Head>
59 <Head>
@@ -76,19 +101,7 @@ const ApplicationPage = ({ data, markdown, params }) => {
76 }
101 }
77 />
102 />
78 )}
103 )}
79− {ob.isValidPatp(data?.developer || "") &&
104+ {devLink}
80− data?.developer.length <= 14 ? (
81− <MetadataLink
82− title="Developer"
83− href={`/ids/${data.developer}`}
84− content={data.developer}
85− />
86− ) : (
87− <MetadataBlock
88− title="Developer"
89− content={data.developer ? data.developer : "Unknown"}
90− />
91− )}
92 <CopyLink
105 <CopyLink
93 className="basis-1/2 sm:basis-1/4"
106 className="basis-1/2 sm:basis-1/4"
94 content={data.shortcode ? data.shortcode : data.title}
107 content={data.shortcode ? data.shortcode : data.title}
@@ -119,7 +132,9 @@ const ApplicationPage = ({ data, markdown, params }) => {
119 urbit.org?
132 urbit.org?
120 </p>
133 </p>
121 <Link href="/applications/submit" passHref>
134 <Link href="/applications/submit" passHref>
122− <a className="font-bold text-green-400">Submit your application</a>
135+ <a className="font-bold text-green-400">
136+ Submit your application
137+ </a>
123 </Link>
138 </Link>
124 </div>
139 </div>
125 <Link href="/" passHref>
140 <Link href="/" passHref>
@@ -145,6 +160,11 @@ export const getServerSideProps = async ({ params, res }) => {
145 )
160 )
146 ) || { data: {}, content: "" };
161 ) || { data: {}, content: "" };
147
162
163+ const organisation =
164+ getAllPosts(["title", "slug", "ships"], "organizations").filter((e) =>
165+ e.ships.includes(params.application?.[0])
166+ )[0] || null;
167+
148 const markdown =
168 const markdown =
149 content !== ""
169 content !== ""
150 ? JSON.stringify(Markdown.parse({ post: { content } }))
170 ? JSON.stringify(Markdown.parse({ post: { content } }))
@@ -161,6 +181,7 @@ export const getServerSideProps = async ({ params, res }) => {
161 props: {
181 props: {
162 data,
182 data,
163 markdown,
183 markdown,
184+ organisation,
164 params,
185 params,
165 },
186 },
166 };
187 };