@nekm/svelte-core 1.1.1 → 1.1.3

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,19 +1,15 @@
1
1
  <script lang="ts">
2
- import {onMount} from "svelte";
3
2
  import {localeFormatDate} from "./locale.js";
4
3
 
5
- interface Props {
4
+ export interface DateTimeProps {
6
5
  readonly date: Date;
6
+ readonly locale?: string;
7
7
  }
8
8
 
9
- const { date }: Props = $props();
9
+ const { date, locale }: DateTimeProps = $props();
10
10
 
11
- const isoString = date.toISOString();
12
- let formatted = $state(isoString);
13
-
14
- onMount(() => {
15
- formatted = localeFormatDate(date);
16
- })
11
+ const isoString = $derived(date.toISOString());
12
+ const formatted = $derived(localeFormatDate(date, locale));
17
13
  </script>
18
14
 
19
15
  <time datetime={isoString}>
@@ -1,6 +1,7 @@
1
- interface Props {
1
+ export interface DateTimeProps {
2
2
  readonly date: Date;
3
+ readonly locale?: string;
3
4
  }
4
- declare const DateTime: import("svelte").Component<Props, {}, "">;
5
+ declare const DateTime: import("svelte").Component<DateTimeProps, {}, "">;
5
6
  type DateTime = ReturnType<typeof DateTime>;
6
7
  export default DateTime;
@@ -22,12 +22,12 @@
22
22
 
23
23
  const { id, productionDomain }: GoogleAnalyticsProps = $props();
24
24
 
25
+ const productionDomainStr = $derived(productionDomain instanceof URL ? productionDomain.hostname : productionDomain);
26
+
25
27
  onMount(() => {
26
28
  let config: GoogleAnalyticsConfig = { debug_mode: true };
27
29
 
28
30
  if (productionDomain) {
29
- const productionDomainStr = productionDomain instanceof URL ? productionDomain.hostname : productionDomain;
30
-
31
31
  if (page.url.hostname === productionDomainStr) {
32
32
  config = {};
33
33
  }
package/dist/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
+ export * from "./google-analytics.js";
1
2
  export { default as GoogleAnalytics } from "./google-analytics.svelte";
2
3
  export * from "./google-analytics.svelte";
3
- export * from "./google-analytics.js";
4
4
  export { default as Seo } from "./seo.svelte";
5
5
  export * from "./seo.svelte";
6
6
  export { default as DateTime } from "./date-time.svelte";
7
+ export * from "./date-time.svelte";
package/dist/index.js CHANGED
@@ -1,6 +1,7 @@
1
+ export * from "./google-analytics.js";
1
2
  export { default as GoogleAnalytics } from "./google-analytics.svelte";
2
3
  export * from "./google-analytics.svelte";
3
- export * from "./google-analytics.js";
4
4
  export { default as Seo } from "./seo.svelte";
5
5
  export * from "./seo.svelte";
6
6
  export { default as DateTime } from "./date-time.svelte";
7
+ export * from "./date-time.svelte";
package/dist/seo.svelte CHANGED
@@ -45,20 +45,14 @@
45
45
  }
46
46
 
47
47
  // Starts with http or https. I.e, is an absolute URL.
48
- const iconHref = !icon.href.match(/^https?:\/\//ig)
49
- ? `${strTrimEnd(origin, "/")}/${strTrimStart(icon.href, "/")}`
50
- : icon.href;
51
-
52
- let canonicalUrl = $state(createCanonical(canonical, true));
53
- let nextUrl = $state(createCanonical(next));
54
-
55
- $effect(() => {
56
- canonicalUrl = createCanonical(canonical, true);
48
+ const iconHref = $derived.by(() => {
49
+ return !icon.href.match(/^https?:\/\//ig)
50
+ ? `${strTrimEnd(origin, "/")}/${strTrimStart(icon.href, "/")}`
51
+ : icon.href;
57
52
  });
58
53
 
59
- $effect(() => {
60
- nextUrl = createCanonical(next);
61
- });
54
+ const canonicalUrl = $derived(createCanonical(canonical, true));
55
+ const nextUrl = $derived(createCanonical(next));
62
56
  </script>
63
57
 
64
58
  <svelte:head>
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@nekm/svelte-core",
3
3
  "description": "Code I find myself re-writing over-and-over, Svelte edition.",
4
- "version": "1.1.1",
4
+ "version": "1.1.3",
5
5
  "scripts": {
6
6
  "dev": "vite dev",
7
7
  "build": "vite build && npm run prepack",