@immich/ui 0.33.0 → 0.34.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,45 +1,54 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import { resolveUrl } from '../../utilities/common.js';
|
|
2
|
+
import { resolveMetadata, resolveUrl, type ArticleMetadata, type Metadata } from '../../utilities/common.js';
|
|
3
3
|
|
|
4
4
|
type Props = {
|
|
5
|
-
site:
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
imageUrl?: string;
|
|
9
|
-
};
|
|
10
|
-
page?: {
|
|
11
|
-
title: string;
|
|
12
|
-
description: string;
|
|
13
|
-
imageUrl?: string;
|
|
14
|
-
};
|
|
5
|
+
site: Metadata;
|
|
6
|
+
page?: Metadata;
|
|
7
|
+
article?: ArticleMetadata;
|
|
15
8
|
};
|
|
16
9
|
|
|
17
|
-
const { site, page }: Props = $props();
|
|
10
|
+
const { site, page, article }: Props = $props();
|
|
18
11
|
|
|
19
|
-
let
|
|
20
|
-
|
|
21
|
-
let pageDescription = $derived(page?.description ?? site.description);
|
|
22
|
-
let pageUrl = $derived(page?.imageUrl ?? site?.imageUrl);
|
|
12
|
+
let resolved = $derived(resolveMetadata(site, page, article));
|
|
23
13
|
</script>
|
|
24
14
|
|
|
25
15
|
<svelte:head>
|
|
26
|
-
<title>{
|
|
27
|
-
<meta name="description" content={
|
|
16
|
+
<title>{resolved.title}</title>
|
|
17
|
+
<meta name="description" content={resolved.description} />
|
|
18
|
+
|
|
19
|
+
<!-- Twitter Meta Tags -->
|
|
20
|
+
<meta name="twitter:card" content="summary_large_image" />
|
|
21
|
+
<meta name="twitter:title" content={resolved.title} />
|
|
22
|
+
<meta name="twitter:description" content={resolved.description} />
|
|
23
|
+
{#if resolved.imageUrl}
|
|
24
|
+
<meta property="twitter:image" content={resolveUrl(resolved.imageUrl)} />
|
|
25
|
+
{/if}
|
|
28
26
|
|
|
29
27
|
<!-- Facebook Meta Tags -->
|
|
30
|
-
<meta property="og:type" content=
|
|
31
|
-
<meta property="og:site_name" content=
|
|
32
|
-
<meta property="og:title" content={
|
|
33
|
-
<meta property="og:description" content={
|
|
34
|
-
{#if
|
|
35
|
-
<meta property="og:image" content={resolveUrl(
|
|
28
|
+
<meta property="og:type" content={resolved.type} />
|
|
29
|
+
<meta property="og:site_name" content={resolved.siteName} />
|
|
30
|
+
<meta property="og:title" content={resolved.title} />
|
|
31
|
+
<meta property="og:description" content={resolved.description} />
|
|
32
|
+
{#if resolved.imageUrl}
|
|
33
|
+
<meta property="og:image" content={resolveUrl(resolved.imageUrl)} />
|
|
36
34
|
{/if}
|
|
37
35
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
36
|
+
{#if resolved.article}
|
|
37
|
+
<meta property="og:article:published_time" content={resolved.article.publishedTime} />
|
|
38
|
+
{#if resolved.article.modifiedTime}
|
|
39
|
+
<meta property="og:article:modified_time" content={resolved.article.modifiedTime} />
|
|
40
|
+
{/if}
|
|
41
|
+
{#if resolved.article.expirationTime}
|
|
42
|
+
<meta property="og:article:expiration_time" content={resolved.article.expirationTime} />
|
|
43
|
+
{/if}
|
|
44
|
+
{#if resolved.article.section}
|
|
45
|
+
<meta property="og:article:section" content={resolved.article.section} />
|
|
46
|
+
{/if}
|
|
47
|
+
{#each resolved.article.authors ?? [] as author (author)}
|
|
48
|
+
<meta property="og:article:author" content={author} />
|
|
49
|
+
{/each}
|
|
50
|
+
{#each resolved.article.tags ?? [] as tag (tag)}
|
|
51
|
+
<meta property="og:article:tag" content={tag} />
|
|
52
|
+
{/each}
|
|
44
53
|
{/if}
|
|
45
54
|
</svelte:head>
|
|
@@ -1,14 +1,8 @@
|
|
|
1
|
+
import { type ArticleMetadata, type Metadata } from '../../utilities/common.js';
|
|
1
2
|
type Props = {
|
|
2
|
-
site:
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
imageUrl?: string;
|
|
6
|
-
};
|
|
7
|
-
page?: {
|
|
8
|
-
title: string;
|
|
9
|
-
description: string;
|
|
10
|
-
imageUrl?: string;
|
|
11
|
-
};
|
|
3
|
+
site: Metadata;
|
|
4
|
+
page?: Metadata;
|
|
5
|
+
article?: ArticleMetadata;
|
|
12
6
|
};
|
|
13
7
|
declare const SiteMetadata: import("svelte").Component<Props, {}, "">;
|
|
14
8
|
type SiteMetadata = ReturnType<typeof SiteMetadata>;
|
|
@@ -1,2 +1,31 @@
|
|
|
1
|
+
import { DateTime } from 'luxon';
|
|
1
2
|
export declare const resolveUrl: (url: string, currentHostname?: string) => string;
|
|
2
3
|
export declare const isExternalLink: (href: string) => boolean;
|
|
4
|
+
export type Metadata = {
|
|
5
|
+
title: string;
|
|
6
|
+
description: string;
|
|
7
|
+
imageUrl?: string;
|
|
8
|
+
};
|
|
9
|
+
export type ArticleMetadata = {
|
|
10
|
+
publishedTime: DateTime;
|
|
11
|
+
modifiedTime?: DateTime;
|
|
12
|
+
expirationTime?: DateTime;
|
|
13
|
+
authors?: string[];
|
|
14
|
+
section?: string;
|
|
15
|
+
tags?: string[];
|
|
16
|
+
};
|
|
17
|
+
export declare const resolveMetadata: (site: Metadata, page?: Metadata, article?: ArticleMetadata) => {
|
|
18
|
+
type: string;
|
|
19
|
+
siteName: string;
|
|
20
|
+
title: string;
|
|
21
|
+
description: string;
|
|
22
|
+
imageUrl: string | undefined;
|
|
23
|
+
article: {
|
|
24
|
+
publishedTime: string | null;
|
|
25
|
+
modifiedTime: string | null | undefined;
|
|
26
|
+
expirationTime: string | null | undefined;
|
|
27
|
+
authors: string[] | undefined;
|
|
28
|
+
section: string | undefined;
|
|
29
|
+
tags: string[] | undefined;
|
|
30
|
+
} | undefined;
|
|
31
|
+
};
|
package/dist/utilities/common.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { env } from '$env/dynamic/public';
|
|
2
|
+
import { DateTime } from 'luxon';
|
|
2
3
|
const getImmichApp = (host) => {
|
|
3
4
|
if (!host || !host.endsWith('immich.app')) {
|
|
4
5
|
return false;
|
|
@@ -20,3 +21,27 @@ export const resolveUrl = (url, currentHostname) => {
|
|
|
20
21
|
export const isExternalLink = (href) => {
|
|
21
22
|
return !(href.startsWith('/') || href.startsWith('#'));
|
|
22
23
|
};
|
|
24
|
+
export const resolveMetadata = (site, page, article) => {
|
|
25
|
+
const title = page ? `${page.title} | ${site.title}` : site.title;
|
|
26
|
+
const description = page?.description ?? site.description;
|
|
27
|
+
const imageUrl = page?.imageUrl ?? site?.imageUrl;
|
|
28
|
+
const siteName = page ? `${site.title} — ${site.description}` : site.title;
|
|
29
|
+
const type = article ? 'article' : 'website';
|
|
30
|
+
return {
|
|
31
|
+
type,
|
|
32
|
+
siteName,
|
|
33
|
+
title,
|
|
34
|
+
description,
|
|
35
|
+
imageUrl,
|
|
36
|
+
article: article
|
|
37
|
+
? {
|
|
38
|
+
publishedTime: article.publishedTime.toISO(),
|
|
39
|
+
modifiedTime: article.modifiedTime?.toISO(),
|
|
40
|
+
expirationTime: article.expirationTime?.toISO(),
|
|
41
|
+
authors: article.authors,
|
|
42
|
+
section: article.section,
|
|
43
|
+
tags: article.tags,
|
|
44
|
+
}
|
|
45
|
+
: undefined,
|
|
46
|
+
};
|
|
47
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@immich/ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.34.0",
|
|
4
4
|
"license": "GNU Affero General Public License version 3",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"create": "node scripts/create.js",
|
|
@@ -48,6 +48,7 @@
|
|
|
48
48
|
"@tailwindcss/postcss": "^4.1.7",
|
|
49
49
|
"@tailwindcss/vite": "^4.1.7",
|
|
50
50
|
"@types/eslint": "^9.6.0",
|
|
51
|
+
"@types/luxon": "^3.7.1",
|
|
51
52
|
"autoprefixer": "^10.4.20",
|
|
52
53
|
"eslint": "^9.7.0",
|
|
53
54
|
"eslint-config-prettier": "^10.0.0",
|
|
@@ -69,6 +70,7 @@
|
|
|
69
70
|
"dependencies": {
|
|
70
71
|
"@mdi/js": "^7.4.47",
|
|
71
72
|
"bits-ui": "^2.9.8",
|
|
73
|
+
"luxon": "^3.7.2",
|
|
72
74
|
"simple-icons": "^15.14.0",
|
|
73
75
|
"tailwind-merge": "^3.0.0",
|
|
74
76
|
"tailwind-variants": "^3.0.0"
|