# `MishkaBlog.Resources.Changes.ContentFacts`
[🔗](https://github.com/mishka-group/mishka_blog/blob/v0.0.1/lib/mishka_blog/resources/__changes/content_facts.ex#L5)

What a post's `content` says about it, worked out once, when the content is written — reading a
post works out neither:

  * `content_components` — the components its markers name
    (`MishkaCmsCore.Runtime.ContentComponents.names/1`), `nil` when it names none. A site's
    stylesheet is built from them — see `MishkaBlog.Plugins.ContentComponents`.
  * `content_icons` — the icon classes it names, in a marker's attribute or in its HTML
    (`MishkaCmsCore.Runtime.ContentComponents.icons/1`), `nil` when it names none. The site's
    stylesheet carries a rule for each — see `MishkaBlog.Plugins.ContentComponents`.
  * `content_classes` — the classes it writes: its HTML's class lists, a marker's `class` and
    `*_class` attributes, and the attributes its component takes a class string in
    (`MishkaCmsCore.Runtime.ContentComponents.site_classes/2`), `nil` when it writes none. The
    site's stylesheet is built with each — see `MishkaBlog.Plugins.ContentComponents`.
  * `reading_time_minutes` — its words at 200 a minute, rounded up, never under 1.

All four are worked out in a `before_action` hook, which runs after every change an action lists
— the `guardedstruct` sanitizer and `MishkaBlog.Resources.Changes.HighlightCode` included — so
they are read off the content that is stored. A write that leaves `content` alone leaves them
alone, unless the post has no reading time yet — a row this change never saw — which any save
fills.

## The stylesheet

A write that makes a name, an icon or a class live on its site — a published post names it now and
did not before, and no other published post of the site names it — rebuilds the site's
stylesheet, through `MishkaCmsCore.Runtime.Compilers.TailwindCompiler.schedule/1`. The job is
enqueued in the write's own transaction, so a write rolled back asks for nothing. A name, an icon
or a class dropped, or a post unpublished, rebuilds nothing.

## Usage

    update :update do
      change MishkaBlog.Resources.Changes.HighlightCode
      change MishkaBlog.Resources.Changes.ContentFacts
    end

On an action that writes no content — `:publish` — only the stylesheet half has anything to do.

# `newly_live`

```elixir
@spec newly_live(
  map(),
  map(),
  :content_components | :content_icons | :content_classes
) :: [String.t()]
```

What `post` makes live of `fact` that `was` did not — its component names
(`:content_components`, the default), its icons (`:content_icons`) or its classes
(`:content_classes`): what a published post lists, less what the post published before the write
already listed.

# `reading_time`

```elixir
@spec reading_time(String.t()) :: pos_integer()
```

Minutes `content` takes to read: its words at 200 a minute, rounded up, never under 1.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
