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

@parameter1/base-cms-marko-web-theme-monorail

v4.80.0

Published

Monorail website theme ===

Downloads

4,796

Readme

Monorail website theme

Features

Content Metering

To install and use this feature, you must:

  1. Import the content metering middleware and add to your content routes:
// site/routes/content.js

+const contentMetering = require('@parameter1/base-cms-marko-web-theme-monorail/middleware/content-metering');
+const config = require('../config/content-meter');

module.exports (app) => {
-  app.get('/*?:id(\\d{8})*', withContent({
+  app.get('/*?:id(\\d{8})*', contentMetering(config), withContent({
    template: content,
    queryFragment,
  }));
  1. Add the contentMeter site config object. See below table for defined options/default values.
# site/config/site.js

+const contentMeter = require('./content-meter');

module.exports = {
  // ...
+  contentMeter,
  // ...
}
// site/config/content-meter.js

module.exports = {
  enabled: process.env.ENABLE_CONTENT_METER || false,
  viewLimit: 5,
}

| Key | Default value | Description | | - | - | - | | enabled | false | If the feature should be enabled. | | viewLimit | 3 | The number of content items a viewer can see in timeframe without logging in. | | timeframe | 30 * 24 * 60 * 60 * 1000 (30 days in ms) | The timeframe to consider | | excludeLabels | [] | Content labels that should be excluded from metering. | | excludeContentTypes | [] | Content types that should be excluded from metering. | | excludePrimarySectionIds | [] | Sections whose primary content should be excluded from metering. | | excludePrimarySectionAlias | [] | Sections whose primary content should be excluded from metering. | | displayOverlay | None | ??? @B77Mills what is this | | promoCode | None | If present, the Omeda promo code to use with content metering events. |

  1. Add the UI display and event tracking component to your core document component (ideally in above-container):
<!-- site/server/components/document.marko -->

$ const { contentMeterState } = out.global;
<if(contentMeterState && !contentMeterState.isLoggedIn)>
  <theme-content-meter-block
    views=contentMeterState.views
    view-limit=contentMeterState.viewLimit
    display-overlay=contentMeterState.displayOverlay
    display-gate=contentMeterState.displayGate
  />
</if>
  1. Adjust the content body template/layout to truncate the body and/or show inline gating options:
<!-- site/components/layouts/content.marko -->

import cm from "@parameter1/base-cms-marko-web-theme-monorail/utils/content-meter-helpers";

$ const { content, blockName } = input;
$ const { contentGatingHandler, contentMeterState, req } = out.global;

$ const showOverlay = cm.shouldOverlay(contentMeterState);
$ const requiresReg = cm.restrictContentByReg(contentMeterState, contentGatingHandler, content);

$ let body = content.body;
<if(cm.shouldTruncate(contentMeterState))>
  $ if (showOverlay) body = getContentPreview({ body: content.body, selector: "p:lt(7)" });
  <marko-web-content-body block-name=blockName obj={ body } />
  <div class="content-page-preview-overlay" />
  <if(!showOverlay)>
    <theme-content-page-gate
      can-access=context.canAccess
      is-logged-in=context.isLoggedIn
      $ // ...
    />
  </if>
</if>
<else-if(!context.canAccess || context.requiresUserInput)>
  $ // ...