mirror of
https://github.com/dillonkearns/elm-pages-v3-beta.git
synced 2024-12-23 11:55:41 +03:00
Include optional parameter for htmlToString configuration.
This commit is contained in:
parent
7c9fb152c8
commit
6a06767120
@ -1687,7 +1687,7 @@ otherFile routes phaseString =
|
||||
(Elm.Op.cons apiPatterns.reference
|
||||
(Elm.apply (Elm.value { name = "routes", importFrom = [ "Api" ], annotation = Nothing })
|
||||
[ getStaticRoutes.reference
|
||||
, fnIgnore (Elm.string "")
|
||||
, Elm.fn2 ( "a", Nothing ) ( "b", Nothing ) (\_ _ -> Elm.string "")
|
||||
]
|
||||
)
|
||||
)
|
||||
@ -1713,7 +1713,7 @@ otherFile routes phaseString =
|
||||
(Elm.apply
|
||||
(Elm.value { name = "routes", importFrom = [ "Api" ], annotation = Nothing })
|
||||
[ getStaticRoutes.reference
|
||||
, fnIgnore (Elm.string "")
|
||||
, Elm.fn2 ( "a", Nothing ) ( "b", Nothing ) (\_ _ -> Elm.string "")
|
||||
]
|
||||
|> Gen.List.call_.map Gen.ApiRoute.values_.toJson
|
||||
)
|
||||
@ -1822,7 +1822,19 @@ otherFile routes phaseString =
|
||||
}
|
||||
globalHeadTags =
|
||||
Elm.Declare.fn "globalHeadTags"
|
||||
( "htmlToString", Type.function [ Gen.Html.annotation_.html Gen.Basics.annotation_.never ] Type.string |> Just )
|
||||
( "htmlToString"
|
||||
, Type.function
|
||||
[ Type.maybe
|
||||
(Type.record
|
||||
[ ( "indent", Type.int )
|
||||
, ( "newLines", Type.bool )
|
||||
]
|
||||
)
|
||||
, Gen.Html.annotation_.html Gen.Basics.annotation_.never
|
||||
]
|
||||
Type.string
|
||||
|> Just
|
||||
)
|
||||
(\htmlToString ->
|
||||
Elm.Op.cons
|
||||
(Elm.value
|
||||
|
@ -8,7 +8,7 @@ import Route exposing (Route)
|
||||
|
||||
routes :
|
||||
DataSource (List Route)
|
||||
-> (Html Never -> String)
|
||||
-> (Maybe { indent : Int, newLines : Bool } -> Html Never -> String)
|
||||
-> List (ApiRoute.ApiRoute ApiRoute.Response)
|
||||
routes getStaticRoutes htmlToString =
|
||||
[]
|
||||
|
@ -21,7 +21,7 @@ import Time
|
||||
|
||||
routes :
|
||||
DataSource (List Route)
|
||||
-> (Html Never -> String)
|
||||
-> (Maybe { indent : Int, newLines : Bool } -> Html Never -> String)
|
||||
-> List (ApiRoute.ApiRoute ApiRoute.Response)
|
||||
routes getStaticRoutes htmlToString =
|
||||
[ ApiRoute.succeed
|
||||
|
@ -22,7 +22,7 @@ import Xml.Decode
|
||||
|
||||
routes :
|
||||
DataSource (List Route)
|
||||
-> (Html Never -> String)
|
||||
-> (Maybe { indent : Int, newLines : Bool } -> Html Never -> String)
|
||||
-> List (ApiRoute.ApiRoute ApiRoute.Response)
|
||||
routes getStaticRoutes htmlToString =
|
||||
let
|
||||
|
@ -8,7 +8,7 @@ import Route exposing (Route)
|
||||
|
||||
routes :
|
||||
DataSource (List Route)
|
||||
-> (Html Never -> String)
|
||||
-> (Maybe { indent : Int, newLines : Bool } -> Html Never -> String)
|
||||
-> List (ApiRoute.ApiRoute ApiRoute.Response)
|
||||
routes getStaticRoutes htmlToString =
|
||||
[]
|
||||
|
@ -10,7 +10,7 @@ import Site
|
||||
|
||||
routes :
|
||||
DataSource (List Route)
|
||||
-> (Html Never -> String)
|
||||
-> (Maybe { indent : Int, newLines : Bool } -> Html Never -> String)
|
||||
-> List (ApiRoute.ApiRoute ApiRoute.Response)
|
||||
routes getStaticRoutes htmlToString =
|
||||
[ DataSource.succeed manifest |> Manifest.generator Site.canonicalUrl
|
||||
|
@ -9,7 +9,7 @@ import Route exposing (Route)
|
||||
|
||||
routes :
|
||||
DataSource (List Route)
|
||||
-> (Html Never -> String)
|
||||
-> (Maybe { indent : Int, newLines : Bool } -> Html Never -> String)
|
||||
-> List (ApiRoute ApiRoute.Response)
|
||||
routes getStaticRoutes htmlToString =
|
||||
[]
|
||||
|
@ -17,7 +17,7 @@ import Site
|
||||
|
||||
routes :
|
||||
DataSource (List Route)
|
||||
-> (Html Never -> String)
|
||||
-> (Maybe { indent : Int, newLines : Bool } -> Html Never -> String)
|
||||
-> List (ApiRoute.ApiRoute ApiRoute.Response)
|
||||
routes getStaticRoutes htmlToString =
|
||||
[ --nonHybridRoute
|
||||
|
@ -8,7 +8,7 @@ import Route exposing (Route)
|
||||
|
||||
routes :
|
||||
DataSource (List Route)
|
||||
-> (Html Never -> String)
|
||||
-> (Maybe { indent : Int, newLines : Bool } -> Html Never -> String)
|
||||
-> List (ApiRoute.ApiRoute ApiRoute.Response)
|
||||
routes getStaticRoutes htmlToString =
|
||||
[]
|
||||
|
@ -8,7 +8,7 @@ import Route exposing (Route)
|
||||
|
||||
routes :
|
||||
DataSource (List Route)
|
||||
-> (Html Never -> String)
|
||||
-> (Maybe { indent : Int, newLines : Bool } -> Html Never -> String)
|
||||
-> List (ApiRoute.ApiRoute ApiRoute.Response)
|
||||
routes getStaticRoutes htmlToString =
|
||||
[]
|
||||
|
@ -8,7 +8,7 @@ import Route exposing (Route)
|
||||
|
||||
routes :
|
||||
DataSource (List Route)
|
||||
-> (Html Never -> String)
|
||||
-> (Maybe { indent : Int, newLines : Bool } -> Html Never -> String)
|
||||
-> List (ApiRoute.ApiRoute ApiRoute.Response)
|
||||
routes getStaticRoutes htmlToString =
|
||||
[]
|
||||
|
@ -17,7 +17,7 @@ import Site
|
||||
|
||||
routes :
|
||||
DataSource (List Route)
|
||||
-> (Html Never -> String)
|
||||
-> (Maybe { indent : Int, newLines : Bool } -> Html Never -> String)
|
||||
-> List (ApiRoute.ApiRoute ApiRoute.Response)
|
||||
routes getStaticRoutes htmlToString =
|
||||
[ --nonHybridRoute
|
||||
|
@ -10,7 +10,7 @@ import Site
|
||||
|
||||
routes :
|
||||
DataSource (List Route)
|
||||
-> (Html Never -> String)
|
||||
-> (Maybe { indent : Int, newLines : Bool } -> Html Never -> String)
|
||||
-> List (ApiRoute.ApiRoute ApiRoute.Response)
|
||||
routes getStaticRoutes htmlToString =
|
||||
[ DataSource.succeed manifest |> Manifest.generator Site.canonicalUrl
|
||||
|
@ -17,7 +17,7 @@ import Site
|
||||
|
||||
routes :
|
||||
DataSource (List Route)
|
||||
-> (Html Never -> String)
|
||||
-> (Maybe { indent : Int, newLines : Bool } -> Html Never -> String)
|
||||
-> List (ApiRoute.ApiRoute ApiRoute.Response)
|
||||
routes getStaticRoutes htmlToString =
|
||||
[ --nonHybridRoute
|
||||
|
@ -9,7 +9,7 @@ import Route exposing (Route)
|
||||
|
||||
routes :
|
||||
DataSource (List Route)
|
||||
-> (Html Never -> String)
|
||||
-> (Maybe { indent : Int, newLines : Bool } -> Html Never -> String)
|
||||
-> List (ApiRoute ApiRoute.Response)
|
||||
routes getStaticRoutes htmlToString =
|
||||
[]
|
||||
|
@ -8,15 +8,19 @@ import Test.Html.Internal.ElmHtml.ToString exposing (defaultFormatOptions, nodeT
|
||||
import VirtualDom
|
||||
|
||||
|
||||
htmlToString : Html msg -> String
|
||||
htmlToString viewHtml =
|
||||
htmlToString : Maybe { indent : Int, newLines : Bool } -> Html msg -> String
|
||||
htmlToString formatOptions viewHtml =
|
||||
case
|
||||
Decode.decodeValue
|
||||
(decodeElmHtml (\_ _ -> VirtualDom.Normal (Decode.succeed ())))
|
||||
(asJsonView viewHtml)
|
||||
of
|
||||
Ok str ->
|
||||
nodeToStringWithOptions defaultFormatOptions str
|
||||
nodeToStringWithOptions
|
||||
(formatOptions
|
||||
|> Maybe.withDefault defaultFormatOptions
|
||||
)
|
||||
str
|
||||
|
||||
Err err ->
|
||||
"Error pre-rendering HTML in HtmlPrinter.elm: " ++ Decode.errorToString err
|
||||
|
@ -880,7 +880,7 @@ sendSinglePageProgress site contentJson config model info =
|
||||
, headers = record.headers
|
||||
}
|
||||
{ head = config.view Dict.empty Dict.empty Nothing currentPage Nothing sharedData pageData Nothing |> .head
|
||||
, view = viewValue.body |> List.map HtmlPrinter.htmlToString |> String.join "\n"
|
||||
, view = viewValue.body |> List.map (HtmlPrinter.htmlToString Nothing) |> String.join "\n"
|
||||
, title = viewValue.title
|
||||
}
|
||||
)
|
||||
@ -1221,7 +1221,7 @@ render404Page config sharedData model path notFoundReason =
|
||||
|
||||
bodyToString : List (Html msg) -> String
|
||||
bodyToString body =
|
||||
body |> List.map HtmlPrinter.htmlToString |> String.join "\n"
|
||||
body |> List.map (HtmlPrinter.htmlToString Nothing) |> String.join "\n"
|
||||
|
||||
|
||||
urlToRoute : ProgramConfig userMsg userModel route pageData actionData sharedData effect mappedMsg errorPage -> Url -> route
|
||||
|
@ -88,7 +88,10 @@ type alias ProgramConfig userMsg userModel route pageData actionData sharedData
|
||||
}
|
||||
-> userMsg
|
||||
, apiRoutes :
|
||||
(Html Never -> String)
|
||||
(Maybe { indent : Int, newLines : Bool }
|
||||
-> Html Never
|
||||
-> String
|
||||
)
|
||||
-> List (ApiRoute.ApiRoute ApiRoute.Response)
|
||||
, pathPatterns : List RoutePattern
|
||||
, basePath : List String
|
||||
@ -98,7 +101,7 @@ type alias ProgramConfig userMsg userModel route pageData actionData sharedData
|
||||
, encodeResponse : ResponseSketch pageData actionData sharedData -> Bytes.Encode.Encoder
|
||||
, encodeAction : actionData -> Bytes.Encode.Encoder
|
||||
, decodeResponse : Bytes.Decode.Decoder (ResponseSketch pageData actionData sharedData)
|
||||
, globalHeadTags : Maybe ((Html Never -> String) -> DataSource (List Head.Tag))
|
||||
, globalHeadTags : Maybe ((Maybe { indent : Int, newLines : Bool } -> Html Never -> String) -> DataSource (List Head.Tag))
|
||||
, cmdToEffect : Cmd userMsg -> effect
|
||||
, perform :
|
||||
{ fetchRouteData :
|
||||
|
Loading…
Reference in New Issue
Block a user