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
Currently there is no way to apply different filters or different fields combination for same content type.
Even in the code it's limited by Object.keys(config.contentTypes) so no way to inject custom rule entry
I tried to hook into the code but found it difficult to extend.
The method createSitemapEntries is called directly and is considered as private for userland code. So there is no way to overload this function.
With some success I managed to hook into customEntries array by overloading getConfig method and appending my additional entries only during sitemap generation by checking stack trace :)
Here is my plugin in strapi-server.ts
I think it would be more handy to have dedicated extension points, so hooking into sitemap generation would be more easy.
module.exports=(plugin)=>{constservice=plugin.services.settings;constinited=service();constorigGetConfig=inited.getConfig;inited.getConfig=asyncfunctionMYgetConfig(){constorigResult=awaitorigGetConfig();conststackTrace=Error().stack;constisGenerating=stackTrace.includes("createSitemapEntries")&&stackTrace.includes("Object.createSitemap");if(!isGenerating){returnorigResult;}constknex=strapi.db.connection;constbenefitLocalityLinks=awaitknex.raw(` SELECT DISTINCT '0.6' AS priority, 'daily' AS changefreq, ('/pl/v/' || slug_city || '/' || slug_service) AS url FROM my_table ORDER BY slug_city ASC `);for(constentryLinkofbenefitLocalityLinks){origResult.customEntries[entryLink.url]=entryLink;}returnorigResult;};//override with custom decoratorplugin.services.settings=()=>inited;returnplugin;};
The text was updated successfully, but these errors were encountered:
Feature request
Summary
Add hooks / extension point where userland code can decorate results.
Why is it needed?
Currently it's hard to hook into sitemap generation with userland code.
Suggested solution(s)
Allow core functions overload
or add dedicated extension points
or add registring custom handlers
or all together.
Related issue(s)/PR(s)
The feature is partly related to these PRs/Issues
#109
#60
Currently there is no way to apply different filters or different fields combination for same content type.
Even in the code it's limited by
Object.keys(config.contentTypes)
so no way to inject custom rule entryI tried to hook into the code but found it difficult to extend.
Especially this core service:
The method
createSitemapEntries
is called directly and is considered as private for userland code. So there is no way to overload this function.With some success I managed to hook into
customEntries
array by overloadinggetConfig
method and appending my additional entries only during sitemap generation by checking stack trace :)Here is my plugin in
strapi-server.ts
I think it would be more handy to have dedicated extension points, so hooking into sitemap generation would be more easy.
The text was updated successfully, but these errors were encountered: