Add favicon
Some checks failed
Deploy Worker / deploy (push) Has been cancelled

Signed-off-by: Joe Ma <rikkaneko23@gmail.com>
This commit is contained in:
Joe Ma 2025-08-04 21:02:38 +08:00
parent a65f25166a
commit 8e7a25bad5
No known key found for this signature in database
GPG key ID: 7A0ECF5F5EDC587F
4 changed files with 10 additions and 9 deletions

BIN
frontend/favicon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

View file

@ -22,6 +22,7 @@
<title>Paste</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width initial-scale=1 shrink-to-fit=1">
<link rel="icon" href="favicon.png" sizes="any" type="image/png;">
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.css" rel="stylesheet">
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.3.2/css/bootstrap.min.css" rel="stylesheet">
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-icons/1.9.1/font/bootstrap-icons.min.css"
@ -31,7 +32,10 @@
<body>
<nav class="navbar sticky-top navbar-expand-lg navbar-dark bg-dark" id="navbar">
<div class="container-fluid">
<span class="navbar-brand">Paste</span>
<span class="navbar-brand" href="#">
<img src="favicon.png" alt="Logo" width="24" height="28" class="d-inline-block align-middle me-1">
Paste
</span>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbar_supported_content"
aria-controls="navbar_supported_content" aria-expanded="false" aria-label="Toggle navigation">
<span class="bi bi-chevron-down"></span>

View file

@ -25,7 +25,7 @@ import { check_password_rules, get_paste_info, get_auth, gen_id } from './utils'
import constants, { fetch_constant } from './constant';
import { get_presign_url, router as large_upload } from './api/large_upload';
import v2api from './v2/api';
import { PasteIndexEntry, PasteTypeStr, PasteTypeFrom, PasteType } from './v2/schema';
import { PasteIndexEntry, PasteTypeFrom, PasteType } from './v2/schema';
// In favour of new cors() in itty-router v5
const { preflight, corsify } = cors({
@ -79,13 +79,8 @@ router.get('/', (request, env, ctx) => {
});
// Favicon
router.get('/favicon.ico', () => {
return new Response(null, {
headers: {
'cache-control': 'public, max-age=172800',
},
status: 404,
});
router.get('/favicon.png', (request, env, ctx) => {
return serve_static(env.PASTE_WEB_URL + '/favicon.png', request.headers);
});
// Web script and style file

View file

@ -25,6 +25,8 @@ export async function serve_static(path: string, req_headers?: Headers): Promise
else if (path.endsWith('.css')) mime = 'text/css; charset=UTF-8;';
else if (path.endsWith('.html')) mime = 'text/html; charset=UTF-8;';
else if (path.endsWith('.ico')) mime = 'image/x-icon';
else if (path.endsWith('.png')) mime = 'image/png';
else if (path.endsWith('.jpg')) mime = 'image/jpg';
else
return new Response(null, {
headers: {