Skip to content

Commit

Permalink
feat: migrate to $app/state (#358)
Browse files Browse the repository at this point in the history
* feat: migrate to `$app/state`

* migrate test
  • Loading branch information
manuel3108 authored Jan 10, 2025
1 parent 4c3a504 commit 2c7f7f5
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 8 deletions.
5 changes: 5 additions & 0 deletions .changeset/sixty-shrimps-mate.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'sv': patch
---

feat: migrate to `$app/state`
4 changes: 2 additions & 2 deletions packages/addons/paraglide/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ export default defineAddon({

imports.addDefault(script.ast, '$lib/paraglide/messages.js', '* as m');
imports.addNamed(script.ast, '$app/navigation', { goto: 'goto' });
imports.addNamed(script.ast, '$app/stores', { page: 'page' });
imports.addNamed(script.ast, '$app/state', { page: 'page' });
imports.addNamed(script.ast, '$lib/i18n', { i18n: 'i18n' });
if (typescript) {
imports.addNamed(
Expand All @@ -253,7 +253,7 @@ export default defineAddon({
${ts('', '* @param {import("$lib/paraglide/runtime").AvailableLanguageTag} newLanguage')}
${ts('', '*/')}
function switchToLanguage(newLanguage${ts(': AvailableLanguageTag')}) {
const canonicalPath = i18n.route($page.url.pathname);
const canonicalPath = i18n.route(page.url.pathname);
const localisedPath = i18n.resolveRoute(canonicalPath, newLanguage);
goto(localisedPath);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/core/tests/js/common/jsdoc-comment/input.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
function switchToLanguage(newLanguage) {
const canonicalPath = i18n.route($page.url.pathname);
const canonicalPath = i18n.route(page.url.pathname);
const localisedPath = i18n.resolveRoute(canonicalPath, newLanguage);
goto(localisedPath);
}
2 changes: 1 addition & 1 deletion packages/core/tests/js/common/jsdoc-comment/output.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @param {import("$lib/paraglide/runtime").AvailableLanguageTag} newLanguage
*/
function switchToLanguage(newLanguage) {
const canonicalPath = i18n.route($page.url.pathname);
const canonicalPath = i18n.route(page.url.pathname);
const localisedPath = i18n.resolveRoute(canonicalPath, newLanguage);
goto(localisedPath);
}
8 changes: 4 additions & 4 deletions packages/create/templates/demo/src/routes/Header.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script lang="ts">
import { page } from '$app/stores';
import { page } from '$app/state';
import logo from '$lib/images/svelte-logo.svg';
import github from '$lib/images/github.svg';
</script>
Expand All @@ -16,13 +16,13 @@
<path d="M0,0 L1,2 C1.5,3 1.5,3 2,3 L2,0 Z" />
</svg>
<ul>
<li aria-current={$page.url.pathname === '/' ? 'page' : undefined}>
<li aria-current={page.url.pathname === '/' ? 'page' : undefined}>
<a href="/">Home</a>
</li>
<li aria-current={$page.url.pathname === '/about' ? 'page' : undefined}>
<li aria-current={page.url.pathname === '/about' ? 'page' : undefined}>
<a href="/about">About</a>
</li>
<li aria-current={$page.url.pathname.startsWith('/sverdle') ? 'page' : undefined}>
<li aria-current={page.url.pathname.startsWith('/sverdle') ? 'page' : undefined}>
<a href="/sverdle">Sverdle</a>
</li>
</ul>
Expand Down

0 comments on commit 2c7f7f5

Please sign in to comment.