Only parse and render content for first page initially, not all pages.

This commit is contained in:
Dillon Kearns 2020-01-20 17:34:42 -08:00
parent 3a4881d002
commit e2a65eb79e
2 changed files with 12 additions and 8 deletions

View File

@ -111,7 +111,7 @@ pagesWithErrors cache =
init : init :
Document metadata view Document metadata view
-> Content -> Content
-> Maybe (ContentJson String) -> Maybe { contentJson : ContentJson String, initialUrl : Url }
-> ContentCache metadata view -> ContentCache metadata view
init document content maybeInitialPageContent = init document content maybeInitialPageContent =
parseMetadata maybeInitialPageContent document content parseMetadata maybeInitialPageContent document content
@ -150,7 +150,7 @@ createBuildError path decodeError =
parseMetadata : parseMetadata :
Maybe (ContentJson String) Maybe { contentJson : ContentJson String, initialUrl : Url }
-> Document metadata view -> Document metadata view
-> List ( List String, { extension : String, frontMatter : String, body : Maybe String } ) -> List ( List String, { extension : String, frontMatter : String, body : Maybe String } )
-> List ( List String, Result String (Entry metadata view) ) -> List ( List String, Result String (Entry metadata view) )
@ -174,11 +174,15 @@ parseMetadata maybeInitialPageContent document content =
parseContent extension value document parseContent extension value document
in in
case maybeInitialPageContent of case maybeInitialPageContent of
Just initialPageContent -> Just { contentJson, initialUrl } ->
Parsed metadata if initialUrl.path == ("/" ++ String.join "/" path) then
{ body = renderer initialPageContent.body Parsed metadata
, staticData = initialPageContent.staticData { body = renderer contentJson.body
} , staticData = contentJson.staticData
}
else
NeedContent extension metadata
Nothing -> Nothing ->
NeedContent extension metadata NeedContent extension metadata

View File

@ -255,7 +255,7 @@ init :
init pathKey canonicalSiteUrl document toJsPort viewFn content initUserModel flags url key = init pathKey canonicalSiteUrl document toJsPort viewFn content initUserModel flags url key =
let let
contentCache = contentCache =
ContentCache.init document content contentJson ContentCache.init document content (Maybe.map (\cj -> { contentJson = cj, initialUrl = url }) contentJson)
contentJson = contentJson =
flags flags