tangled
alpha
login
or
join now
dbushell.com
/
attic.social
6
fork
atom
Attic is a cozy space with lofty ambitions.
attic.social
6
fork
atom
overview
issues
pulls
pipelines
favicon proxy
dbushell.com
1 week ago
80acba46
a4794476
verified
This commit was signed with the committer's
known signature
.
dbushell.com
SSH Key Fingerprint:
SHA256:Sj5AfJ6VbC0PEnnQD2kGGEiGFwHdFBS/ypN5oifzzFI=
+53
-1
3 changed files
expand all
collapse all
unified
split
src
css
components
bookmark.css
routes
bookmarks
[did=did]
+page.svelte
favicon
[hostname]
+server.ts
+15
-1
src/css/components/bookmark.css
···
32
32
}
33
33
34
34
& > :is(h2, h3, .flex) {
35
35
+
grid-column: 1 / -1;
36
36
+
}
37
37
+
38
38
+
& > :is(h2, h3) {
35
39
font-size: var(--font-size-3);
36
36
-
grid-column: 1/ -1;
37
40
38
41
& a {
42
42
+
align-items: start;
43
43
+
column-gap: 5px;
44
44
+
display: flex;
45
45
+
39
46
&::after {
40
47
content: "";
41
48
display: block;
42
49
inset: 0;
43
50
position: absolute;
51
51
+
}
52
52
+
53
53
+
& img {
54
54
+
block-size: 20px;
55
55
+
flex: 0 0 auto;
56
56
+
inline-size: 20px;
57
57
+
margin-block: 2px;
44
58
}
45
59
}
46
60
}
+6
src/routes/bookmarks/[did=did]/+page.svelte
···
154
154
<article id={entry.cid} class="Bookmark">
155
155
<h3>
156
156
<a href={entry.url} rel="noopener noreferrer" target="_blank">
157
157
+
<img
158
158
+
alt=""
159
159
+
width="16"
160
160
+
height="16"
161
161
+
src="/bookmarks/favicon/{new URL(entry.url).hostname}"
162
162
+
/>
157
163
{entry.title}
158
164
</a>
159
165
</h3>
+32
src/routes/bookmarks/favicon/[hostname]/+server.ts
···
1
1
+
import { redirect } from "@sveltejs/kit";
2
2
+
import type { RequestHandler } from "./$types";
3
3
+
4
4
+
const copyHeaders = [
5
5
+
"Age",
6
6
+
"Cache-Control",
7
7
+
"Cotent-Type",
8
8
+
"Date",
9
9
+
"Last-Modified",
10
10
+
];
11
11
+
12
12
+
export const GET: RequestHandler = async (event) => {
13
13
+
const url = URL.parse(`https://${event.params.hostname}`);
14
14
+
if (url === null) {
15
15
+
return redirect(303, "/images/favicon.svg");
16
16
+
}
17
17
+
const response = await event.fetch(
18
18
+
`https://twenty-icons.com/${url.hostname}/32`,
19
19
+
);
20
20
+
if (response.ok === false) {
21
21
+
return redirect(303, "/images/favicon.svg");
22
22
+
}
23
23
+
if (response.headers.get("Content-Type") !== "image/png") {
24
24
+
return redirect(303, "/images/favicon.svg");
25
25
+
}
26
26
+
const headers = new Headers();
27
27
+
for (const name of copyHeaders) {
28
28
+
const value = response.headers.get(name);
29
29
+
if (value) headers.set(name, value);
30
30
+
}
31
31
+
return new Response(response.body, { headers });
32
32
+
};