Skip to content

Commit 79cb18d

Browse files
authored
fix(logo): support multiple formats and remove styling requirements (#62)
1 parent 1279917 commit 79cb18d

File tree

1 file changed

+21
-8
lines changed

1 file changed

+21
-8
lines changed

packages/astro/src/default/components/Header.astro

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,30 @@
11
---
22
import fs from 'node:fs';
3+
import path from 'node:path';
34
import { LoginButton } from './LoginButton';
45
import { ThemeSwitch } from './ThemeSwitch';
56
import { useAuth } from './setup';
67
8+
const LOGO_EXTENSIONS = [
9+
'svg',
10+
'png',
11+
'jpeg',
12+
'jpg',
13+
];
14+
715
let logo;
816
9-
try {
10-
logo = fs.readFileSync('./public/logo.svg', { encoding: 'utf8' });
11-
} catch {
12-
console.warn('No logo.svg found in public/');
17+
for (const logoFilename of LOGO_EXTENSIONS) {
18+
const exists = fs.existsSync(path.join('public', `logo.${logoFilename}`));
19+
20+
if (exists) {
21+
logo = `/${logoFilename}`;
22+
break;
23+
}
24+
}
25+
26+
if (!logo) {
27+
console.warn(`No logo found in public/. Supported filenames are: logo.(${LOGO_EXTENSIONS.join('|')})`);
1328
}
1429
---
1530

@@ -18,12 +33,10 @@ try {
1833
>
1934
<div class="flex flex-1">
2035
<a
21-
href="#"
36+
href="/"
2237
class="flex items-center text-tk-elements-topBar-logo-color hover:text-tk-elements-topBar-logo-colorHover"
2338
>
24-
<span class="h-5 w-auto">
25-
{logo && <Fragment set:html={logo} />}
26-
</span>
39+
{logo && <img class="h-5 w-auto" src={logo} />}
2740
</a>
2841
</div>
2942
<div>

0 commit comments

Comments
 (0)