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
28
pulls
pipelines
remove features not in scope
cozylittle.house
1 month ago
1698f705
3e43160c
+8
-63
4 changed files
expand all
collapse all
unified
split
app
(home-pages)
reader
InboxContent.tsx
LocalContent.tsx
page.tsx
components
PostListing.tsx
+8
-42
app/(home-pages)/reader/InboxContent.tsx
···
73
73
74
74
return () => observer.disconnect();
75
75
}, [data, size, setSize, isValidating]);
76
76
-
let [searchValue, setSearchValue] = useState("");
77
77
-
let [sort, setSort] = useState<"recent" | "popular">("popular");
78
76
79
77
const allPosts = data ? data.flatMap((page) => page.posts) : [];
80
80
-
const postTitles = allPosts.map((p) => {
81
81
-
p.documents.data?.title;
82
82
-
});
83
83
-
const filteredPosts = allPosts
84
84
-
.filter((p) =>
85
85
-
p.documents.data?.title.toLowerCase().includes(searchValue.toLowerCase()),
86
86
-
)
87
87
-
.sort(
88
88
-
(a, b) =>
89
89
-
new Date(b.documents.data?.publishedAt || 0).getTime() -
90
90
-
new Date(a.documents.data?.publishedAt || 0).getTime(),
91
91
-
);
78
78
+
79
79
+
const sortedPosts = allPosts.sort(
80
80
+
(a, b) =>
81
81
+
new Date(b.documents.data?.publishedAt || 0).getTime() -
82
82
+
new Date(a.documents.data?.publishedAt || 0).getTime(),
83
83
+
);
92
84
93
85
if (allPosts.length === 0 && !isValidating) return <ReaderEmpty />;
94
86
···
96
88
97
89
return (
98
90
<div className="flex flex-row gap-6 ">
99
99
-
<div className="flex flex-col gap-6 relative">
100
100
-
<div className="flex justify-between gap-4 text-tertiary">
101
101
-
<Input
102
102
-
className={`inboxSearchInput
103
103
-
appearance-none! outline-hidden!
104
104
-
w-full min-w-0 text-primary relative px-1
105
105
-
border rounded-md border-border-light focus-within:border-border
106
106
-
bg-transparent ${hasBackgroundImage ? "focus-within:bg-bg-page" : "focus-within:bg-bg-leaflet"} `}
107
107
-
type="text"
108
108
-
id="inbox-search"
109
109
-
size={1}
110
110
-
placeholder="search posts..."
111
111
-
value={searchValue}
112
112
-
onChange={(e) => {
113
113
-
setSearchValue(e.currentTarget.value);
114
114
-
}}
115
115
-
/>
116
116
-
<button
117
117
-
className="flex gap-1"
118
118
-
onClick={() => {
119
119
-
setSort(sort === "popular" ? "recent" : "popular");
120
120
-
}}
121
121
-
>
122
122
-
{sort === "popular" ? "Popular" : "Recent"}
123
123
-
<SortSmall />
124
124
-
</button>
125
125
-
</div>
126
126
-
{filteredPosts.map((p) => (
91
91
+
<div className="flex flex-col gap-8 relative">
92
92
+
{sortedPosts.map((p) => (
127
93
<PostListing {...p} key={p.documents.uri} />
128
94
))}
129
95
{/* Trigger element for loading more posts */}
-9
app/(home-pages)/reader/LocalContent.tsx
···
1
1
-
"use client";
2
2
-
3
3
-
export const LocalContent = () => {
4
4
-
return (
5
5
-
<div className="flex flex-col gap-2 container bg-[rgba(var(--bg-page),.7)] sm:p-4 p-3 justify-between text-center text-tertiary">
6
6
-
Nothing here yet…
7
7
-
</div>
8
8
-
);
9
9
-
};
-5
app/(home-pages)/reader/page.tsx
···
1
1
import { DashboardLayout } from "components/PageLayouts/DashboardLayout";
2
2
import { InboxContent } from "./InboxContent";
3
3
-
import { LocalContent } from "./LocalContent";
4
3
import { GlobalContent } from "./GlobalContent";
5
4
import { getReaderFeed } from "./getReaderFeed";
6
5
···
19
18
content: (
20
19
<InboxContent nextCursor={posts.nextCursor} posts={posts.posts} />
21
20
),
22
22
-
},
23
23
-
Friends: {
24
24
-
controls: null,
25
25
-
content: <LocalContent />,
26
21
},
27
22
Global: {
28
23
controls: null,
-7
components/PostListing.tsx
···
72
72
73
73
return (
74
74
<div className="postListing flex flex-col gap-1">
75
75
-
<div className="text-sm text-tertiary flex gap-1 items-center px-1 ">
76
76
-
<div className="flex ">
77
77
-
<div className="sm:w-4 w-4 sm:h-4 h-4 rounded-full bg-test border border-border-light first:ml-0 -ml-2" />
78
78
-
<div className="sm:w-4 w-4 sm:h-4 h-4 rounded-full bg-test border border-border-light first:ml-0 -ml-2" />
79
79
-
</div>
80
80
-
others recommend
81
81
-
</div>
82
75
<BaseThemeProvider {...theme} local>
83
76
<div
84
77
id={`post-listing-${postUri}`}