You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Plugin content API: public URLs for a page of entries in one call
#3366
I'm building a web analytics plugin that shows views per entry. It matches the paths the analytics provider reports to entries through ctx.content.getPublicUrl(collection, id), which returns exactly the URL the site serves, locale prefix and trailing slash included. That is one call per entry, and in the Cloudflare sandbox every ctx call is one of the invocation's subrequests (10 today, 30 after the proposed raise).
The walk over existing content already batches everything else, storage through getMany and putMany included: seven calls per run, plus one getPublicUrl per entry. With a run every half hour that is three entries per run at 10 and about 23 at 30, so a site with 1,000 published entries waits about a week at 10 and most of a day at 30 before every entry has its numbers.
Everything getPublicUrl reads from the entry is already in a content.list item: slug, status, locale and publish date. The rest is the collection's URL pattern and the site's settings, the same for the whole page. One call per page would do, and I can see two shapes:
An option on content.list, for example list(collection, { where: { status: "published" }, publicUrl: true }), where each item carries publicUrl: string | null. list already adds SEO metadata to a page with one batched read.
A method getPublicUrls(collection, ids): Promise<Map<string, string | null>>, for plugins that hold ids from their own storage rather than a listing.
Both keep the URL logic in core, so a plugin never copies the route resolution and drifts from what the site serves.
Would you take either of these? I'm happy to implement whichever shape you prefer.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
I'm building a web analytics plugin that shows views per entry. It matches the paths the analytics provider reports to entries through
ctx.content.getPublicUrl(collection, id), which returns exactly the URL the site serves, locale prefix and trailing slash included. That is one call per entry, and in the Cloudflare sandbox everyctxcall is one of the invocation's subrequests (10 today, 30 after the proposed raise).The walk over existing content already batches everything else, storage through
getManyandputManyincluded: seven calls per run, plus onegetPublicUrlper entry. With a run every half hour that is three entries per run at 10 and about 23 at 30, so a site with 1,000 published entries waits about a week at 10 and most of a day at 30 before every entry has its numbers.Everything
getPublicUrlreads from the entry is already in acontent.listitem: slug, status, locale and publish date. The rest is the collection's URL pattern and the site's settings, the same for the whole page. One call per page would do, and I can see two shapes:content.list, for examplelist(collection, { where: { status: "published" }, publicUrl: true }), where each item carriespublicUrl: string | null.listalready adds SEO metadata to a page with one batched read.getPublicUrls(collection, ids): Promise<Map<string, string | null>>, for plugins that hold ids from their own storage rather than a listing.Both keep the URL logic in core, so a plugin never copies the route resolution and drifts from what the site serves.
Would you take either of these? I'm happy to implement whichever shape you prefer.
All reactions