tangled
alpha
login
or
join now
leaflet.pub
/
leaflet
289
fork
atom
a tool for shared writing and social publishing
289
fork
atom
overview
issues
27
pulls
pipelines
add comment/quote counts + links to post list
awarm.space
6 months ago
55786cd3
730b6b1e
+50
-17
1 changed file
expand all
collapse all
unified
split
app
lish
[did]
[publication]
page.tsx
+50
-17
app/lish/[did]/[publication]/page.tsx
···
11
11
PublicationThemeProvider,
12
12
} from "components/ThemeManager/PublicationThemeProvider";
13
13
import { SpeedyLink } from "components/SpeedyLink";
14
14
+
import { QuoteTiny } from "components/Icons/QuoteTiny";
15
15
+
import { CommentTiny } from "components/Icons/CommentTiny";
14
16
15
17
export default async function Publication(props: {
16
18
params: Promise<{ publication: string; did: string }>;
···
34
36
.select(
35
37
`*,
36
38
publication_subscriptions(*),
37
37
-
documents_in_publications(documents(*))
39
39
+
documents_in_publications(documents(
40
40
+
*,
41
41
+
comments_on_documents(count),
42
42
+
document_mentions_in_bsky(count)
43
43
+
))
38
44
`,
39
45
)
40
46
.eq("identity_did", did)
···
121
127
.map((doc) => {
122
128
if (!doc.documents) return null;
123
129
let uri = new AtUri(doc.documents.uri);
124
124
-
let record = doc.documents
130
130
+
let doc_record = doc.documents
125
131
.data as PubLeafletDocument.Record;
132
132
+
let quotes =
133
133
+
doc.documents.document_mentions_in_bsky[0].count || 0;
134
134
+
let comments =
135
135
+
record?.preferences?.showComments === false
136
136
+
? 0
137
137
+
: doc.documents.comments_on_documents[0].count || 0;
138
138
+
126
139
return (
127
140
<React.Fragment key={doc.documents?.uri}>
128
128
-
<div className="flex w-full ">
141
141
+
<div className="flex w-full grow flex-col ">
129
142
<SpeedyLink
130
143
href={`${getPublicationURL(publication)}/${uri.rkey}`}
131
131
-
className="publishedPost grow flex flex-col hover:!no-underline"
144
144
+
className="publishedPost hover:!no-underline flex flex-col"
132
145
>
133
133
-
<h3 className="text-primary">{record.title}</h3>
146
146
+
<h3 className="text-primary">{doc_record.title}</h3>
134
147
<p className="italic text-secondary">
135
135
-
{record.description}
148
148
+
{doc_record.description}
136
149
</p>
137
137
-
<p className="text-sm text-tertiary pt-2">
138
138
-
{record.publishedAt &&
139
139
-
new Date(record.publishedAt).toLocaleDateString(
140
140
-
undefined,
141
141
-
{
142
142
-
year: "numeric",
143
143
-
month: "long",
144
144
-
day: "2-digit",
145
145
-
},
146
146
-
)}{" "}
150
150
+
</SpeedyLink>
151
151
+
152
152
+
<div className="text-sm text-tertiary flex gap-1 flex-wrap pt-2">
153
153
+
<p className="text-sm text-tertiary ">
154
154
+
{doc_record.publishedAt &&
155
155
+
new Date(
156
156
+
doc_record.publishedAt,
157
157
+
).toLocaleDateString(undefined, {
158
158
+
year: "numeric",
159
159
+
month: "long",
160
160
+
day: "2-digit",
161
161
+
})}{" "}
147
162
</p>
148
148
-
</SpeedyLink>
163
163
+
{comments > 0 || quotes > 0 ? "| " : ""}
164
164
+
{quotes > 0 && (
165
165
+
<SpeedyLink
166
166
+
href={`${getPublicationURL(publication)}/${uri.rkey}?interactionDrawer=quotes`}
167
167
+
className="flex flex-row gap-0 text-sm text-tertiary items-center flex-wrap"
168
168
+
>
169
169
+
<QuoteTiny /> {quotes}
170
170
+
</SpeedyLink>
171
171
+
)}
172
172
+
{comments > 0 &&
173
173
+
record?.preferences?.showComments !== false && (
174
174
+
<SpeedyLink
175
175
+
href={`${getPublicationURL(publication)}/${uri.rkey}?interactionDrawer=comments`}
176
176
+
className="flex flex-row gap-0 text-sm text-tertiary items-center flex-wrap"
177
177
+
>
178
178
+
<CommentTiny /> {comments}
179
179
+
</SpeedyLink>
180
180
+
)}
181
181
+
</div>
149
182
</div>
150
183
<hr className="last:hidden border-border-light" />
151
184
</React.Fragment>