Giter Site home page Giter Site logo

harveyrandall / nut Goto Github PK

View Code? Open in Web Editor NEW

This project forked from nut-project/nut

0.0 0.0 0.0 5.6 MB

🌰 A framework born for micro frontends

Home Page: https://nut.js.org

License: MIT License

JavaScript 34.12% AppleScript 0.22% CSS 15.70% HTML 48.41% Vue 1.55%

nut's Introduction

nut logo

NUT Project

npm version dependencies node version build status npm downloads license

Features

  • Flexible layout mechanism
  • File-based router system
  • Customizable layouts and themes
  • Builtin markdown support
  • System events
  • Configuration management
  • Convenient hot reload during development
  • Plugin system

layout / theme HMR

hmr.gif

markdown theme HMR

markdown-theme-hmr.gif

System events

system-events.jpg

Route matching

route-match.jpg

Builtin layouts

default

ocean sakura
ocean sakura

saber

ocean sakura
ocean sakura

now

now

How to write a layout

...

How to write a plugin

A standard plugin looks like

export default {
  name: 'your-superb-plugin',
  // some special plugin need specify type,but you can ignore this in most cases
  type: 'login',
  apply( ctx = {}, options = {} ) {
    const { api, events } = ctx

    api.expose( 'method_name', () => {} )
    api.expose( 'prop', 'value' )

    events.on( 'system:before-startup', async ctx => {
      await api.axios() // do some request
      await events.pluginEmit( 'some-event', data ) // emit plugin event out
    } )
  }
}

You can expose some methods or props to application, or listen for system events, emit out some event in plugin

Using plugin

nut.config.js

module.exports = {
  plugins: {
    superb: {
      package: 'your-superb-plugin',
      enable: true,
    }
  }
}

superb is the name in current application

Use above plugin for example

// plugin exposed
ctx.use( 'superb', 'method_name' )
ctx.use( 'superb', 'prop' )

// plugin events
ctx.events.on( 'plugin:superb:some-event', async data => {} )

Get started

yarn global add @nut-project/cli
nut # develop locally
nut --prod # build for production

nut's People

Contributors

centmaster avatar fengzilong avatar renovate[bot] avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.