1export { theme } from "../tags/question-layout.marko";
2export interface Input {
3 question: Question;
4}
5
6server export function meta({ context, question }) {
7 const isDiscord = context.req
8 .header("user-agent")
9 ?.toLowerCase()
10 .includes("discord");
11 if (question.type === QuestionType.normal) {
12 return {
13 title: "question permalink",
14 openGraph: {
15 title: isDiscord
16 ? undefined
17 : `question at ${formatQuestionTimestamp(question.date)}`,
18 image: `https://paperclover.net/q+a/${question.id}.png`,
19 },
20 twitter: { card: "summary_large_image" },
21 themeColor: isDiscord
22 ? question.date.getTime() > transitionDate
23 ? "#8c78ff"
24 : "#58ff71"
25 : undefined,
26 };
27 }
28 return { title: "question permalink" };
29}
30
31<const/{ question }=input>
32<const/{ type }=question>
33
34<question-layout>
35 <if=type == QuestionType.normal>
36 <p>this page is a permalink to the following question:</p>
37 <question ...{ question }/>
38 </if>
39 <else if=type == QuestionType.pending>
40 <p>
41 this page is a permalink to a question that has not yet been answered.
42 </p>
43 <p><a href="/q+a">read questions with existing responses</a>.</p>
44 </else>
45 <else if=type == QuestionType.reject>
46 <p>
47 this page is a permalink to a question, but the question was deleted
48 instead of answered. maybe it was sent multiple times, or maybe the
49 question was not a question. who knows.
50 </p>
51 <p>sorry, sister</p>
52 <p><a href="/q+a">all questions</a></p>
53 </else>
54 <else>
55 <p>oh dear, this question is in an invalid state</p>
56 <pre>${JSON.stringify(question, null, 2)}</pre>
57 </else>
58
59 <a href="/q+a">view more questions</a>
60</question-layout>
61
62import { Question, QuestionType } from "#src/q+a/models/Question.ts";
63import { transitionDate } from "#src/q+a/tags/question.marko";
64import { formatQuestionTimestamp } from "#src/q+a/format.ts";