Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PRO-4745: Make it possible to fetch data rather than a rendered page for any page URL in Apostrophe core #4285

Merged
merged 2 commits into from
Sep 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@
### Adds

* 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
Loading