Degrade gracefully on corrupt backlinks JSON
If data/backlinks.json fails to parse, every page that uses the backlinks context aborts with 'fail'. The JSON is build-generated; corruption is unlikely but not impossible (interrupted writer, disk issue). Switch to noResult so the affected pages render without the backlinks block instead of failing the whole build. The next clean build regenerates the JSON. Note: commonplace.yaml and now.yaml deliberately keep fail-fast — they're hand-edited and silent fallbacks would mask author typos. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
725fa17f6a
commit
0379dda908
|
|
@ -356,7 +356,7 @@ backlinksField = field "backlinks" $ \item -> do
|
||||||
blItem <- load (fromFilePath "data/backlinks.json") :: Compiler (Item String)
|
blItem <- load (fromFilePath "data/backlinks.json") :: Compiler (Item String)
|
||||||
case Aeson.decodeStrict (TE.encodeUtf8 (T.pack (itemBody blItem)))
|
case Aeson.decodeStrict (TE.encodeUtf8 (T.pack (itemBody blItem)))
|
||||||
:: Maybe (Map T.Text [BacklinkSource]) of
|
:: Maybe (Map T.Text [BacklinkSource]) of
|
||||||
Nothing -> fail "backlinks: could not parse data/backlinks.json"
|
Nothing -> noResult "backlinks: could not parse data/backlinks.json"
|
||||||
Just blMap -> do
|
Just blMap -> do
|
||||||
mRoute <- getRoute (itemIdentifier item)
|
mRoute <- getRoute (itemIdentifier item)
|
||||||
case mRoute of
|
case mRoute of
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue