Skip to content
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
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@

* Redirects to URLs containing accent marks and other non-ascii characters now behave as expected with Astro. Pre-encoding the URLs exactly the way `res.redirect` would before passing them to Astro prevents an error in Astro and allows the redirect to succeed.
* Removes the non-functional `uniqueUsername` route from the `user` module
* Modifies the `annotateAreaForExternalFront()` method of the `@apostrophecms/template` module to accept a per-module `annotateWidgetForExternalFront()` method. This allows widgets to send project-level options alongside the per-area options to external frontends.
* Updated dependencies to address deprecation warnings.


## 4.21.0 (2025-09-03)

### Adds
Expand Down
25 changes: 18 additions & 7 deletions modules/@apostrophecms/template/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -432,8 +432,8 @@ module.exports = {
const parse = config.parse
? config.parse
: function (parser, nodes, lexer) {
// Default parser gets comma separated arguments,
// assumes no body
// Default parser gets comma separated arguments,
// assumes no body

// get the tag token
const token = parser.nextToken();
Expand Down Expand Up @@ -696,7 +696,7 @@ module.exports = {
_.extend(args, data);

if (req.aposError) {
// A 500-worthy error occurred already, i.e. in `pageBeforeSend`
// A 500-worthy error occurred already, i.e. in `pageBeforeSend`
telemetry.handleError(span, req.aposError);
span.end();
return error(req.aposError);
Expand Down Expand Up @@ -739,8 +739,8 @@ module.exports = {
span.setStatus({ code: telemetry.api.SpanStatusCode.OK });
return content;
} catch (e) {
// The page template threw an exception. Log where it
// occurred for easier debugging
// The page template threw an exception. Log where it
// occurred for easier debugging
telemetry.handleError(span, e);
return error(e);
} finally {
Expand Down Expand Up @@ -1303,11 +1303,22 @@ module.exports = {
label: options.addLabel || manager.label || `No label for ${name}`
};
}).filter(choice => !!choice);

area.items ||= [];
if (area._docId) {
for (const item of area.items) {
for (const item of area.items) {
// Add _docId if area has one
if (area._docId) {
item._docId = area._docId;
}

// Annotate each individual widget with its options
// Each widget must elect into this by creating an
// `annotateWidgetForExternalFront() method.
const manager = self.apos.area.getManager?.(item.type) ||
self.apos.area.widgetManagers?.[item.type];

const widgetOptions = manager.annotateWidgetForExternalFront() || {};
item._options = widgetOptions;
}
}
};
Expand Down
5 changes: 5 additions & 0 deletions modules/@apostrophecms/widget-type/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,12 @@ module.exports = {
}
return true;
});
},

annotateWidgetForExternalFront() {
return {};
}

};
},
extendMethods(self) {
Expand Down