Skip to main content

Module: @headstartwp/core

Namespaces

Enumerations

Classes

Interfaces

DOM Helpers

isAnchorTag

isAnchorTag(node, options?, site?): node is Element

Checks if the provided node is an valid anchor tag

This function expects to be used with DOMNode objects from html-react-parser, which is the underlying parser used by BlocksRenderer.

Usage

import { isAnchorTag } from '@headstartwp/core';
import { LinkBlock } from '@10up/headless-next';

<BlocksRenderer html={html}>
<LinkBlock test={(node) => isAnchorTag(node, { isInternalLink: true})} />
</BlocksRenderer>

Parameters

NameTypeDefault valueDescription
nodeDOMNodeundefinedThe node to test
optionsisAnchorTagOptions{}Supported options
siteundefined | HeadlessConfigundefined

Returns

node is Element

Whether it's an anchor tag according to the options passed

Defined in

packages/core/src/dom/index.ts:77


isBlock

isBlock(node, _options): boolean

Tests a node by tagName and/or className

This function expects to be used with DOMNode objects from html-react-parser, which is the underlying parser used by BlocksRenderer.

Usage

import { isBlock } from '@headstartwp/core';

<BlocksRenderer html={html}>
<MyCustomBlock
test={(node) => isBlock(node, { tagName: 'div', classList: ['block-class-name'] })}
/>
</BlocksRenderer>

Parameters

NameTypeDescription
nodeDOMNodeThe node to test
_optionsisBlockOptions

Returns

boolean

true if the node passes the test

Defined in

packages/core/src/dom/index.ts:278


isBlockByName

isBlockByName(node, name): boolean

Tests a node by block name. This requires the Headless WP Plugin to be installed.

The Headless WP Plugin will append data-wp-block-name and data-wp-block to every block, this function relies on those attributes to determine if the node is a block.

This function expects to be used with DOMNode objects from html-react-parser, which is the underlying parser used by BlocksRenderer.

Usage

import { isBlockByName } from '@headstartwp/core';

<BlocksRenderer html={html}>
<MyCustomBlock
test={(node) => isBlock(node, 'core/paragraph')}
/>
</BlocksRenderer>

Parameters

NameTypeDescription
nodeDOMNodeThe node to test
namestringThe block name

Returns

boolean

true if the node passes the test

Defined in

packages/core/src/dom/index.ts:334


isImageTag

isImageTag(node, options?): string | boolean

Checks if the provided node is an valid image tag

This function expects to be used with DOMNode objects from html-react-parser, which is the underlying parser used by BlocksRenderer.

Usage

import { isImageTag, ImageBlock } from '@headstartwp/core';
import { ImageComponent } from '@10up/headless-next';

<BlocksRenderer html={html}>
<ImageBlock
test={(node) => isImageTag(node, { hasDimensions: true})}
component={ImageComponent}
/>
</BlocksRenderer>

Parameters

NameTypeDescription
nodeDOMNodeThe node to test
optionsisImageTagOptionsSupported options.

Returns

string | boolean

Whether it's an image tag or not according to the options passed

Defined in

packages/core/src/dom/index.ts:141


isTwitterEmbed

isTwitterEmbed(node): boolean

Checks if the node is an twitter embed

This function expects to be used with DOMNode objects from html-react-parser, which is the underlying parser used by BlocksRenderer.

Usage

import { isTwitterEmbed } from '@headstartwp/core';

<BlocksRenderer html={html}>
<MyTwitterBlock
test={isTwitterEmbed}
/>
</BlocksRenderer>

Parameters

NameTypeDescription
nodeDOMNodeThe node to test

Returns

boolean

true if the node is a twitter embed

Defined in

packages/core/src/dom/index.ts:227


isYoutubeEmbed

isYoutubeEmbed(node): boolean

Checks if the node is an youtube embed

This function expects to be used with DOMNode objects from html-react-parser, which is the underlying parser used by BlocksRenderer.

Usage

import { isYoutubeEmbed } from '@headstartwp/core';

<BlocksRenderer html={html}>
<MyYoutubeBlock
test={isYoutubeEmbed}
/>
</BlocksRenderer>

Parameters

NameTypeDescription
nodeDOMNodeThe node to test

Returns

boolean

true if the node is a youtube embed

Defined in

packages/core/src/dom/index.ts:187


wpKsesPost

wpKsesPost(content, allowList?, options?): string

Sanitize HTML content by the wp_kses_post() requirements

Usage

import { wpKsesPost } from '@headstartwp/core';
wpKsesPost(html);

See

https://codex.wordpress.org/Function_Reference/wp_kses_post

Parameters

NameTypeDescription
contentstringThe content to sanitize.
allowList?IWhiteListOptional. The list of allowed HTML tags and attributes. If not set, the default allow list will be used.
options?IWpKsesPostOptionsOptional. IWpKsesPostOptions.

Returns

string

Sanitized string of HTML.

Defined in

packages/core/src/dom/wpKsesPost.ts:30

Data Fetching

apiGet

apiGet(url, args?, burstCache?): Promise<{ headers: { [index: string]: any; } = receivedHeaders; json: any }>

Fetch Wrapper to handle GET requests.

Parameters

NameTypeDefault valueDescription
urlstringundefinedThe URL where to make the request to
argsObject{}The arguments
burstCachebooleanfalseWhether it should burst cache

Returns

Promise<{ headers: { [index: string]: any; } = receivedHeaders; json: any }>

Defined in

packages/core/src/data/api/fetch-utils.ts:46


apiPost

apiPost(url, args?): Promise<any>

Fetch Wrapper to handle POST requests

Parameters

NameTypeDescription
urlstringThe URL where to make the request to
argsObjectThe arguments

Returns

Promise<any>

Defined in

packages/core/src/data/api/fetch-utils.ts:17

Data Handling

getPostAuthor

getPostAuthor(post): AuthorEntity[]

Returns the author object from the post object if it exists

Parameters

NameTypeDescription
postPostEntity | PostSearchEntityThe Post object

Returns

AuthorEntity[]

Defined in

packages/core/src/data/utils/postHandling.ts:11


getPostTerms

getPostTerms(post): Record<string, TermEntity[]>

Returns the terms associated with the post

Parameters

NameTypeDescription
postPostEntity | PostSearchEntityThe Post object

Returns

Record<string, TermEntity[]>

Defined in

packages/core/src/data/utils/postHandling.ts:22

Other

CustomPostType

Ƭ CustomPostType: Object

Type declaration

NameTypeDescription
archive?string-
endpointstring-
matchSinglePath?booleanWhether this custom post type should match the archive path If set to true, then when querying a post type archive page such as /[post-type]/[post-name] the post.link property should match the current path. This will avoid matching nested posts/pages that doesn't exist for instance: /[post-type]/fake-parent-page/[post-name] will not match if this option is set to true even though post-name exists. It is strongly recommended to set this option to true, otherwise hierarchical post types (such as pages) will not work properly. Default true
single?string-
slugstring-

Defined in

packages/core/src/types.ts:1


CustomPostTypes

Ƭ CustomPostTypes: CustomPostType[]

Defined in

packages/core/src/types.ts:21


CustomTaxonomies

Ƭ CustomTaxonomies: CustomTaxonomy[]

Defined in

packages/core/src/types.ts:43


CustomTaxonomy

Ƭ CustomTaxonomy: Object

Type declaration

NameTypeDescription
endpointstring-
matchArchivePath?booleanWhether this custom taxonomy should match the archive path If set to true, then when querying a taxonomy archive page such as /[taxonmy-slug]/[term-slug] the term.link property should match the current path. This will avoid matching nested categories that doesn't exist for instance: /[taxonmy-slug]/fake-parent-term/[term-slug] will not match if this option is set to true even though term-slug exists. Default false
restParam?string-
rewrite?string-
slugstring-

