How to use the frontity.URL function in frontity

To help you get started, weโ€™ve selected a few frontity examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github frontity / frontity / packages / head-tags / src / utils / index.ts View on Github external
const getWpUrl = (api: string, isWpCom: boolean): URL => {
  const apiUrl = new URL(api);
  if (isWpCom) {
    const { pathname } = apiUrl;
    return new URL(pathname.replace(/^\/wp\/v2\/sites\//, "https://"));
  }
  // Get API subdirectory.
  const apiSubdir = apiUrl.pathname.replace(/\/wp-json\/?$/, "/");
  return new URL(apiSubdir, apiUrl);
};
github frontity / frontity / packages / head-tags / src / utils / index.ts View on Github external
const getWpUrl = (api: string, isWpCom: boolean): URL => {
  const apiUrl = new URL(api);
  if (isWpCom) {
    const { pathname } = apiUrl;
    return new URL(pathname.replace(/^\/wp\/v2\/sites\//, "https://"));
  }
  // Get API subdirectory.
  const apiSubdir = apiUrl.pathname.replace(/\/wp-json\/?$/, "/");
  return new URL(apiSubdir, apiUrl);
};
github frontity / frontity / packages / head-tags / src / utils / index.ts View on Github external
const getWpUrl = (api: string, isWpCom: boolean): URL => {
  const apiUrl = new URL(api);
  if (isWpCom) {
    const { pathname } = apiUrl;
    return new URL(pathname.replace(/^\/wp\/v2\/sites\//, "https://"));
  }
  // Get API subdirectory.
  const apiSubdir = apiUrl.pathname.replace(/\/wp-json\/?$/, "/");
  return new URL(apiSubdir, apiUrl);
};
github frontity / frontity / packages / head-tags / src / utils / index.ts View on Github external
const getNewLink = (value: string, base: string, newBase: string) => {
  const { pathname, search, hash } = new URL(value);
  const finalPathname = pathname.replace(
    new RegExp(`^${new URL(base).pathname}`),
    "/"
  );
  return `${newBase.replace(/\/?$/, "")}${finalPathname}${search}${hash}`;
};
github frontity / frontity / packages / head-tags / src / utils / index.ts View on Github external
const getNewLink = (value: string, base: string, newBase: string) => {
  const { pathname, search, hash } = new URL(value);
  const finalPathname = pathname.replace(
    new RegExp(`^${new URL(base).pathname}`),
    "/"
  );
  return `${newBase.replace(/\/?$/, "")}${finalPathname}${search}${hash}`;
};
github frontity / frontity / e2e / packages / emotion / src / index.tsx View on Github external
const Root = connect(({ state }) => {
  const { pathname } = new URL(state.router.link, "http://localhost:3001");
  if (pathname === "/background-blue") return ;
  if (pathname === "/color-red") return ;
  if (pathname === "/styled-css") return ;
});