1.24.2 • Published 12 months ago
@mindful-web/marko-web-theme-monorail v1.24.2
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('@mindful-web/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,
}));- Add the
contentMetersite 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. |
- Add the UI display and event tracking component to your core
documentcomponent (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>- Adjust the content body template/layout to truncate the body and/or show inline gating options:
<!-- site/components/layouts/content.marko -->
import cm from "@mindful-web/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)>
$ // ...1.24.2
12 months ago
1.23.0
1 year ago
1.20.5
1 year ago
1.20.3
1 year ago
1.20.2
1 year ago
1.20.1
1 year ago
1.20.0
1 year ago
1.19.6
1 year ago
1.19.5
1 year ago
1.19.4
1 year ago
1.19.3
1 year ago
1.19.2
1 year ago
1.19.1
1 year ago
1.19.0
1 year ago
1.18.4
1 year ago
1.18.2
1 year ago
1.18.1
1 year ago
1.17.11
1 year ago
1.17.10
1 year ago
1.17.9
1 year ago
1.17.8
1 year ago
1.17.7
1 year ago
1.17.6
1 year ago
1.17.5
1 year ago
1.17.4
1 year ago
1.17.3
1 year ago
1.17.2
1 year ago
1.17.0
1 year ago
1.16.1
1 year ago
1.16.0
1 year ago
1.15.0
1 year ago
1.14.0
1 year ago
1.13.1
1 year ago
1.13.0
1 year ago
1.12.2
1 year ago
1.12.1
1 year ago
1.12.0
1 year ago
1.11.9
1 year ago
1.11.7
1 year ago
1.11.6
1 year ago
1.11.5
1 year ago
1.11.0
1 year ago
1.10.0
1 year ago
1.9.5
1 year ago
1.9.4
1 year ago
1.9.3
1 year ago
1.9.2
1 year ago
1.9.1
1 year ago
1.9.0
1 year ago
1.8.1
1 year ago
1.8.0
1 year ago
1.7.0
1 year ago
1.6.0
1 year ago
1.3.2
1 year ago
1.1.5
1 year ago
1.1.4
1 year ago
1.1.3
1 year ago
1.1.2
1 year ago
1.1.0
1 year ago
1.0.1
2 years ago
1.0.0
2 years ago