Defined in

packages/core/src/types.ts:25


DOMNode

Ƭ DOMNode: Comment | Element | Node | ProcessingInstruction | Text

Defined in

node_modules/html-react-parser/index.d.ts:21


HTMLParser2Options

Ƭ HTMLParser2Options: ParserOptions & DomHandlerOptions

Defined in

node_modules/html-react-parser/index.d.ts:19


HeadlessConfig

Ƭ HeadlessConfig: Object

Type declaration

NameType
customPostTypes?CustomPostTypes | (defaultPostTypes: CustomPostTypes) => CustomPostTypes
customTaxonomies?CustomTaxonomies | (defaultTaxonomies: CustomTaxonomies) => CustomTaxonomies
debug?{ devMode?: boolean ; redirects?: boolean ; requests?: boolean }
debug.devMode?boolean
debug.redirects?boolean
debug.requests?boolean
host?string
hostUrl?string
integrations?Integrations
locale?string
redirectStrategy?RedirectStrategy
sites?HeadlessConfig[]
sourceUrl?string
useWordPressPlugin?boolean

Defined in

packages/core/src/types.ts:58


Integrations

Ƭ Integrations: Object

Type declaration

NameType
polylang?PolylangIntegration
yoastSEO?YoastSEOIntegration

Defined in

packages/core/src/types.ts:53


Matcher

Ƭ Matcher: Object

Type declaration

NameType
namestring
patternstring
prioritynumber

Defined in

packages/core/src/data/utils/matchers.ts:1


NormalizedDataForCache

Ƭ NormalizedDataForCache<T, P>: Object

Type parameters

Name
T
P

Type declaration

NameType
additionalCacheObjects?NormalizedDataForCache<T, P>[]
dataFetchResponse<T>
key{ args: Partial<P> ; url: string }
key.argsPartial<P>
key.urlstring

Defined in

packages/core/src/data/strategies/AbstractFetchStrategy.ts:83


PostOrPostsFetchStrategyResult

Ƭ PostOrPostsFetchStrategyResult<T>: Object

Type parameters

Name
T

Type declaration

NameType
dataT | T[]
isArchiveboolean
isSingleboolean

Defined in

packages/core/src/data/strategies/PostOrPostsFetchStrategy.ts:42


QueriedObject

Ƭ QueriedObject: Object

The QueriedObject represents the object that the current requests is subjected to.

Querying by taxonomy and/or author will set the queried object.

Type declaration

NameTypeDescription
author?AuthorEntityIf the request is an author query, this will be populated with the author object
search?SearchEntityIf the request is a search query, this will be populated with the search entity object
term?TermEntityIf the request is a term query, this will be populated with the term object

Defined in

packages/core/src/data/types/entities.ts:765


Redirect

Ƭ Redirect: Object

Type declaration

NameType
IDnumber
enable_regexboolean
post_statusstring
redirect_fromstring
redirect_tostring
status_codenumber

Defined in

packages/core/src/data/types/entities.ts:705


RedirectData

Ƭ RedirectData: Object

Type declaration

NameTypeDescription
locationstring | undefined | nullThe redirect new location will be null if no redirect is found
statusnumberThe status number of the redirect Will be 0 if the redirect is not found

Defined in

packages/core/src/utils/fetchRedirect.ts:5


RedirectStrategy

Ƭ RedirectStrategy: "404" | "none" | "always"

Defined in

packages/core/src/types.ts:23


isAnchorTagOptions

Ƭ isAnchorTagOptions: Object

Type declaration

NameTypeDescription
isInternalLink?booleanIf true, will check if the anchor tag contains a valid internal link. if target="_blank" then this option is not taken into account

Defined in

packages/core/src/dom/index.ts:5


isBlockOptions

Ƭ isBlockOptions: Object

Type declaration

NameTypeDescription
className?string | string[]A single or array of classNames to check for If an array of class names is passed, the block will be considered valid if all of the class names are found
tagName?stringThe tagName to check for

Defined in

packages/core/src/dom/index.ts:238


isImageTagOptions

Ƭ isImageTagOptions: Object

Type declaration

NameTypeDescription
hasDimensions?booleanIf true, will check if the image tag contains width and height attributes

Defined in

packages/core/src/dom/index.ts:107


removeSourceUrlType

Ƭ removeSourceUrlType: Object

Type declaration

NameTypeDescription
backendUrlstringThe backend url.
linkstringThe link url, possibly with the source url.
publicUrl?stringThe public url. Defaults to '/'.

Defined in

packages/core/src/utils/removeSourceUrl.ts:3


authorArchivesMatchers

Const authorArchivesMatchers: Matcher[]

Defined in

packages/core/src/data/utils/matchers.ts:43


endpoints

Const endpoints: Object

Type declaration

NameType
appSettingsstring
categorystring
pagesstring
postsstring
searchstring
tagsstring
tokenVerifystring
yoaststring

Defined in

packages/core/src/utils/endpoints.ts:1


ksesAllowedList

Const ksesAllowedList: IWhiteList

Default Allowed HTML Attributes

See

https://codex.wordpress.org/Function_Reference/wp_kses_post

Defined in

packages/core/src/dom/wpKsesPost.ts:266


postMatchers

Const postMatchers: Matcher[]

Defined in

packages/core/src/data/utils/matchers.ts:7


postsMatchers

Const postsMatchers: Matcher[]

Defined in

packages/core/src/data/utils/matchers.ts:20


searchMatchers

Const searchMatchers: Matcher[]

Defined in

packages/core/src/data/utils/matchers.ts:56


youtubeEmbedRegex

Const youtubeEmbedRegex: RegExp

Defined in

packages/core/src/dom/index.ts:160


HTMLReactParser

HTMLReactParser(html, options?): ReturnType<typeof domToReact>

Converts HTML string to JSX element(s).

Parameters

NameTypeDescription
htmlstringHTML string.
options?HTMLReactParserOptionsParser options.

Returns

ReturnType<typeof domToReact>

  • JSX element(s), empty array, or string.

Defined in

node_modules/html-react-parser/index.d.ts:51


addQueryArgs

addQueryArgs(url, args): string

Parameters

NameType
urlstring
argsRecord<string, any>

Returns

string

Defined in

packages/core/src/utils/url.ts:167


asyncForEach

asyncForEach(array, callback): Promise<void>

Parameters

NameType
arrayany[]
callback(el: any, index: number, array: any[]) => void

Returns

Promise<void>

Defined in

packages/core/src/utils/asyncForEach.ts:1


attributesToProps

attributesToProps(attributes, nodeName?): Props

Converts HTML/SVG DOM attributes to React props.

Parameters

NameTypeDescription
attributesAttributesHTML/SVG DOM attributes.
nodeName?stringDOM node name.

Returns

Props

  • React props.

Defined in

node_modules/html-react-parser/lib/attributes-to-props.d.ts:17


buildQueryString

buildQueryString(data): string

Generates URL-encoded query string using input query data.

It is intended to behave equivalent as PHP's http_build_query, configured with encoding type PHP_QUERY_RFC3986 (spaces as %20).

Example

const queryString = buildQueryString( {
simple: 'is ok',
arrays: [ 'are', 'fine', 'too' ],
objects: {
evenNested: {
ok: 'yes',
},
},
} );
// "simple=is%20ok&arrays%5B0%5D=are&arrays%5B1%5D=fine&arrays%5B2%5D=too&objects%5BevenNested%5D%5Bok%5D=yes"

Parameters

NameTypeDescription
dataRecord<string, any>Data to encode.

Returns

string

Query string.

Defined in

packages/core/src/utils/url.ts:129


decodeHtmlSpeciaChars

decodeHtmlSpeciaChars(text): string

Decodes HTML special chars entities

Parameters

NameTypeDescription
textstringThe text we want to decode

Returns

string

text with decoded html entities

Defined in

packages/core/src/utils/decodeHtmlSpeciaChars.ts:8


domToReact

domToReact(nodes, options?): string | JSX.Element | JSX.Element[]

Converts DOM nodes to JSX element(s).

Parameters

NameTypeDescription
nodesDOMNode[]DOM nodes.
options?HTMLReactParserOptionsParser options.

Returns

string | JSX.Element | JSX.Element[]

  • JSX element(s).

Defined in

node_modules/html-react-parser/lib/dom-to-react.d.ts:15


fetchRedirect

fetchRedirect(pathname, sourceUrl): Promise<RedirectData>

Fetches a redirect from the WordPress origin by making a HEAD request and checking the response

Parameters

NameTypeDescription
pathnamestringThe path to the page to fetch the redirect for
sourceUrlstringThe source url

Returns

Promise<RedirectData>

The redirect data

Defined in

packages/core/src/utils/fetchRedirect.ts:51


getAuthHeader

getAuthHeader(): null

Returns

null

Defined in

packages/core/src/data/api/fetch-utils.ts:3


getCustomPostType

getCustomPostType(slug, sourceUrl?): undefined | CustomPostType

Returns a single post type by slug if defined

Parameters

NameTypeDescription
slugstringpost type slug
sourceUrl?string

Returns

undefined | CustomPostType

Defined in

packages/core/src/utils/config.ts:248


getCustomPostTypes

getCustomPostTypes(sourceUrl?): CustomPostTypes

Returns the available post types

Parameters

NameType
sourceUrl?string

Returns

CustomPostTypes

Defined in

packages/core/src/utils/config.ts:225


getCustomPostTypesSlugs

getCustomPostTypesSlugs(sourceUrl?): string[]

Returns the available post type slugs

Parameters

NameType
sourceUrl?string

Returns

string[]

Defined in

packages/core/src/utils/config.ts:236


getCustomTaxonomies

getCustomTaxonomies(sourceUrl?): CustomTaxonomies

Returns the available taxonomies

Parameters

NameType
sourceUrl?string

Returns

CustomTaxonomies

Defined in

packages/core/src/utils/config.ts:185


getCustomTaxonomy

getCustomTaxonomy(slug, sourceUrl?): undefined | CustomTaxonomy

Returns a single post type by slug if defined

Parameters

NameTypeDescription
slugstringpost type slug
sourceUrl?string

Returns

undefined | CustomTaxonomy

Defined in

packages/core/src/utils/config.ts:214


getCustomTaxonomySlugs

getCustomTaxonomySlugs(sourceUrl?): string[]

Returns the available taxonomy slugs

Parameters

NameType
sourceUrl?string

Returns

string[]

Defined in

packages/core/src/utils/config.ts:197


getHeadlessConfig

getHeadlessConfig(): Object

Returns the contents of headless.config.js

This function requires framework integration in order to work. The contents of headless.config.js needs to be injected at build time into a global variable.

Make sure you are using one of the framework's integration (such as next) before using this function.

Returns

Object

The contents of headless.config.js

NameType
customPostTypesCustomPostTypes
customTaxonomiesCustomTaxonomies
debugundefined | { devMode?: boolean ; redirects?: boolean ; requests?: boolean }
hostUrlstring
integrationsundefined | Integrations
redirectStrategyRedirectStrategy
sitesHeadlessConfig[]
sourceUrlundefined | string
useWordPressPluginboolean

Defined in

packages/core/src/utils/config.ts:22


getHeadstartWPConfig

getHeadstartWPConfig(): Object

Returns the contents of headless.config.js

This function requires framework integration in order to work. The contents of headless.config.js needs to be injected at build time into a global variable.

