elm-pages 3.0.0-beta.1 → 3.0.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -35312,7 +35312,11 @@ var $author$project$GenerateMain$otherFile = F2(
35312
35312
  $author$project$Elm$string('Model mismatch')),
35313
35313
  _Utils_Tuple2(
35314
35314
  'body',
35315
- $author$project$Gen$Html$text('Model mismatch'))
35315
+ $author$project$Elm$list(
35316
+ _List_fromArray(
35317
+ [
35318
+ $author$project$Gen$Html$text('Model mismatch')
35319
+ ])))
35316
35320
  ])));
35317
35321
  var view = A3(
35318
35322
  $author$project$Elm$Declare$function,
@@ -35424,9 +35428,10 @@ var $author$project$GenerateMain$otherFile = F2(
35424
35428
  _Utils_Tuple2('title', $author$project$Elm$Annotation$string),
35425
35429
  _Utils_Tuple2(
35426
35430
  'body',
35427
- $author$project$Gen$Html$annotation_.html(
35428
- $author$project$Gen$Pages$Msg$annotation_.msg(
35429
- A2($author$project$Elm$Annotation$named, _List_Nil, 'Msg'))))
35431
+ $author$project$Elm$Annotation$list(
35432
+ $author$project$Gen$Html$annotation_.html(
35433
+ $author$project$Gen$Pages$Msg$annotation_.msg(
35434
+ A2($author$project$Elm$Annotation$named, _List_Nil, 'Msg')))))
35430
35435
  ])))),
35431
35436
  _Utils_Tuple2(
35432
35437
  'head',
@@ -35790,12 +35795,16 @@ var $author$project$GenerateMain$otherFile = F2(
35790
35795
  $author$project$Elm$string('Page not found')),
35791
35796
  _Utils_Tuple2(
35792
35797
  'body',
35793
- A2(
35794
- $author$project$Gen$Html$div,
35795
- _List_Nil,
35798
+ $author$project$Elm$list(
35796
35799
  _List_fromArray(
35797
35800
  [
35798
- $author$project$Gen$Html$text('This page could not be found.')
35801
+ A2(
35802
+ $author$project$Gen$Html$div,
35803
+ _List_Nil,
35804
+ _List_fromArray(
35805
+ [
35806
+ $author$project$Gen$Html$text('This page could not be found.')
35807
+ ]))
35799
35808
  ])))
35800
35809
  ]));
35801
35810
  })),
@@ -75,7 +75,7 @@ console.elmlog = (str) => logs.push(str + "\n");
75
75
  const { Elm } = require("./Runner.elm.js");
76
76
 
77
77
  // Start the Elm app
78
- const flags = { initialSeed: 3296225071, fuzzRuns: 100, filter: null };
78
+ const flags = { initialSeed: 1130841854, fuzzRuns: 100, filter: null };
79
79
  const app = Elm.Runner.init({ flags: flags });
80
80
 
81
81
  // Record the timing at which we received the last "runTest" message
@@ -82,7 +82,7 @@ const verbosity = 0;
82
82
  // Create a long lived reporter worker
83
83
  const { Elm } = require("./Reporter.elm.js");
