Skip to content

ampify-io/plugins

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ampify Plugins

A monorepo for Ampify's open source plugins and utilities.

Plugins

Utils

A plugin

Plugin is just an exported function, you have complete control on the document as in the browser.

Example:

export default () => {
  const el = document.querySelector('.menu');
};

You can also use module.exports:

module.exports = () => {
  const el = document.querySelector('.menu');
};

Plugin return object

Plugin can return an object with some settings:

  • classes - Array of classes to not shorten.

Example:

export default () => {
  //...plugin logic here

  return {
    classes: ['is-open', 'menu', 'header']
  };
};

Build

Use yarn build command to create a bundled plugin in the dist folder.

Manually create plugin

Plugin is just a function exposed on the window object, you can do it manually, however it is easier to use webpack configuration and build it to use 3rd party dependencies.

Example:

window.myCustomPlugin = () => {
  //...plugin logic goes here.
};