mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-27 18:52:14 +03:00
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
This commit is contained in:
parent
8c5f1d0ef0
commit
9037c19e50
@ -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);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user