✨ Prev & next post filtering, with primary tag support#9141
Merged
kevinansfield merged 13 commits intoTryGhost:masterfrom Oct 13, 2017
Merged
✨ Prev & next post filtering, with primary tag support#9141kevinansfield merged 13 commits intoTryGhost:masterfrom
kevinansfield merged 13 commits intoTryGhost:masterfrom
Conversation
kirrg001
reviewed
Oct 13, 2017
| return apiOptions; | ||
| }; | ||
|
|
||
| fetch = function fetch(options, data) { |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
kirrg001
reviewed
Oct 13, 2017
core/server/helpers/prev_next.js
Outdated
| return fetch(apiOptions, options, data); | ||
| } else { | ||
| // Guard against trying to execute prev/next on previews, pages, or other resources | ||
| if (!isPost(this) || this.status !== 'published') { |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
kirrg001
reviewed
Oct 13, 2017
| return encodeURIComponent("published_at:" + op + "'" + publishedAt + "'"); // jscs:ignore | ||
| } | ||
|
|
||
| request.get(testUtils.API.getApiQuery( |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
kirrg001
approved these changes
Oct 13, 2017
ErisDS
pushed a commit
that referenced
this pull request
Oct 18, 2017
refs #9141 - adds support for `{{#prev_post in="author"}}{{/prev_post}}` & `{{#next_post in="author"}}{{/next_post}}` - "author.slug" is the author equivalent of "primary_tag.slug" - there is only one - added tests to cover both cases in the prev/next helpers
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Replace prev & next logic with the filter param, add new "in" option to support next and preivous post within primary tags.
closes #9140
This PR introduces a breaking change to the JSON API, removing the undocumented ability to fetch next/prev post directly using includes. Instead, anyone who did use this feature would need to use the filter param instead:
Previous post query:
/posts/?filter=slug:-[current-post-slug]+published_at:<='current-post-published-at'&order=published_at desc&limit=1Next post query:
/posts/?filter="slug:-[current-post-slug]+published_at:>='current-post-published-at'&order=published_at asc&limit=1Meanwhile, the widely used
{{#next_post}}{{/next_post}}&{{#prev_post}}{{/prev_post}}helpers will work exactly as they did before, with no changes. The underlying implementation will be more efficient (hopefully improving page load times and reducing load on the database).Finally, we're adding an extra parameter to the
{{#next_post}}{{/next_post}}&{{#prev_post}}{{/prev_post}}to support fetching the next/prev post inside of a primary tag.Things that need more testing: