Resolve the URL of an asset in your static directory, by prefixing it with config.paths.assets if configured, or otherwise by prefixing it with the base path.
During server rendering, the base path is relative and depends on the page currently being rendered.
Resolve a pathname by prefixing it with the base path, if any, or resolve a route ID by populating dynamic segments with parameters.
In hash routing mode, the returned URL starts with #.
During server rendering, the base path is relative and depends on the page currently being rendered.
import{resolve}from'$app/paths';// using a pathnameconstresolved=resolve(`blog/hello-world`);// using a route ID plus parametersconstresolved=resolve('/blog/[slug]',{slug:'hello-world'});
2.26
}from'$app/paths';
asset
Disponible depuis la version 2.26
Résout l’URL d’un asset se trouvant dans votre dossier static, en le préfixant avec
config.paths.assets si configuré, ou avec le chemin de base
sinon.
Lors du rendu côté serveur, le chemin de base est relatif et dépend de la page en train d’être
rendue.
Résout un chemin en le préfixant avec le chemin de base, s’il existe, ou avec un ID de route en
remplissant les segments dynamiques avec des paramètres.
En mode “routing par hash”, l’URL renvoyée commence par #.
Lors du rendu côté serveur, le chemin de base est relatif et dépend de la page en train d’être
rendue.
Resolve a pathname by prefixing it with the base path, if any, or resolve a route ID by populating dynamic segments with parameters.
In hash routing mode, the returned URL starts with #.
During server rendering, the base path is relative and depends on the page currently being rendered.
import{resolve}from'$app/paths';// using a pathnameconstresolved=resolve(`blog/hello-world`);// using a route ID plus parametersconstresolved=resolve('/blog/[slug]',{slug:'hello-world'});
2.26
}from'$app/paths';// avec un chemin
constresolvedconstresolved:string=resolve(alias)resolve<"blog/hello-world">(pathname:"blog/hello-world"):ResolvedPathnameimportresolve
Resolve a pathname by prefixing it with the base path, if any, or resolve a route ID by populating dynamic segments with parameters.
In hash routing mode, the returned URL starts with #.
During server rendering, the base path is relative and depends on the page currently being rendered.
import{resolve}from'$app/paths';// using a pathnameconstresolved=resolve(`blog/hello-world`);// using a route ID plus parametersconstresolved=resolve('/blog/[slug]',{slug:'hello-world'});
2.26
(`blog/hello-world`);// avec un ID de route et ses paramètres
constresolvedconstresolved:string=resolve(alias)resolve<"/blog/[slug]">(route:"/blog/[slug]",params:Record<string,string>):ResolvedPathnameimportresolve
Resolve a pathname by prefixing it with the base path, if any, or resolve a route ID by populating dynamic segments with parameters.
In hash routing mode, the returned URL starts with #.
During server rendering, the base path is relative and depends on the page currently being rendered.
import{resolve}from'$app/paths';// using a pathnameconstresolved=resolve(`blog/hello-world`);// using a route ID plus parametersconstresolved=resolve('/blog/[slug]',{slug:'hello-world'});