@windy/location
Modifies URL of the page and document title. Well configured plugins need to use this module to change URL and title of the page ONLY when their parameters are changed.
Example
import { setUrl, setTitle } from '@windy/location';
export const onopen = (params: PluginParams) => {
// We DO NOT NEED to set URL and title here!!!
// Windy's plugin system will do it for us automatically
}
// Here we detect change of params
export const onpPramsChanged = (newParams: PluginParams) => {
setUrl('windy-plugin-name', newParams);
setTitle('New title for ne params');
}
Table of contents
Functions
Functions
description
▸ description(desc
): void
Sets browser's description meta tag for purpose of SEO
Parameters
Name | Type |
---|---|
desc | string |
Returns
void
getURL
▸ getURL(): string
Gets current browser's URL (for example for purpose of sharing)
Returns
string
reset
▸ reset(pluginId?
): void
Reset both, title & URL, to its default values. PluginId makes sure, that only plugin that changed URL can reset it. Well configured plugins should not need to call this method, and Windy's plugin system should do it for you automatically.
Parameters
Name | Type | Description |
---|---|---|
pluginId? | `windy-plugin-${string}` | keyof Plugins | Plugin ident (or null if called not from plugin) |
Returns
void
resetTitle
▸ resetTitle(): void
Resets browser's title to initial value Windy's plugin system should do it automatically
Returns
void
setTitle
▸ setTitle(newTitle
): void
Sets browser's title of a page
Parameters
Name | Type |
---|---|
newTitle | string |
Returns
void
setUrl
▸ setUrl<P
>(pluginId
, pluginParams?
, seoPrefix?
): void
Set URL of page. PluginId makes sure, that only plugin that changed URL can reset it later on.
Type parameters
Name | Type |
---|---|
P | extends keyof WindowPlugins |
Parameters
Name | Type | Description |
---|---|---|
pluginId | `windy-plugin-${string}` | P | id, respective name of the plugin that is updating the URL |
pluginParams? | PluginsOpenParams [P ] | parameters of the plugin. Same parameters as plugin receives in its onopen method |
seoPrefix? | string | SEO prefix of the URL |
Returns
void