svelte-link-interceptor 0.1.0 → 0.1.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.
- package/README.md +39 -0
- package/package.json +4 -3
package/README.md
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# svelte-link-interceptor
|
|
2
|
+
|
|
3
|
+
Svelte action to intercept all `<a>` tag clicks in your SPA. Handle internal routing and external link modifications with ease.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install svelte-link-interceptor
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```svelte
|
|
14
|
+
<script>
|
|
15
|
+
import { linkInterceptor } from 'svelte-link-interceptor'
|
|
16
|
+
|
|
17
|
+
const options = {
|
|
18
|
+
onInternalLink(ctx) {
|
|
19
|
+
ctx.preventDefault()
|
|
20
|
+
goto(ctx.path) // SvelteKit
|
|
21
|
+
},
|
|
22
|
+
onExternalLink(ctx) {
|
|
23
|
+
ctx.url.searchParams.set('utm_source', 'myapp')
|
|
24
|
+
},
|
|
25
|
+
}
|
|
26
|
+
</script>
|
|
27
|
+
|
|
28
|
+
<div use:linkInterceptor={options}>
|
|
29
|
+
...
|
|
30
|
+
</div>
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Docs & Playground
|
|
34
|
+
|
|
35
|
+
https://babu-ch.github.io/link-interceptor/?fw=svelte
|
|
36
|
+
|
|
37
|
+
## License
|
|
38
|
+
|
|
39
|
+
[MIT](https://github.com/babu-ch/link-interceptor/blob/main/LICENSE)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "svelte-link-interceptor",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Svelte action to intercept all <a> tag clicks in your SPA — handle internal routing and external link modifications with ease.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"anchor",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
],
|
|
14
14
|
"author": "babu-ch",
|
|
15
15
|
"license": "MIT",
|
|
16
|
-
"homepage": "https://
|
|
16
|
+
"homepage": "https://babu-ch.github.io/link-interceptor/?fw=svelte",
|
|
17
17
|
"repository": {
|
|
18
18
|
"type": "git",
|
|
19
19
|
"url": "git+https://github.com/babu-ch/link-interceptor.git",
|
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
"node": ">=18.0.0"
|
|
28
28
|
},
|
|
29
29
|
"files": [
|
|
30
|
+
"README.md",
|
|
30
31
|
"dist"
|
|
31
32
|
],
|
|
32
33
|
"type": "module",
|
|
@@ -53,7 +54,7 @@
|
|
|
53
54
|
"svelte": "^5.0.0",
|
|
54
55
|
"typescript": "^5.8.2",
|
|
55
56
|
"vite-plus": "^0.1.14",
|
|
56
|
-
"link-interceptor": "0.1.
|
|
57
|
+
"link-interceptor": "0.1.2"
|
|
57
58
|
},
|
|
58
59
|
"scripts": {
|
|
59
60
|
"build": "vp pack",
|