Make sure you are using one of the framework's integration (such as next) before using this function.

Returns

Object

The contents of headless.config.js

NameType
customPostTypesCustomPostTypes
customTaxonomiesCustomTaxonomies
debugundefined | { devMode?: boolean ; redirects?: boolean ; requests?: boolean }
hostUrlstring
integrationsundefined | Integrations
redirectStrategyRedirectStrategy
sitesHeadlessConfig[]
sourceUrlundefined | string
useWordPressPluginboolean

Defined in

packages/core/src/utils/config.ts:22


getHostUrl

getHostUrl(): string

Returns the WP URL based on the headless config

Returns

string

Defined in

packages/core/src/utils/config.ts:265


getQueryArgs

getQueryArgs(url): Record<string, any>

Returns an object of query arguments of the given URL. If the given URL is invalid or has no querystring, an empty object is returned.

Example

const foo = getQueryArgs( 'https://wordpress.org?foo=bar&bar=baz' );
// { "foo": "bar", "bar": "baz" }

Parameters

NameTypeDescription
urlstringURL.

Returns

Record<string, any>

Query args object.

Defined in

packages/core/src/utils/url.ts:78


getQueryString

getQueryString(url): any

Parameters

NameType
urlstring

Returns

any

Defined in

packages/core/src/utils/url.ts:49


getSite

getSite(site?): HeadlessConfig

Get a config for a specific site

Parameters

NameType
site?HeadlessConfig

Returns

HeadlessConfig

Defined in

packages/core/src/utils/config.ts:111


getSiteByHost

getSiteByHost(hostOrUrl, locale?): null | HeadlessConfig

Finds a site by host and optionally locale

Parameters

NameTypeDescription
hostOrUrlstringThe hostname
locale?string

Returns

null | HeadlessConfig

Defined in

packages/core/src/utils/config.ts:135


getSiteBySourceUrl

getSiteBySourceUrl(sourceUrl): HeadlessConfig

Get a site by source url

Parameters

NameType
sourceUrlstring

Returns

HeadlessConfig

HeadlessConfig

Defined in

packages/core/src/utils/config.ts:173


getWPUrl

getWPUrl(): string

Returns the WP URL based on the headless config

Returns

string

Defined in

packages/core/src/utils/config.ts:257


htmlToDOM

htmlToDOM(html, options?): (Comment | Element | ProcessingInstruction | Text)[]

Parses HTML string to DOM nodes in Node.js.

This is the same method as require('htmlparser2').parseDOM https://github.com/fb55/htmlparser2/blob/v6.0.0/src/index.ts#L29-L41

Parameters

NameTypeDescription
htmlstringHTML markup.
options?DomHandlerOptionsParser options (https://github.com/fb55/domhandler/tree/v5.0.3#readme).

Returns

(Comment | Element | ProcessingInstruction | Text)[]

  • DOM nodes.

Defined in

node_modules/html-dom-parser/lib/server/html-to-dom.d.ts:21


isElement

isElement(node): node is Element

Checks if the node is an Element.

We rely on this function to avoid issues with instanceof.

See

https://github.com/10up/headstartwp/issues/504

Parameters

NameTypeDescription
nodeDOMNodeThe dom node

Returns

node is Element

Whether the node is of type element or not

Defined in

packages/core/src/dom/index.ts:25


isExternalUrl

isExternalUrl(link): boolean

Checks if the provided link is an external Url.

Inspired on the Frontity implementation

See

https://github.com/frontity/frontity/blob/dev/packages/components/link/utils.ts

Parameters

NameTypeDescription
linkstringThe link Url.

Returns

boolean

True if the link is an external Url.

Defined in

packages/core/src/utils/isExternalUrl.ts:12


isInternalLink(url, site?): boolean

Checks if the url is for an internal link

Parameters

NameTypeDescription
urlstringThe url to check
site?HeadlessConfig(optional) the site config

Returns

boolean

Defined in

packages/core/src/utils/isInternalLink.ts:14


log

log(type, ...args): void

Parameters

NameType
typeLOGTYPE
...argsany[]

Returns

void

Defined in

packages/core/src/utils/log.ts:9


removeFieldsFromPostRelatedData

removeFieldsFromPostRelatedData(fieldsToRemove, post): PostEntity | { _embedded: { author: AuthorEntity[] ; wp:featuredmedia: any ; wp:term: TermEntity[][] } ; author?: AuthorEntity[] ; categories?: number[] ; comment_status?: "open" | "closed" ; content: Rendered ; date: string ; date_gmt: string ; excerpt: Rendered ; featured_media: number ; format: "link" | "status" | "standard" | "aside" | "chat" | "gallery" | "image" | "quote" | "video" | "audio" ; guid: Rendered ; id: number ; link: string ; meta: Record<string, unknown> ; modified: string ; modified_gmt: string ; ping_status: "open" | "closed" ; slug: string ; status: "publish" | "future" | "draft" | "pending" | "private" ; sticky: boolean ; tags?: number[] ; template: string ; terms?: Record<string, TermEntity[]> ; title: Rendered ; type: string ; yoast_head?: null | string ; yoast_head_json?: null | Record<string, any> }

Parameters

NameType
fieldsToRemove(string | number)[]
postPostEntity

Returns

PostEntity | { _embedded: { author: AuthorEntity[] ; wp:featuredmedia: any ; wp:term: TermEntity[][] } ; author?: AuthorEntity[] ; categories?: number[] ; comment_status?: "open" | "closed" ; content: Rendered ; date: string ; date_gmt: string ; excerpt: Rendered ; featured_media: number ; format: "link" | "status" | "standard" | "aside" | "chat" | "gallery" | "image" | "quote" | "video" | "audio" ; guid: Rendered ; id: number ; link: string ; meta: Record<string, unknown> ; modified: string ; modified_gmt: string ; ping_status: "open" | "closed" ; slug: string ; status: "publish" | "future" | "draft" | "pending" | "private" ; sticky: boolean ; tags?: number[] ; template: string ; terms?: Record<string, TermEntity[]> ; title: Rendered ; type: string ; yoast_head?: null | string ; yoast_head_json?: null | Record<string, any> }

Defined in

packages/core/src/data/utils/postHandling.ts:51


removeSourceUrl

removeSourceUrl(«destructured»): string

Make the link relative if it belongs to the backend, to force client-side navigation.

Inspired on the Frontity implementation

See

https://github.com/frontity/frontity/blob/dev/packages/components/link/utils.ts

Parameters

NameType
«destructured»removeSourceUrlType

Returns

string

The URL without the Source URL.

Defined in

packages/core/src/utils/removeSourceUrl.ts:30


setHeadlessConfig

setHeadlessConfig(config): void

Parameters

NameType
configHeadlessConfig

Returns

void

Defined in

packages/core/src/utils/config.ts:6


setHeadstartWPConfig

setHeadstartWPConfig(config): void

Parameters

NameType
configHeadlessConfig

Returns

void

Defined in

packages/core/src/utils/config.ts:6


stripTags

stripTags(html): any

Utility functions to strip any tags

Parameters

NameTypeDescription
htmlanyThe html string

Returns

any

Defined in

packages/core/src/dom/stripTags.ts:8


warn

warn(message): void

Logs a warning in the console in dev mode

Example

warn("You should do/change something.")

Parameters

NameTypeDescription
messagestringThe message that describes the warning.

Returns

void

Defined in

packages/core/src/utils/errors.ts:45

Utility Functions

parsePath

parsePath(matchers, path): Record<string, string>

Parses a path and extracts the parameters from it

Parameters

NameTypeDescription
matchersMatcher[]An array of Matchers
pathstringThe path

Returns

Record<string, string>

the extracted parameters

Defined in

packages/core/src/data/utils/parsePath.ts:46