Skip to content

Add variables that contain URls #7398

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
KevsRepos opened this issue Oct 26, 2022 · 4 comments
Open

Add variables that contain URls #7398

KevsRepos opened this issue Oct 26, 2022 · 4 comments
Labels
feature / enhancement New feature or request
Milestone

Comments

@KevsRepos
Copy link

KevsRepos commented Oct 26, 2022

Describe the problem

When building your app, at some point you might wanna move a page to a different URL. But at that point you could already have dozens of links pointing to that page with the given static URL. Example: We have the Login Page in /Account/Login and we have set dozens of links all over the Webapp like that: <a href="/Account/Login">Login</a>
Now, we want to move the Login page to this URL: /Account/User/Login. Now its a mess, all the links are broken and we have to fix em manually.

Describe the proposed solution

Add the feature to add a const that we can import from /Account/Login/+page.ts that contains the URL of that page. Yes, by moving the directory (and therefore the URL), the import wouldnt work anymore aswell. But vscode and other IDEs are fixing this issue already by automatically correcting the imports.

export const loginRoute = CURRENT.ROUTE;

Where CURRENT.ROUTE is determined during compile time, so its just like export const loginRoute = "/Account/Login" after the build completed.

Alternatives considered

The alternative is that we can manually make a mapping that we manually have to update...

Importance

would make my life easier

Additional Information

No response

@dummdidumm
Copy link
Member

Sounds related to #7110 (comment) .

(in your specific case I think a simple string search + replace should do it?)

@Conduitry
Copy link
Member

Also sounds related to #6167.

I don't know what this current route string would be for routes with params in them.

@david-plugge
Copy link
Contributor

@KevsRepos I wonder if this could work for you?

// /Account/Login/+page.ts
import { page } from '$app/stores';

const loginRoute = $page.url.pathname;

@KevsRepos
Copy link
Author

@david-plugge We dont need the current URI, we need every URI that exists in the whole app...

@benmccann benmccann added this to the whenever milestone Nov 9, 2022
@eltigerchino eltigerchino added the feature / enhancement New feature or request label Nov 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature / enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

6 participants