From 9037c19e50c4da026f4b797413a682e1411b032f Mon Sep 17 00:00:00 2001 From: Fabien O'Carroll Date: Mon, 12 Aug 2019 18:18:32 +0800 Subject: [PATCH] Ensured `page` filter works in routes.yaml refs #10922 The frontend UrlGenerator parses the filters itself rather than passing to the api, so we need to replicate the conversion from page -> type --- core/frontend/services/url/UrlGenerator.js | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/core/frontend/services/url/UrlGenerator.js b/core/frontend/services/url/UrlGenerator.js index 46b53a8df7..fbc9205e7a 100644 --- a/core/frontend/services/url/UrlGenerator.js +++ b/core/frontend/services/url/UrlGenerator.js @@ -23,6 +23,8 @@ const _ = require('lodash'), replacement: 'primary_author.slug' }]; +const mapNQLKeyValues = require('nql-map-key-values'); + /** * The UrlGenerator class is responsible to generate urls based on a router's conditions. * It is the component which sits between routers and resources and connects them together. @@ -44,7 +46,22 @@ class UrlGenerator { // CASE: routers can define custom filters, but not required. if (this.router.getFilter()) { this.filter = this.router.getFilter(); - this.nql = nql(this.filter, {expansions: EXPANSIONS}); + this.nql = nql(this.filter, { + expansions: EXPANSIONS, + transformer: mapNQLKeyValues({ + key: { + from: 'page', + to: 'type' + }, + values: [{ + from: false, + to: 'post' + }, { + from: true, + to: 'page' + }] + }) + }); debug('filter', this.filter); }