@nekm/svelte-core 1.6.1 → 1.6.2
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,15 +1,27 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import type {Snippet} from "svelte";
|
|
3
|
+
import {page} from "$app/state";
|
|
3
4
|
|
|
4
5
|
export interface ExternalLinkProps {
|
|
5
6
|
readonly href: string;
|
|
6
7
|
readonly children: Snippet;
|
|
7
|
-
readonly type?: "nofollow" | "ugc" | "sponsored";
|
|
8
|
+
readonly type?: "dofollow" | "nofollow" | "ugc" | "sponsored";
|
|
9
|
+
readonly origin?: string;
|
|
8
10
|
}
|
|
9
11
|
|
|
10
|
-
const { href, children, type = "nofollow" }: ExternalLinkProps = $props();
|
|
12
|
+
const { href, children, type = "nofollow", origin }: ExternalLinkProps = $props();
|
|
13
|
+
|
|
14
|
+
const source = $derived(origin ?? page.url.origin);
|
|
15
|
+
|
|
16
|
+
const hrefWithSource = $derived.by(() => {
|
|
17
|
+
const sign = href.includes("?") ? "&" : "?";
|
|
18
|
+
return href + sign + `utm_source=${encodeURIComponent(source)}`;
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
const rel = $derived(type === "dofollow" ? undefined : type);
|
|
11
22
|
</script>
|
|
12
23
|
|
|
13
|
-
<a
|
|
24
|
+
<a href={hrefWithSource}
|
|
25
|
+
target="_blank" rel="{rel} noreferrer noopener">
|
|
14
26
|
{@render children()}
|
|
15
27
|
</a>
|
|
@@ -2,7 +2,8 @@ import type { Snippet } from "svelte";
|
|
|
2
2
|
export interface ExternalLinkProps {
|
|
3
3
|
readonly href: string;
|
|
4
4
|
readonly children: Snippet;
|
|
5
|
-
readonly type?: "nofollow" | "ugc" | "sponsored";
|
|
5
|
+
readonly type?: "dofollow" | "nofollow" | "ugc" | "sponsored";
|
|
6
|
+
readonly origin?: string;
|
|
6
7
|
}
|
|
7
8
|
declare const ExternalLink: import("svelte").Component<ExternalLinkProps, {}, "">;
|
|
8
9
|
type ExternalLink = ReturnType<typeof ExternalLink>;
|
package/package.json
CHANGED