Skip to content

Commit

Permalink
Merge pull request #4285 from apostrophecms/pro-4745
Browse files Browse the repository at this point in the history
PRO-4745: Make it possible to fetch data rather than a rendered page for any page URL in Apostrophe core
  • Loading branch information
boutell authored Sep 8, 2023
2 parents ce7cc93 + 645332b commit 52e4517
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@
* Add `@apostrophecms/rich-text-widget:lint-fix-figure` task to wrap text nodes in paragraph tags when next to figure tag. Figure tags are not valid children of paragraph tags.
* Add `@apostrophecms/rich-text-widget:remove-empty-paragraph` task to remove empty paragraphs from all existing rich-texts.
* Add ability for custom tiptap extensions to access the options passed to rich text widgets at the area level
* The actual invocation of `renderPageForModule` by the `sendPage` method of all modules has been
factored out to `renderPage`, which is no longer deprecated. This provides a convenient override point
for those who wish to substitute something else for Nunjucks or just wrap the HTML in a larger data
structure. For consistent results, one might also choose to override the `renderWidget` and `render`
methods of the `@apostrophecms/area` module, which are used to render content while editing.
Thanks to Michelin for their support of this work.

## 3.55.0

Expand Down
13 changes: 5 additions & 8 deletions modules/@apostrophecms/module/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -418,13 +418,11 @@ module.exports = {
// `data.query` (req.query)
//
// This method is async in 3.x and must be awaited.
//
// No longer deprecated because it is a useful override point
// for this part of the behavior of sendPage.

async renderPage(req, template, data) {
// TODO Remove in next major version.
self.apos.util.warnDevOnce(
'deprecate-renderPage',
'self.renderPage() is deprecated. Use self.sendPage() instead.'
);
return self.apos.template.renderPageForModule(req, template, data, self);
},

Expand Down Expand Up @@ -482,9 +480,8 @@ module.exports = {
try {
await self.apos.page.emit('beforeSend', req);
await self.apos.area.loadDeferredWidgets(req);
req.res.send(
await self.apos.template.renderPageForModule(req, template, data, self)
);
const result = await self.renderPage(req, template, data);
req.res.send(result);
span.setStatus({ code: telemetry.api.SpanStatusCode.OK });
} catch (err) {
telemetry.handleError(span, err);
Expand Down

0 comments on commit 52e4517

Please sign in to comment.