84
84
  const flags = {
85
- initialSeed: 3296225071,
85
+ initialSeed: 1130841854,
86
86
  fuzzRuns: 100,
87
87
  mode: "consoleNoColor",
88
88
  verbosity: verbosity,
@@ -75,7 +75,7 @@ console.elmlog = (str) => logs.push(str + "\n");
75
75
  const { Elm } = require("./Runner.elm.js");
76
76
 
77
77
  // Start the Elm app
78
- const flags = { initialSeed: 1016531122, fuzzRuns: 100, filter: null };
78
+ const flags = { initialSeed: 2471752417, fuzzRuns: 100, filter: null };
79
79
  const app = Elm.Runner.init({ flags: flags });
80
80
 
81
81
  // Record the timing at which we received the last "runTest" message
@@ -82,7 +82,7 @@ const verbosity = 0;
82
82
  // Create a long lived reporter worker
83
83
  const { Elm } = require("./Reporter.elm.js");
84
84
  const flags = {
85
- initialSeed: 1016531122,
85
+ initialSeed: 2471752417,
86
86
  fuzzRuns: 100,
87
87
  mode: "consoleNoColor",
88
88
  verbosity: verbosity,
@@ -34,7 +34,7 @@ type alias SharedTemplate msg sharedModel sharedData mappedMsg =
34
34
  -> sharedModel
35
35
  -> (msg -> mappedMsg)
36
36
  -> View mappedMsg
37
- -> { body : Html mappedMsg, title : String }
37
+ -> { body : List (Html mappedMsg), title : String }
38
38
  , data : DataSource.DataSource sharedData
39
39
  , subscriptions : Path -> sharedModel -> Sub msg
40
40
  , onPageChange :
@@ -63,32 +63,10 @@ async function generateTemplateModuleConnector(basePath, phase) {
63
63
  }
64
64
 
65
65
  async function runElmCodegenCli(templates, basePath, phase) {
66
- // await runElmCodegenInstall();
67
- // try {
68
- // await compileCliApp(
69
- // // { debug: true },
70
- // {},
71
- // `Generate.elm`,
72
- // path.join(process.cwd(), "elm-stuff/elm-pages-codegen.js"),
73
- // path.join(__dirname, "../../codegen"),
74
-
75
- // path.join(process.cwd(), "elm-stuff/elm-pages-codegen.js")
76
- // );
77
- // } catch (error) {
78
- // console.log(restoreColorSafe(error));
79
- // process.exit(1);
80
- // // throw error;
81
- // }
82
-
83
66
  const filePath = path.join(__dirname, `../../codegen/elm-pages-codegen.js`);
84
67
 
85
- // TODO use uncached require here to prevent stale code from running
86
-
87
68
  const promise = new Promise((resolve, reject) => {
88
69
  const elmPagesCodegen = require(filePath).Elm.Generate;
89
- // path.join(
90
- // process.cwd(),
91
- // "./elm-stuff/elm-pages-codegen.js")
92
70
 
93
71
  const app = elmPagesCodegen.init({
94
72
  flags: { templates: templates, basePath, phase },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "elm-pages",
3
- "version": "3.0.0-beta.1",
3
+ "version": "3.0.0-beta.2",
4
4
  "homepage": "https://elm-pages.com",
5
5
  "moduleResolution": "node",
6
6
  "description": "Type-safe static sites, written in pure elm with your own custom elm-markup syntax.",
@@ -171,7 +171,7 @@ just the metadata.
171
171
  (Decode.field "tags" (Decode.list Decode.string))
172
172
 
173
173
  If you wanted to use this to get this metadata for all blog posts in a folder, you could use
174
- the [`DataSource`](DataSource) API along with [`DataSource.Glob`](DataSource.Glob).
174
+ the [`DataSource`](DataSource) API along with [`DataSource.Glob`](DataSource-Glob).
175
175
 
176
176
  import DataSource exposing (DataSource)
177
177
  import DataSource.File as File
@@ -1,10 +1,5 @@
1
1
  module DataSource.Internal.Request exposing (request)
2
2
 
3
- {-| Build a `DataSource.Http` request (analogous to [Http.request](https://package.elm-lang.org/packages/elm/http/latest/Http#request)).
4
- This function takes in all the details to build a `DataSource.Http` request, but you can build your own simplified helper functions
5
- with this as a low-level detail, or you can use functions like [DataSource.Http.get](#get).
6
- -}
7
-
8
3
  import DataSource exposing (DataSource)
9
4
  import DataSource.Http exposing (Body, Expect)
10
5
 
package/src/Form.elm CHANGED
@@ -575,7 +575,7 @@ field name (Field fieldParser kind) (Form definitions parseFn toInitialValues) =
575
575
 
576
576
  {-| Declare a hidden field for the form.
577
577
 
578
- Unlike [`field`](#field) declarations which are rendered using [`Form.ViewField`](Form-ViewField)
578
+ Unlike [`field`](#field) declarations which are rendered using [`Form.FieldView`](Form-FieldView)
579
579
  functions, `hiddenField` inputs are automatically inserted into the form when you render it.
580
580
 
581
581
  You define the field's validations the same way as for `field`, with the
package/src/Head/Seo.elm CHANGED
@@ -49,10 +49,12 @@ with the `head` function that you pass to your Pages config (`Pages.application`
49
49
 
50
50
  -}
51
51
 
52
+ import DateOrDateTime exposing (DateOrDateTime)
52
53
  import Head
53
54
  import Head.Twitter as Twitter
54
55
  import LanguageTag.Country
55
56
  import LanguageTag.Language
57
+ import MimeType exposing (MimeType)
56
58
  import Pages.Url
57
59
 
58
60
 
@@ -235,9 +237,9 @@ website common =
235
237
  article :
236
238
  { tags : List String
237
239
  , section : Maybe String
238
- , publishedTime : Maybe Iso8601DateTime
239
- , modifiedTime : Maybe Iso8601DateTime
240
- , expirationTime : Maybe Iso8601DateTime
240
+ , publishedTime : Maybe DateOrDateTime
241
+ , modifiedTime : Maybe DateOrDateTime
242
+ , expirationTime : Maybe DateOrDateTime
241
243
  }
242
244
  -> Common
243
245
  -> List Head.Tag
@@ -252,7 +254,7 @@ book :
252
254
  ->
253
255
  { tags : List String
254
256
  , isbn : Maybe String
255
- , releaseDate : Maybe Iso8601DateTime
257
+ , releaseDate : Maybe DateOrDateTime
256
258
  }
257
259
  -> List Head.Tag
258
260
  book common details =
@@ -354,7 +356,7 @@ tagsForAudio : Audio -> List ( String, Maybe Head.AttributeValue )
354
356
  tagsForAudio audio =
355
357
  [ ( "og:audio", audio.url |> Head.raw |> Just )
356
358
  , ( "og:audio:secure_url", audio.url |> Head.raw |> Just )
357
- , ( "og:audio:type", audio.mimeType |> Maybe.map Head.raw )
359
+ , ( "og:audio:type", audio.mimeType |> Maybe.map (MimeType.toString >> Head.raw) )
358
360
  ]
359
361
 
360
362
 
@@ -371,14 +373,14 @@ type ContentDetails
371
373
  | Article
372
374
  { tags : List String
373
375
  , section : Maybe String
374
- , publishedTime : Maybe Iso8601DateTime
375
- , modifiedTime : Maybe Iso8601DateTime
376
- , expirationTime : Maybe Iso8601DateTime
376
+ , publishedTime : Maybe DateOrDateTime
377
+ , modifiedTime : Maybe DateOrDateTime
378
+ , expirationTime : Maybe DateOrDateTime
377
379
  }
378
380
  | Book
379
381
  { tags : List String
380
382
  , isbn : Maybe String
381
- , releaseDate : Maybe Iso8601DateTime
383
+ , releaseDate : Maybe DateOrDateTime
382
384
  }
383
385
  | Song
384
386
  {-
@@ -399,20 +401,6 @@ type ContentDetails
399
401
  }
400
402
 
401
403
 
402
- {-| <https://en.wikipedia.org/wiki/ISO_8601>
403
- -}
404
- type alias Iso8601DateTime =
405
- -- TODO should be more type-safe here
406
- String
407
-
408
-
409
- {-| <https://en.wikipedia.org/wiki/Media_type>
410
- -}
411
- type alias MimeType =
412
- -- TODO should be more type-safe here
413
- String
414
-
415
-
416
404
  {-| See <https://ogp.me/#structured>
417
405
  -}
418
406
  type alias Image =
@@ -448,6 +436,7 @@ tagsForVideo video =
448
436
  , ( "og:video:secure_url", video.url |> Head.raw |> Just )
449
437
  , ( "og:video:width", video.dimensions |> Maybe.map .width |> Maybe.map String.fromInt |> Maybe.map Head.raw )
450
438
  , ( "og:video:height", video.dimensions |> Maybe.map .height |> Maybe.map String.fromInt |> Maybe.map Head.raw )
439
+ , ( "og:video:type", video.mimeType |> Maybe.map (MimeType.toString >> Head.raw) )
451
440
  ]
452
441
 
453
442
 
@@ -466,9 +455,9 @@ tags (Content common details) =
466
455
  -}
467
456
  [ ( "og:type", "article" |> Head.raw |> Just )
468
457
  , ( "article:section", articleDetails.section |> Maybe.map Head.raw )
469
- , ( "article:published_time", articleDetails.publishedTime |> Maybe.map Head.raw )
470
- , ( "article:modified_time", articleDetails.modifiedTime |> Maybe.map Head.raw )
471
- , ( "article:expiration_time", articleDetails.expirationTime |> Maybe.map Head.raw )
458
+ , ( "article:published_time", articleDetails.publishedTime |> Maybe.map (DateOrDateTime.dateOrDateTimeToIso8601String >> Head.raw) )
459
+ , ( "article:modified_time", articleDetails.modifiedTime |> Maybe.map (DateOrDateTime.dateOrDateTimeToIso8601String >> Head.raw) )
460
+ , ( "article:expiration_time", articleDetails.expirationTime |> Maybe.map (DateOrDateTime.dateOrDateTimeToIso8601String >> Head.raw) )
472
461
  ]
473
462
  ++ List.map
474
463
  (\tag -> ( "article:tag", tag |> Head.raw |> Just ))
@@ -477,7 +466,7 @@ tags (Content common details) =
477
466
  Book bookDetails ->
478
467
  [ ( "og:type", "book" |> Head.raw |> Just )
479
468
  , ( "og:isbn", bookDetails.isbn |> Maybe.map Head.raw )
480
- , ( "og:release_date", bookDetails.releaseDate |> Maybe.map Head.raw )
469
+ , ( "og:release_date", bookDetails.releaseDate |> Maybe.map (DateOrDateTime.dateOrDateTimeToIso8601String >> Head.raw) )
481
470
  ]
482
471
  ++ List.map
483
472
  (\tag -> ( "book:tag", tag |> Head.raw |> Just ))
@@ -44,11 +44,11 @@ type NotFoundReason
44
44
  document :
45
45
  List RoutePattern
46
46
  -> Payload
47
- -> { title : String, body : Html msg }
47
+ -> { title : String, body : List (Html msg) }
48
48
  document pathPatterns payload =
49
49
  { title = "Page not found"
50
50
  , body =
51
- Html.div
51
+ [ Html.div
52
52
  [ Attr.id "not-found-reason"
53
53
  , Attr.style "padding" "30px"
54
54
  ]
@@ -110,6 +110,7 @@ document pathPatterns payload =
110
110
  , Html.text <| "TODO"
111
111
  ]
112
112
  )
113
+ ]
113
114
  }
114
115
 
115
116
 
@@ -829,13 +829,13 @@ sendSinglePageProgress site contentJson config model info =
829
829
  )
830
830
  |> Tuple.first
831
831
 
832
- viewValue : { title : String, body : Html (Pages.Msg.Msg userMsg) }
832
+ viewValue : { title : String, body : List (Html (Pages.Msg.Msg userMsg)) }
833
833
  viewValue =
834
834
  (config.view Dict.empty Dict.empty Nothing currentPage Nothing sharedData pageData maybeActionData |> .view) pageModel
835
835
  in
836
836
  PageServerResponse.RenderPage responseInfo
837
837
  { head = config.view Dict.empty Dict.empty Nothing currentPage Nothing sharedData pageData maybeActionData |> .head
838
- , view = viewValue.body |> HtmlPrinter.htmlToString
838
+ , view = viewValue.body |> bodyToString
839
839
  , title = viewValue.title
840
840
  }
841
841
 
@@ -871,7 +871,7 @@ sendSinglePageProgress site contentJson config model info =
871
871
  pageData =
872
872
  config.errorPageToData error
873
873
 
874
- viewValue : { title : String, body : Html (Pages.Msg.Msg userMsg) }
874
+ viewValue : { title : String, body : List (Html (Pages.Msg.Msg userMsg)) }
875
875
  viewValue =
876
876
  (config.view Dict.empty Dict.empty Nothing currentPage Nothing sharedData pageData Nothing |> .view) pageModel
877
877
  in
@@ -880,7 +880,7 @@ sendSinglePageProgress site contentJson config model info =
880
880
  , headers = record.headers
881
881
  }
882
882
  { head = config.view Dict.empty Dict.empty Nothing currentPage Nothing sharedData pageData Nothing |> .head
883
- , view = viewValue.body |> HtmlPrinter.htmlToString
883
+ , view = viewValue.body |> List.map HtmlPrinter.htmlToString |> String.join "\n"
884
884
  , title = viewValue.title
885
885
  }
886
886
  )
@@ -1143,7 +1143,7 @@ render404Page config sharedData model path notFoundReason =
1143
1143
  pathAndRoute =
1144
1144
  { path = path, route = config.notFoundRoute }
1145
1145
 
1146
- viewValue : { title : String, body : Html (Pages.Msg.Msg userMsg) }
1146
+ viewValue : { title : String, body : List (Html (Pages.Msg.Msg userMsg)) }
1147
1147
  viewValue =
1148
1148
  (config.view Dict.empty
1149
1149
  Dict.empty
@@ -1159,7 +1159,7 @@ render404Page config sharedData model path notFoundReason =
1159
1159
  in
1160
1160
  { route = Path.toAbsolute path
1161
1161
  , contentJson = Dict.empty
1162
- , html = viewValue.body |> HtmlPrinter.htmlToString
1162
+ , html = viewValue.body |> bodyToString
1163
1163
  , errors = []
1164
1164
  , head = config.view Dict.empty Dict.empty Nothing pathAndRoute Nothing justSharedData pageData Nothing |> .head
1165
1165
  , title = viewValue.title
@@ -1179,7 +1179,7 @@ render404Page config sharedData model path notFoundReason =
1179
1179
  |> config.encodeResponse
1180
1180
  |> Bytes.Encode.encode
1181
1181
 
1182
- notFoundDocument : { title : String, body : Html msg }
1182
+ notFoundDocument : { title : String, body : List (Html msg) }
1183
1183
  notFoundDocument =
1184
1184
  { path = path
1185
1185
  , reason = notFoundReason
@@ -1188,7 +1188,7 @@ render404Page config sharedData model path notFoundReason =
1188
1188
  in
1189
1189
  { route = Path.toAbsolute path
1190
1190
  , contentJson = Dict.empty
1191
- , html = HtmlPrinter.htmlToString notFoundDocument.body
1191
+ , html = bodyToString notFoundDocument.body
1192
1192
  , errors = []
1193
1193
  , head = []
1194
1194
  , title = notFoundDocument.title
@@ -1204,6 +1204,11 @@ render404Page config sharedData model path notFoundReason =
1204
1204
  |> Effect.SendSinglePageNew byteEncodedPageData
1205
1205
 
1206
1206
 
1207
+ bodyToString : List (Html msg) -> String
1208
+ bodyToString body =
1209
+ body |> List.map HtmlPrinter.htmlToString |> String.join "\n"
1210
+
1211
+
1207
1212
  urlToRoute : ProgramConfig userMsg userModel route pageData actionData sharedData effect mappedMsg errorPage -> Url -> route
1208
1213
  urlToRoute config url =
1209
1214
  if url.path |> String.startsWith "/____elm-pages-internal____" then
@@ -58,7 +58,7 @@ type alias Program userModel userMsg pageData actionData sharedData errorPage =
58
58
  mainView :
59
59
  ProgramConfig userMsg userModel route pageData actionData sharedData effect (Msg userMsg pageData actionData sharedData errorPage) errorPage
60
60
  -> Model userModel pageData actionData sharedData
61
- -> { title : String, body : Html (Pages.Msg.Msg userMsg) }
61
+ -> { title : String, body : List (Html (Pages.Msg.Msg userMsg)) }
62
62
  mainView config model =
63
63
  case model.notFound of
64
64
  Just info ->
@@ -95,7 +95,7 @@ mainView config model =
95
95
  Err error ->
96
96
  { title = "Page Data Error"
97
97
  , body =
98
- Html.div [] [ Html.text error ]
98
+ [ Html.div [] [ Html.text error ] ]
99
99
  }
100
100
 
101
101
 
@@ -124,9 +124,9 @@ view config model =
124
124
  { title = title
125
125
  , body =
126
126
  [ onViewChangeElement model.url
127
- , body |> Html.map UserMsg
128
127
  , AriaLiveAnnouncer.view model.ariaNavigationAnnouncement
129
128
  ]
129
+ ++ List.map (Html.map UserMsg) body
130
130
  }
131
131
 
132
132
 
@@ -65,7 +65,7 @@ type alias ProgramConfig userMsg userModel route pageData actionData sharedData
65
65
  -> pageData
66
66
  -> Maybe actionData
67
67
  ->
68
- { view : userModel -> { title : String, body : Html (Pages.Msg.Msg userMsg) }
68
+ { view : userModel -> { title : String, body : List (Html (Pages.Msg.Msg userMsg)) }
69
69
  , head : List Head.Tag
70
70
  }
71
71
  , handleRoute : route -> DataSource (Maybe NotFoundReason)