wix-router.WixRouterSitemapRequest

wix-router.WixRouterSitemapRequest

An object representing a request for a sitemap.

Contents

baseUrl Returns the base URL of the request.
pageName Sets or gets the page name.
pages Returns the names of the pages associated with this router.
prefix Returns the router prefix of the request.
user Returns the details of the current site user who is logged in.
baseUrl

baseUrl

Returns the base URL of the request.

Syntax

get baseUrl(): string

Description

Premium sites: Premium site baseUrl

Free sites: Free site baseUrl

Type

String

Examples

Get the base URL of the request

ZXhwb3J0IGZ1bmN0aW9uIG15Um91dGVyX1NpdGVNYXAoc2l0ZW1hcFJlcXVlc3QpIHsKCiAgbGV0IGJhc2VVcmwgPSBzaXRlbWFwUmVxdWVzdC5iYXNlVXJsOwogIC8vIFByZW1pdW0gc2l0ZTogImh0dHBzOi8vZG9tYWluLmNvbSIKICAvLyBGcmVlIHNpdGU6ICJodHRwczovL3VzZXIud2l4LXNpdGVzLmNvbS96b28iCgp9Cg==
export function myRouter_SiteMap(sitemapRequest) {

  let baseUrl = sitemapRequest.baseUrl;
  // Premium site: "https://domain.com"
  // Free site: "https://user.wix-sites.com/zoo"

}
pageName

pageName

Sets or gets the page name.

Syntax

get pageName(): string

Type

String

Examples

Get the request's page name

ZXhwb3J0IGZ1bmN0aW9uIG15Um91dGVyX1NpdGVNYXAoc2l0ZW1hcFJlcXVlc3QpIHsKCiAgbGV0IHBhZ2VOYW1lID0gc2l0ZW1hcFJlcXVlc3QucGFnZU5hbWU7IC8vICJQYWdlIE5hbWUiCgp9Cg==
export function myRouter_SiteMap(sitemapRequest) {

  let pageName = sitemapRequest.pageName; // "Page Name"

}
pages

pages

Returns the names of the pages associated with this router.

Syntax

get pages(): string[]

Description

Pages are added and removed from a router in the Editor.

Type

String[ ]

Examples

Get the names of the pages associated with this router

ZXhwb3J0IGZ1bmN0aW9uIG15Um91dGVyX1NpdGVNYXAoc2l0ZW1hcFJlcXVlc3QpIHsKCiAgbGV0IHBhZ2VzID0gc2l0ZW1hcFJlcXVlc3QucGFnZXM7CiAgLy8gWyJteVJvdXRlci1wYWdlMSIsICJteVJvdXRlci1wYWdlMiJdCgp9Cg==
export function myRouter_SiteMap(sitemapRequest) {

  let pages = sitemapRequest.pages;
  // ["myRouter-page1", "myRouter-page2"]

}
prefix

prefix

Returns the router prefix of the request.

Syntax

get prefix(): string

Description

Premium sites: Premium site prefix

Free sites: Free site prefix

Type

String

Examples

Get the prefix of the request's URL

ZXhwb3J0IGZ1bmN0aW9uIG15Um91dGVyX1NpdGVNYXAoc2l0ZW1hcFJlcXVlc3QpIHsKCiAgbGV0IHByZWZpeCA9IHNpdGVtYXBSZXF1ZXN0LnByZWZpeDsgLy8gImFuaW1hbHMiCgp9Cg==
export function myRouter_SiteMap(sitemapRequest) {

  let prefix = sitemapRequest.prefix; // "animals"

}
user

user

Returns the details of the current site user who is logged in.

Syntax

get user(): WixRouterUser

Description

Returns an object with the id and role of the logged in user who made the request.

Type

WixRouterUser

Examples

Get the user from the request

ZXhwb3J0IGZ1bmN0aW9uIG15Um91dGVyX1NpdGVNYXAoc2l0ZW1hcFJlcXVlc3QpIHsKCiAgbGV0IHVzZXIgPSBzaXRlbWFwUmVxdWVzdC51c2VyOwogIC8qCiAgKiB7CiAgKiAgICJpZCI6ICJmNnEwZmIzMi1iMDZyLTQ2OWYtYWc0ZC05ZGY4OWFma2o1ZDkiLAogICogICAicm9sZSI6ICJBZG1pbiIKICAqIH0KICAqLwoKfQo=
export function myRouter_SiteMap(sitemapRequest) {

  let user = sitemapRequest.user;
  /*
  * {
  *   "id": "f6q0fb32-b06r-469f-ag4d-9df89afkj5d9",
  *   "role": "Admin"
  * }
  */

}