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

@amagaki/amagaki-plugin-page-builder

v3.12.0

Published

[![NPM Version][npm-image]][npm-url] [![GitHub Actions][github-image]][github-url] [![TypeScript Style Guide][gts-image]][gts-url]

Downloads

1,662

Readme

amagaki-plugin-page-builder

NPM Version GitHub Actions TypeScript Style Guide

An opinionated page builder for Amagaki: the base template for constructing pages from content and templates.

Usage

  1. Install the plugin.
npm install --save @amagaki/amagaki-plugin-page-builder
  1. Add to amagaki.ts.
import {PageBuilder} from '@amagaki/amagaki-plugin-page-builder';
import {Pod} from '@amagaki/amagaki';

export default (pod: Pod) => {
  PageBuilder.register(pod);
};
  1. Ensure your site uses the following structure:
# Page module templates.
/views/partials/{partial}.njk

# Page module JavaScript.
/dist/js/{partial}.js

# Page module CSS.
/dist/css/{partial}.css

Background

Amagaki provides structure around how your site's content and templates are organized, but it doesn't provide any built-in structure for generating the markup used in HTML pages, or loading page modules. That's where this plugin comes in.

To use this plugin, get started by placing content within the /content directory. A content document should then define a field partials that lists the partial content used by a page's modules.

# /content/index.yaml

partials:
- partial: hero
  headline: Hello World!
- partial: banner
  body: Lorem ipsum dolor sit amet.

In the above content document, we define the index.yaml page to contain two partials: hero and banner. These partials correspond to files in the /views directory, such as:

# /views/partials/hero.njk

<div class="hero">
  {{partial.headline}}
</div>

The page builder plugin will render the page by looping over the items in the partials field and rendering the individual partial templates.

Furthermore, the page builder manages resource loading. By default, it will look for CSS and JS files corresponding to each partial template, and load them as needed on a per-module basis.

By default, the page builder looks for CSS and JS in the following directories:

/dist/css/{partial}.css
/dist/js/{partial}.js

In addition to rendering page modules using the partial loop, the page builder also manages the <head> tag and typical elements, such as elements used for SEO and sharing metadata, as well as canonical and alternate links. These elements are either configurable or managed automatically.

Options

Refer to the PageBuilderOptions interface for a full list of options.

Grid inspector settings

The page builder includes a configurable layout grid inspector to simplify comparing a web page to a Figma design. The grid inspector can be configured across various breakpoints, with parameters that align to Figma's options:

  • The Count determines how many columns there are in the grid.
  • The Gutter defines the distance between each column.
  • The Margin is the distance from the edge that the column.

Example

See the example in the /example directory for a full example, or refer to the configuration below for example usage within amagaki.ts.

PageBuilder.register(pod, {
  head: {
    siteName: 'Site Name',
    twitterSite: '@username',
    icon: pod.staticFile('/src/images/favicon.ico'),
    scripts: [pod.staticFile('/dist/js/main.min.js')],
    stylesheets: [
      'https://fonts.googleapis.com/css?family=Material+Icons|Roboto:400,500,700&display=swap',
      pod.staticFile('/dist/css/main.css'),
    ],
    extra: ['/views/head.njk'],
  },
  body: {
    extra: ['/views/body.njk'],
  },
});