Skip to content

Commit 2c7f7f5

Browse files
authored
feat: migrate to $app/state (#358)
* feat: migrate to `$app/state` * migrate test
1 parent 4c3a504 commit 2c7f7f5

File tree

5 files changed

+13
-8
lines changed

5 files changed

+13
-8
lines changed

.changeset/sixty-shrimps-mate.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'sv': patch
3+
---
4+
5+
feat: migrate to `$app/state`

packages/addons/paraglide/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ export default defineAddon({
231231

232232
imports.addDefault(script.ast, '$lib/paraglide/messages.js', '* as m');
233233
imports.addNamed(script.ast, '$app/navigation', { goto: 'goto' });
234-
imports.addNamed(script.ast, '$app/stores', { page: 'page' });
234+
imports.addNamed(script.ast, '$app/state', { page: 'page' });
235235
imports.addNamed(script.ast, '$lib/i18n', { i18n: 'i18n' });
236236
if (typescript) {
237237
imports.addNamed(
@@ -253,7 +253,7 @@ export default defineAddon({
253253
${ts('', '* @param {import("$lib/paraglide/runtime").AvailableLanguageTag} newLanguage')}
254254
${ts('', '*/')}
255255
function switchToLanguage(newLanguage${ts(': AvailableLanguageTag')}) {
256-
const canonicalPath = i18n.route($page.url.pathname);
256+
const canonicalPath = i18n.route(page.url.pathname);
257257
const localisedPath = i18n.resolveRoute(canonicalPath, newLanguage);
258258
goto(localisedPath);
259259
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
function switchToLanguage(newLanguage) {
2-
const canonicalPath = i18n.route($page.url.pathname);
2+
const canonicalPath = i18n.route(page.url.pathname);
33
const localisedPath = i18n.resolveRoute(canonicalPath, newLanguage);
44
goto(localisedPath);
55
}

packages/core/tests/js/common/jsdoc-comment/output.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* @param {import("$lib/paraglide/runtime").AvailableLanguageTag} newLanguage
33
*/
44
function switchToLanguage(newLanguage) {
5-
const canonicalPath = i18n.route($page.url.pathname);
5+
const canonicalPath = i18n.route(page.url.pathname);
66
const localisedPath = i18n.resolveRoute(canonicalPath, newLanguage);
77
goto(localisedPath);
88
}

packages/create/templates/demo/src/routes/Header.svelte

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<script lang="ts">
2-
import { page } from '$app/stores';
2+
import { page } from '$app/state';
33
import logo from '$lib/images/svelte-logo.svg';
44
import github from '$lib/images/github.svg';
55
</script>
@@ -16,13 +16,13 @@
1616
<path d="M0,0 L1,2 C1.5,3 1.5,3 2,3 L2,0 Z" />
1717
</svg>
1818
<ul>
19-
<li aria-current={$page.url.pathname === '/' ? 'page' : undefined}>
19+
<li aria-current={page.url.pathname === '/' ? 'page' : undefined}>
2020
<a href="/">Home</a>
2121
</li>
22-
<li aria-current={$page.url.pathname === '/about' ? 'page' : undefined}>
22+
<li aria-current={page.url.pathname === '/about' ? 'page' : undefined}>
2323
<a href="/about">About</a>
2424
</li>
25-
<li aria-current={$page.url.pathname.startsWith('/sverdle') ? 'page' : undefined}>
25+
<li aria-current={page.url.pathname.startsWith('/sverdle') ? 'page' : undefined}>
2626
<a href="/sverdle">Sverdle</a>
2727
</li>
2828
</ul>

0 commit comments

Comments
 (0)