@immich/ui 0.32.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.
@@ -0,0 +1,54 @@
1
+ <script lang="ts">
2
+ import { resolveMetadata, resolveUrl, type ArticleMetadata, type Metadata } from '../../utilities/common.js';
3
+
4
+ type Props = {
5
+ site: Metadata;
6
+ page?: Metadata;
7
+ article?: ArticleMetadata;
8
+ };
9
+
10
+ const { site, page, article }: Props = $props();
11
+
12
+ let resolved = $derived(resolveMetadata(site, page, article));
13
+ </script>
14
+
15
+ <svelte:head>
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}
26
+
27
+ <!-- Facebook Meta Tags -->
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)} />
34
+ {/if}
35
+
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}
53
+ {/if}
54
+ </svelte:head>
@@ -0,0 +1,9 @@
1
+ import { type ArticleMetadata, type Metadata } from '../../utilities/common.js';
2
+ type Props = {
3
+ site: Metadata;
4
+ page?: Metadata;
5
+ article?: ArticleMetadata;
6
+ };
7
+ declare const SiteMetadata: import("svelte").Component<Props, {}, "">;
8
+ type SiteMetadata = ReturnType<typeof SiteMetadata>;
9
+ export default SiteMetadata;
package/dist/index.d.ts CHANGED
@@ -51,6 +51,7 @@ export { default as NavbarItem } from './components/Navbar/NavbarItem.svelte';
51
51
  export { default as PasswordInput } from './components/PasswordInput/PasswordInput.svelte';
52
52
  export { default as Scrollable } from './components/Scrollable/Scrollable.svelte';
53
53
  export { default as Select } from './components/Select/Select.svelte';
54
+ export { default as SiteMetadata } from './components/SiteMetadata/SiteMetadata.svelte';
54
55
  export { default as HStack } from './components/Stack/HStack.svelte';
55
56
  export { default as Stack } from './components/Stack/Stack.svelte';
56
57
  export { default as VStack } from './components/Stack/VStack.svelte';
package/dist/index.js CHANGED
@@ -53,6 +53,7 @@ export { default as NavbarItem } from './components/Navbar/NavbarItem.svelte';
53
53
  export { default as PasswordInput } from './components/PasswordInput/PasswordInput.svelte';
54
54
  export { default as Scrollable } from './components/Scrollable/Scrollable.svelte';
55
55
  export { default as Select } from './components/Select/Select.svelte';
56
+ export { default as SiteMetadata } from './components/SiteMetadata/SiteMetadata.svelte';
56
57
  export { default as HStack } from './components/Stack/HStack.svelte';
57
58
  export { default as Stack } from './components/Stack/Stack.svelte';
58
59
  export { default as VStack } from './components/Stack/VStack.svelte';
@@ -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
+ };
@@ -1,5 +1,7 @@
1
+ import { env } from '$env/dynamic/public';
2
+ import { DateTime } from 'luxon';
1
3
  const getImmichApp = (host) => {
2
- if (!host.endsWith('immich.app')) {
4
+ if (!host || !host.endsWith('immich.app')) {
3
5
  return false;
4
6
  }
5
7
  if (host === 'immich.app' || host.startsWith('pr-')) {
@@ -13,9 +15,33 @@ export const resolveUrl = (url, currentHostname) => {
13
15
  }
14
16
  const target = new URL(url);
15
17
  const targetApp = getImmichApp(target.hostname);
16
- const currentApp = getImmichApp(currentHostname ?? globalThis.location.hostname);
18
+ const currentApp = getImmichApp(currentHostname ?? globalThis.location?.hostname ?? env.PUBLIC_IMMICH_HOSTNAME);
17
19
  return targetApp && targetApp === currentApp ? target.pathname : target.href;
18
20
  };
19
21
  export const isExternalLink = (href) => {
20
22
  return !(href.startsWith('/') || href.startsWith('#'));
21
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.32.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"