Skip to content

Commit eb5924a

Browse files
Add preview for site icon
1 parent 00f8a49 commit eb5924a

File tree

3 files changed

+36
-2
lines changed

3 files changed

+36
-2
lines changed

src/components/Favicon.svelte

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
<script lang="ts">
2+
import consts from '$lib/consts';
3+
24
type Props = {
35
path?: string;
46
};
57
6-
const { path = '/minifolio.png' }: Props = $props();
8+
const { path }: Props = $props();
9+
10+
const actualPath = path ? `/data/${path}` : consts.APP_ICON_URL;
711
</script>
812

9-
<link rel="icon" href={path} />
13+
<link rel="icon" href={actualPath} />

src/lib/consts.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ export const APP_NAME = 'Minifolio';
77
/** Link to app's GitHub repo */
88
export const APP_GITHUB = 'https://github.com/MaddyGuthridge/Minifolio';
99

10+
export const APP_ICON_URL = '/minifolio.png';
11+
1012
/** Author info -- `[name, URL]` */
1113
type AuthorInfo = [string, string];
1214

@@ -22,6 +24,7 @@ export const EDIT_COMMIT_HESITATION = 1_000;
2224
export default {
2325
APP_NAME,
2426
APP_GITHUB,
27+
APP_ICON_URL,
2528
APP_AUTHOR,
2629
APP_CONTRIBUTORS,
2730
EDIT_COMMIT_HESITATION,

src/routes/admin/PublicConfig.svelte

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
import api from '$endpoints';
66
import consts from '$lib/consts';
77
import DelayedUpdater from '$lib/delayedUpdate';
8+
import itemId from '$lib/itemId';
89
import type { ConfigJson } from '$lib/server/data/config';
10+
import { itemFileUrl } from '$lib/urls';
911
1012
type Props = {
1113
configJson: ConfigJson;
@@ -33,6 +35,18 @@
3335
files={imageFiles}
3436
onchange={() => updater.update(config)}
3537
/>
38+
{#if config.siteIcon}
39+
<p>
40+
Note: the image may be squashed/stretched by the browser when
41+
displayed in the address bar.
42+
</p>
43+
<div class="site-icon-preview">
44+
<img
45+
src={itemFileUrl(itemId.ROOT, config.siteIcon)}
46+
alt={'Preview of site icon'}
47+
/>
48+
</div>
49+
{/if}
3650
</div>
3751

3852
<label for="rel-me"><h3>Verification links</h3></label>
@@ -51,3 +65,16 @@
5165
/>
5266
</form>
5367
</div>
68+
69+
<style>
70+
.site-icon-preview {
71+
aspect-ratio: 1 / 1;
72+
max-width: 30%;
73+
margin: 10px;
74+
}
75+
.site-icon-preview > img {
76+
width: 100%;
77+
height: 100%;
78+
border-radius: 10px;
79+
}
80+
</style>

0 commit comments

Comments
 (0)