mirror of
https://github.com/dillonkearns/elm-pages-v3-beta.git
synced 2024-12-23 20:03:31 +03:00
Save skeleton app example.
This commit is contained in:
parent
b1af39c851
commit
fb65fbbad9
5
examples/hello/.gitignore
vendored
Normal file
5
examples/hello/.gitignore
vendored
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
node_modules/
|
||||||
|
elm-stuff/
|
||||||
|
dist/
|
||||||
|
.elm-pages/
|
||||||
|
functions/render/elm-pages-cli.js
|
1
examples/hello/README.md
Normal file
1
examples/hello/README.md
Normal file
@ -0,0 +1 @@
|
|||||||
|
# README
|
14
examples/hello/app/Api.elm
Normal file
14
examples/hello/app/Api.elm
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
module Api exposing (routes)
|
||||||
|
|
||||||
|
import ApiRoute
|
||||||
|
import DataSource exposing (DataSource)
|
||||||
|
import Html exposing (Html)
|
||||||
|
import Route exposing (Route)
|
||||||
|
|
||||||
|
|
||||||
|
routes :
|
||||||
|
DataSource (List Route)
|
||||||
|
-> (Html Never -> String)
|
||||||
|
-> List (ApiRoute.ApiRoute ApiRoute.Response)
|
||||||
|
routes getStaticRoutes htmlToString =
|
||||||
|
[]
|
86
examples/hello/app/Page/Index.elm
Normal file
86
examples/hello/app/Page/Index.elm
Normal file
@ -0,0 +1,86 @@
|
|||||||
|
module Page.Index exposing (Data, Model, Msg, page)
|
||||||
|
|
||||||
|
import DataSource exposing (DataSource)
|
||||||
|
import Head
|
||||||
|
import Head.Seo as Seo
|
||||||
|
import Html
|
||||||
|
import Html.Attributes as Attr
|
||||||
|
import Page exposing (Page, StaticPayload)
|
||||||
|
import Pages.PageUrl exposing (PageUrl)
|
||||||
|
import Pages.Url
|
||||||
|
import Shared
|
||||||
|
import View exposing (View)
|
||||||
|
|
||||||
|
|
||||||
|
type alias Model =
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
type alias Msg =
|
||||||
|
()
|
||||||
|
|
||||||
|
|
||||||
|
type alias RouteParams =
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
type alias Data =
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
page : Page RouteParams Data
|
||||||
|
page =
|
||||||
|
Page.single
|
||||||
|
{ head = head
|
||||||
|
, data = data
|
||||||
|
}
|
||||||
|
|> Page.buildNoState { view = view }
|
||||||
|
|
||||||
|
|
||||||
|
data : DataSource Data
|
||||||
|
data =
|
||||||
|
DataSource.succeed {}
|
||||||
|
|
||||||
|
|
||||||
|
head :
|
||||||
|
StaticPayload Data RouteParams
|
||||||
|
-> List Head.Tag
|
||||||
|
head static =
|
||||||
|
Seo.summary
|
||||||
|
{ canonicalUrlOverride = Nothing
|
||||||
|
, siteName = "elm-pages"
|
||||||
|
, image =
|
||||||
|
{ url = Pages.Url.external "TODO"
|
||||||
|
, alt = "elm-pages logo"
|
||||||
|
, dimensions = Nothing
|
||||||
|
, mimeType = Nothing
|
||||||
|
}
|
||||||
|
, description = "TODO"
|
||||||
|
, locale = Nothing
|
||||||
|
, title = "elm-pages is running"
|
||||||
|
}
|
||||||
|
|> Seo.website
|
||||||
|
|
||||||
|
|
||||||
|
view :
|
||||||
|
Maybe PageUrl
|
||||||
|
-> Shared.Model
|
||||||
|
-> StaticPayload Data RouteParams
|
||||||
|
-> View Msg
|
||||||
|
view maybeUrl sharedModel static =
|
||||||
|
{ title = "elm-pages is running"
|
||||||
|
, body =
|
||||||
|
[ Html.h1 [] [ Html.text "elm-pages is up and running!" ]
|
||||||
|
, Html.h2 [] [ Html.text "Learn more" ]
|
||||||
|
, Html.ul
|
||||||
|
[]
|
||||||
|
[ Html.li []
|
||||||
|
[ Html.a [ Attr.href "https://elm-pages.com/docs/" ] [ Html.text "Framework documentation" ]
|
||||||
|
]
|
||||||
|
, Html.li
|
||||||
|
[]
|
||||||
|
[ Html.a [ Attr.href "https://package.elm-lang.org/packages/dillonkearns/elm-pages/latest/" ] [ Html.text "Elm package documentation" ]
|
||||||
|
]
|
||||||
|
]
|
||||||
|
]
|
||||||
|
}
|
100
examples/hello/app/Shared.elm
Normal file
100
examples/hello/app/Shared.elm
Normal file
@ -0,0 +1,100 @@
|
|||||||
|
module Shared exposing (Data, Model, Msg(..), SharedMsg(..), template)
|
||||||
|
|
||||||
|
import Browser.Navigation
|
||||||
|
import DataSource
|
||||||
|
import Html exposing (Html)
|
||||||
|
import Pages.Flags
|
||||||
|
import Pages.PageUrl exposing (PageUrl)
|
||||||
|
import Path exposing (Path)
|
||||||
|
import Route exposing (Route)
|
||||||
|
import SharedTemplate exposing (SharedTemplate)
|
||||||
|
import View exposing (View)
|
||||||
|
|
||||||
|
|
||||||
|
template : SharedTemplate Msg Model Data msg
|
||||||
|
template =
|
||||||
|
{ init = init
|
||||||
|
, update = update
|
||||||
|
, view = view
|
||||||
|
, data = data
|
||||||
|
, subscriptions = subscriptions
|
||||||
|
, onPageChange = Just OnPageChange
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
type Msg
|
||||||
|
= OnPageChange
|
||||||
|
{ path : Path
|
||||||
|
, query : Maybe String
|
||||||
|
, fragment : Maybe String
|
||||||
|
}
|
||||||
|
| SharedMsg SharedMsg
|
||||||
|
|
||||||
|
|
||||||
|
type alias Data =
|
||||||
|
()
|
||||||
|
|
||||||
|
|
||||||
|
type SharedMsg
|
||||||
|
= NoOp
|
||||||
|
|
||||||
|
|
||||||
|
type alias Model =
|
||||||
|
{ showMobileMenu : Bool
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
init :
|
||||||
|
Maybe Browser.Navigation.Key
|
||||||
|
-> Pages.Flags.Flags
|
||||||
|
->
|
||||||
|
Maybe
|
||||||
|
{ path :
|
||||||
|
{ path : Path
|
||||||
|
, query : Maybe String
|
||||||
|
, fragment : Maybe String
|
||||||
|
}
|
||||||
|
, metadata : route
|
||||||
|
, pageUrl : Maybe PageUrl
|
||||||
|
}
|
||||||
|
-> ( Model, Cmd Msg )
|
||||||
|
init navigationKey flags maybePagePath =
|
||||||
|
( { showMobileMenu = False }
|
||||||
|
, Cmd.none
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
update : Msg -> Model -> ( Model, Cmd Msg )
|
||||||
|
update msg model =
|
||||||
|
case msg of
|
||||||
|
OnPageChange _ ->
|
||||||
|
( { model | showMobileMenu = False }, Cmd.none )
|
||||||
|
|
||||||
|
SharedMsg globalMsg ->
|
||||||
|
( model, Cmd.none )
|
||||||
|
|
||||||
|
|
||||||
|
subscriptions : Path -> Model -> Sub Msg
|
||||||
|
subscriptions _ _ =
|
||||||
|
Sub.none
|
||||||
|
|
||||||
|
|
||||||
|
data : DataSource.DataSource Data
|
||||||
|
data =
|
||||||
|
DataSource.succeed ()
|
||||||
|
|
||||||
|
|
||||||
|
view :
|
||||||
|
Data
|
||||||
|
->
|
||||||
|
{ path : Path
|
||||||
|
, route : Maybe Route
|
||||||
|
}
|
||||||
|
-> Model
|
||||||
|
-> (Msg -> msg)
|
||||||
|
-> View msg
|
||||||
|
-> { body : Html msg, title : String }
|
||||||
|
view sharedData page model toMsg pageView =
|
||||||
|
{ body = Html.div [] pageView.body
|
||||||
|
, title = pageView.title
|
||||||
|
}
|
35
examples/hello/app/Site.elm
Normal file
35
examples/hello/app/Site.elm
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
module Site exposing (config)
|
||||||
|
|
||||||
|
import DataSource exposing (DataSource)
|
||||||
|
import Head
|
||||||
|
import Pages.Manifest as Manifest
|
||||||
|
import Route
|
||||||
|
import SiteConfig exposing (SiteConfig)
|
||||||
|
|
||||||
|
|
||||||
|
type alias Data =
|
||||||
|
()
|
||||||
|
|
||||||
|
|
||||||
|
config : SiteConfig
|
||||||
|
config =
|
||||||
|
{ canonicalUrl = "https://elm-pages.com"
|
||||||
|
, head = head
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
head : DataSource (List Head.Tag)
|
||||||
|
head =
|
||||||
|
[ Head.sitemapLink "/sitemap.xml"
|
||||||
|
]
|
||||||
|
|> DataSource.succeed
|
||||||
|
|
||||||
|
|
||||||
|
manifest : Data -> Manifest.Config
|
||||||
|
manifest static =
|
||||||
|
Manifest.init
|
||||||
|
{ name = "Site Name"
|
||||||
|
, description = "Description"
|
||||||
|
, startUrl = Route.Index |> Route.toPath
|
||||||
|
, icons = []
|
||||||
|
}
|
23
examples/hello/app/View.elm
Normal file
23
examples/hello/app/View.elm
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
module View exposing (View, map, placeholder)
|
||||||
|
|
||||||
|
import Html exposing (Html)
|
||||||
|
|
||||||
|
|
||||||
|
type alias View msg =
|
||||||
|
{ title : String
|
||||||
|
, body : List (Html msg)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
map : (msg1 -> msg2) -> View msg1 -> View msg2
|
||||||
|
map fn doc =
|
||||||
|
{ title = doc.title
|
||||||
|
, body = List.map (Html.map fn) doc.body
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
placeholder : String -> View msg
|
||||||
|
placeholder moduleName =
|
||||||
|
{ title = "Placeholder - " ++ moduleName
|
||||||
|
, body = [ Html.text moduleName ]
|
||||||
|
}
|
9
examples/hello/elm-tooling.json
Normal file
9
examples/hello/elm-tooling.json
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"entrypoints": [
|
||||||
|
"./src/Main.elm"
|
||||||
|
],
|
||||||
|
"tools": {
|
||||||
|
"elm": "0.19.1",
|
||||||
|
"elm-format": "0.8.5"
|
||||||
|
}
|
||||||
|
}
|
64
examples/hello/elm.json
Normal file
64
examples/hello/elm.json
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
{
|
||||||
|
"type": "application",
|
||||||
|
"source-directories": [
|
||||||
|
"src",
|
||||||
|
"app",
|
||||||
|
"../../src",
|
||||||
|
".elm-pages",
|
||||||
|
"../../plugins"
|
||||||
|
],
|
||||||
|
"elm-version": "0.19.1",
|
||||||
|
"dependencies": {
|
||||||
|
"direct": {
|
||||||
|
"MartinSStewart/elm-serialize": "1.2.5",
|
||||||
|
"avh4/elm-color": "1.0.0",
|
||||||
|
"danfishgold/base64-bytes": "1.1.0",
|
||||||
|
"danyx23/elm-mimetype": "4.0.1",
|
||||||
|
"dillonkearns/elm-bcp47-language-tag": "1.0.1",
|
||||||
|
"dillonkearns/elm-markdown": "6.0.1",
|
||||||
|
"elm/browser": "1.0.2",
|
||||||
|
"elm/bytes": "1.0.8",
|
||||||
|
"elm/core": "1.0.5",
|
||||||
|
"elm/html": "1.0.0",
|
||||||
|
"elm/http": "2.0.0",
|
||||||
|
"elm/json": "1.1.3",
|
||||||
|
"elm/parser": "1.1.0",
|
||||||
|
"elm/random": "1.0.0",
|
||||||
|
"elm/regex": "1.0.0",
|
||||||
|
"elm/time": "1.0.0",
|
||||||
|
"elm/url": "1.0.0",
|
||||||
|
"elm/virtual-dom": "1.0.2",
|
||||||
|
"elm-community/dict-extra": "2.4.0",
|
||||||
|
"elm-community/list-extra": "8.3.0",
|
||||||
|
"elm-community/result-extra": "2.4.0",
|
||||||
|
"elm-explorations/test": "1.2.2",
|
||||||
|
"jgrenat/elm-html-test-runner": "1.0.3",
|
||||||
|
"jluckyiv/elm-utc-date-strings": "1.0.0",
|
||||||
|
"lamdera/codecs": "1.0.0",
|
||||||
|
"lamdera/core": "1.0.0",
|
||||||
|
"matheus23/elm-default-tailwind-modules": "2.0.1",
|
||||||
|
"miniBill/elm-codec": "2.0.0",
|
||||||
|
"noahzgordon/elm-color-extra": "1.0.2",
|
||||||
|
"pablohirafuji/elm-syntax-highlight": "3.4.0",
|
||||||
|
"robinheghan/fnv1a": "1.0.0",
|
||||||
|
"robinheghan/murmur3": "1.0.0",
|
||||||
|
"rtfeldman/elm-css": "16.1.1",
|
||||||
|
"tripokey/elm-fuzzy": "5.2.1",
|
||||||
|
"turboMaCk/non-empty-list-alias": "1.2.0",
|
||||||
|
"vito/elm-ansi": "10.0.1",
|
||||||
|
"zwilias/json-decode-exploration": "6.0.0"
|
||||||
|
},
|
||||||
|
"indirect": {
|
||||||
|
"bburdette/toop": "1.0.1",
|
||||||
|
"elm/file": "1.0.5",
|
||||||
|
"elm-community/maybe-extra": "5.3.0",
|
||||||
|
"fredcy/elm-parseint": "2.0.1",
|
||||||
|
"mgold/elm-nonempty-list": "4.2.0",
|
||||||
|
"rtfeldman/elm-hex": "1.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"test-dependencies": {
|
||||||
|
"direct": {},
|
||||||
|
"indirect": {}
|
||||||
|
}
|
||||||
|
}
|
10
examples/hello/netlify.toml
Normal file
10
examples/hello/netlify.toml
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
[build]
|
||||||
|
functions = "functions/"
|
||||||
|
publish = "dist/"
|
||||||
|
command = "export ELM_HOME=\"$NETLIFY_BUILD_BASE/cache/elm\" && npm install --no-optional && npm run build"
|
||||||
|
|
||||||
|
[dev]
|
||||||
|
command = "npm start"
|
||||||
|
targetPort = 1234
|
||||||
|
autoLaunch = true
|
||||||
|
framework = "#custom"
|
3060
examples/hello/package-lock.json
generated
Normal file
3060
examples/hello/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
14
examples/hello/package.json
Normal file
14
examples/hello/package.json
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
{
|
||||||
|
"name": "elm-pages-app",
|
||||||
|
"scripts": {
|
||||||
|
"postinstall": "elm-tooling install",
|
||||||
|
"start": "elm-pages dev",
|
||||||
|
"build": "elm-pages build"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"elm-optimize-level-2": "^0.3.4",
|
||||||
|
"elm-pages": "file:../..",
|
||||||
|
"elm-review": "^2.7.0",
|
||||||
|
"elm-tooling": "^1.7.0"
|
||||||
|
}
|
||||||
|
}
|
12
examples/hello/public/index.js
Normal file
12
examples/hello/public/index.js
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
/** @typedef {{load: (Promise<unknown>); flags: (unknown)}} ElmPagesInit */
|
||||||
|
|
||||||
|
/** @type ElmPagesInit */
|
||||||
|
export default {
|
||||||
|
load: async function (elmLoaded) {
|
||||||
|
const app = await elmLoaded;
|
||||||
|
console.log("App loaded", app);
|
||||||
|
},
|
||||||
|
flags: function () {
|
||||||
|
return "You can decode this in Shared.elm using Json.Decode.string!";
|
||||||
|
},
|
||||||
|
};
|
4
examples/hello/public/style.css
Normal file
4
examples/hello/public/style.css
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
body {
|
||||||
|
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial,
|
||||||
|
sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user