Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@burdy-cms/web-utils

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@burdy-cms/web-utils

Burdy web utilities

  • 1.3.0
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-50%
Maintainers
1
Weekly downloads
 
Created
Source

Burdy Web Utils

Powerful utilities to simplify usage of the Burdy on the web.

  • See Burdy Docs for more details

Instalation

npm i @burdy-cms/web-utils

Functionalities

createRewrites

Creates a RewritesObject instance that can be used to rewrite paths based on the configuration.

Accepts rewriteMap and origin (optional) as object parameters.

import { createRewrites } from '@burdy-cms/web-utils'; 
import axios from 'axios';

const rewrites = createRewrites({
  origin: 'https://cms.website.com/api/content',
  rewriteMap: [
    {
      source: '/:lang(fr|de)/:path*',
      rewrites: {
        page: '/sites/{lang}/{path}',
        header: '/sites/{lang}/fragments/header',
        footer: '/sites/{lang}/fragments/footer'
      }
    },
    {
      source: '/:path*',
      rewrites: {
        page: '/sites/en/{path}',
        header: '/sites/en/fragments/header',
        footer: '/sites/en/fragments/footer'
      }
    }
  ]
});

/**
  Page = https://cms.website.com/api/content/sites/fr/fragments/home
  Header = https://cms.website.com/api/content/sites/fr/fragments/header
  Footer = https://cms.website.com/api/content/sites/fr/fragments/footer
**/
const { page, footer, header } = rewrites.rewrite('/fr/home');

// Fetch data from Burdy
const [pageRequest, footerRequest, headerRequest] = await Promise.all([
  page,
  footer,
  header
]);

richtextToHtml

A function for converting Richtext (DraftJS) Editor content to plain HTML.

This is a forked version of draftjs-to-html draftjs-to-html created by Jyoti Puri.

import { richtextToHtml } from '@burdy-cms/web-utils';

const rawContentState = BURDY_RICHTEXT_RESPONSE;

const markup = richtextToHtml(
  rawContentState
);

subscribeToPreview

Subscribes to Burdy preview (iframe parent). Returns a Subscription that has unsubscribe() method.

import { subscribeToPreview } from '@burdy-cms/web-utils';
const subscription = subscribeToPreview({
  onEdit: post => {
    updateView(post); // Updates view using new content
  }
});

// Unsubscribe at some point if needed
subscription.unsubscribe();

updatePreview

Sends the updates to Burdy preview (iframe parent). This allows Burdy to know when you have switched the page on the frontend.

import { updatePreview } from '@burdy-cms/web-utils';

onRouterChange((pageData) => {
  updatePreview(pageData);
});

FAQs

Package last updated on 26 Jan 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc