Skip to content

@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

typescript
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 ​

NameType
descstring

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 ​

NameTypeDescription
pluginId?`windy-plugin-${string}` | keyof PluginsPlugin 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 ​

NameType
newTitlestring

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 ​

NameType
Pextends keyof WindowPlugins

Parameters ​

NameTypeDescription
pluginId`windy-plugin-${string}` | Pid, 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?stringSEO prefix of the URL

Returns ​

void