MishkaCmsCore.Runtime.Resources.Notifiers.SitemapRefresh (Mishka CMS Core v0.0.1)

Copy Markdown View Source

A reusable Ash notifier that rebuilds a site's sitemap after a write to a row it is built from.

Notifiers run after the transaction commits, for every action of a resource that lists this — master twins, bulk actions and actions added later included. Each hands the record's site to MishkaCmsCore.Runtime.Compilers.SitemapCompiler.schedule/1, which enqueues that site's "sitemap" job; a burst of writes is one build.

The site is the RECORD's site_id, not the changeset's tenant: a master twin runs with none. A nil one is a global row, so every open site is rebuilt. On MishkaCmsCore.Runtime.Setting only the keys a sitemap reads count.

An extension whose seo:sitemap:urls plugin lists rows of a resource adds it beside that resource's other notifiers:

use Ash.Resource,
  ...,
  notifiers: [
    Ash.Notifier.PubSub,
    MishkaCmsCore.Runtime.Resources.Notifiers.PluginHook,
    MishkaCmsCore.Runtime.Resources.Notifiers.SitemapRefresh
  ]

Pages and layouts do not list it: MishkaCmsCore.Runtime.Workers.RuntimeCompilerWorker enqueues the job after their own. Nor does a site: ScheduleSiteRuntime and BootHandler.compile_site/2 do.