Updated frontend helpers to handle tiers visibility

refs https://github.com/TryGhost/Team/issues/1071

- visibility handling for posts/pages with restricted tiers access has changed, this change updates frontend helpers
This commit is contained in:
Rishabh 2022-01-26 16:55:04 +05:30 committed by Rishabh Garg
parent b259bb2431
commit 15d692dc01
3 changed files with 4 additions and 8 deletions

View File

@ -27,7 +27,7 @@ const buildApiOptions = function buildApiOptions(options, post) {
/**
* @deprecated: single authors was superceded by multiple authors in Ghost 1.22.0
*/
include: 'author,authors,tags',
include: 'author,authors,tags,tiers',
order: 'published_at ' + order,
limit: 1,
// This line deliberately uses double quotes because GQL cannot handle either double quotes

View File

@ -6,7 +6,6 @@
const {labs} = require('../services/proxy');
const {SafeString} = require('../services/rendering');
const nql = require('@nexes/nql');
const isString = require('lodash/isString');
function products(options = {}) {
@ -29,11 +28,8 @@ function products(options = {}) {
accessProductsList = productsList;
}
if (this.visibility === 'filter') {
const nqlFilter = nql(this.visibility_filter);
accessProductsList = productsList.filter((product) => {
return nqlFilter.queryJSON({product: product.slug});
});
if (this.visibility === 'tiers') {
accessProductsList = this.tiers;
}
if (accessProductsList.length > 0) {

View File

@ -7,7 +7,7 @@
{{#has visibility="members"}}
<h2>This post is for subscribers only</h2>
{{/has}}
{{#has visibility="filter"}}
{{#has visibility="tiers"}}
<h2>This post is for subscribers on the {{products}} only </h2>
{{/has}}
{{#if @member}}