MishkaBlog.Resources.Changes.ContentFacts (Mishka Blog v0.0.1)

Copy Markdown View Source

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

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.

Summary

Functions

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.

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

Functions

newly_live(was, post, fact \\ :content_components)

@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(content)

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

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