npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-magnolia

v1.1.5

Published

Manage React app with Magnolia.

Downloads

8

Readme

This package has been deprecated

Version no longer supported. Upgrade to @magnolia/react-editor

react-magnolia

Manage React app with Magnolia.

Example code using this package can be found here:

https://git.magnolia-cms.com/projects/DEMOS/repos/demo-headless-magnolia-dev/browse

This is an incubator(link to https://wiki.magnolia-cms.com/display/SERVICES/Incubator) module from Magnolia Professional Services. This feature will be productized in Q2 2020.

Requirements

You will need your Magnolia account credentials to download modules.

Getting started

react-magnolia exposes 2 components to be used in your app:

  • Page
  • Area

Each represents corresponding entities in Magnolia. Magnolia sees those components as wrappers allowing green bars to be added.

react-magnolia requires magnolia.config.js file in the root folder of your project. This is the main configuration file for the package.

magnolia.config.js

Configuration file consists of:

  • templates - used to map Magnolia templates to React components
  • getChildren - Defines how Area retrieves children nodes. Used only when the default (props['@nodes'].map(node => props[node])) format of delivery endpoint is modified.

Example of magnolia.config.js

import Home from './src/pages/Home';
import Ad from './src/components/Ad';

const config = {
  templates: {
    // Pages
    'news-demo-templates:pages/Home': Home,

    // Components
    'news-demo-templates:components/Ad': Ad,
  },
  getChildren: (areaProps) => areaProps['@nodes'].map((node) => areaProps[node]),
};

export default config;

Page component

Page component will look for mgnl:template prop and find corresponding React component with help of magnolia.config.js.

If component exists it renders the component passing everything down as props.

In Magnolia author Page component will add Magnolia's comments that are required to render green bars.

It requires it's props to be extended with page object representation returned from REST endpoint.

Example

import React from 'react';
import { Page } from 'react-magnolia';

const isInAuthor = window.self !== window.top && window.singlePageConfig;

class App extends React.Component {
  state = {
    page: isInAuthor ? window.singlePageConfig.content : undefined
  };

  getPage = () => {...};

  render() {
    return <Page {...this.state.page} />;
  }
}

Area component

Area component will loop over all of it's nodes.

If node is a Magnolia component it will look for mgnl:template prop of that node and find corresponding React component with help of magnolia.config.js.

If component exists it renders the component passing node properties down as props.

In Magnolia author Area component will add Magnolia's comments that are required to render green bars.

It requires it's props to be extended with area object representation returned from REST endpoint.

Example with main area

import React from 'react';
import { Area } from 'react-magnolia';

const Home = (props) => {
  return (
    <div className="Home">
      <Area {...props.main} />
    </div>
  );
};

export default Home;