Skip to content

Commit effdca1

Browse files
committed
Initial commit
1 parent 722a9d8 commit effdca1

17 files changed

+411
-0
lines changed

.gitignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/bower_components/
2+
/node_modules/
3+
/.pulp-cache/
4+
/output/
5+
/generated-docs/
6+
/.psc-package/
7+
/.psc*
8+
/.purs*
9+
/.psa*
10+
/.spago

package.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"name": "purescript-nextjs",
3+
"version": "1.0.0",
4+
"description": "",
5+
"main": "index.js",
6+
"scripts": {
7+
"test": "echo \"Error: no test specified\" && exit 1"
8+
},
9+
"keywords": [],
10+
"author": "",
11+
"license": "ISC"
12+
}

packages.dhall

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
{-
2+
Welcome to your new Dhall package-set!
3+
4+
Below are instructions for how to edit this file for most use
5+
cases, so that you don't need to know Dhall to use it.
6+
7+
## Use Cases
8+
9+
Most will want to do one or both of these options:
10+
1. Override/Patch a package's dependency
11+
2. Add a package not already in the default package set
12+
13+
This file will continue to work whether you use one or both options.
14+
Instructions for each option are explained below.
15+
16+
### Overriding/Patching a package
17+
18+
Purpose:
19+
- Change a package's dependency to a newer/older release than the
20+
default package set's release
21+
- Use your own modified version of some dependency that may
22+
include new API, changed API, removed API by
23+
using your custom git repo of the library rather than
24+
the package set's repo
25+
26+
Syntax:
27+
where `entityName` is one of the following:
28+
- dependencies
29+
- repo
30+
- version
31+
-------------------------------
32+
let upstream = --
33+
in upstream
34+
with packageName.entityName = "new value"
35+
-------------------------------
36+
37+
Example:
38+
-------------------------------
39+
let upstream = --
40+
in upstream
41+
with halogen.version = "master"
42+
with halogen.repo = "https://example.com/path/to/git/repo.git"
43+
44+
with halogen-vdom.version = "v4.0.0"
45+
with halogen-vdom.dependencies = [ "extra-dependency" ] # halogen-vdom.dependencies
46+
-------------------------------
47+
48+
### Additions
49+
50+
Purpose:
51+
- Add packages that aren't already included in the default package set
52+
53+
Syntax:
54+
where `<version>` is:
55+
- a tag (i.e. "v4.0.0")
56+
- a branch (i.e. "master")
57+
- commit hash (i.e. "701f3e44aafb1a6459281714858fadf2c4c2a977")
58+
-------------------------------
59+
let upstream = --
60+
in upstream
61+
with new-package-name =
62+
{ dependencies =
63+
[ "dependency1"
64+
, "dependency2"
65+
]
66+
, repo =
67+
"https://example.com/path/to/git/repo.git"
68+
, version =
69+
"<version>"
70+
}
71+
-------------------------------
72+
73+
Example:
74+
-------------------------------
75+
let upstream = --
76+
in upstream
77+
with benchotron =
78+
{ dependencies =
79+
[ "arrays"
80+
, "exists"
81+
, "profunctor"
82+
, "strings"
83+
, "quickcheck"
84+
, "lcg"
85+
, "transformers"
86+
, "foldable-traversable"
87+
, "exceptions"
88+
, "node-fs"
89+
, "node-buffer"
90+
, "node-readline"
91+
, "datetime"
92+
, "now"
93+
]
94+
, repo =
95+
"https://github.com/hdgarrood/purescript-benchotron.git"
96+
, version =
97+
"v7.0.0"
98+
}
99+
-------------------------------
100+
-}
101+
let upstream =
102+
https://github.com/purescript/package-sets/releases/download/psc-0.15.4-20220822/packages.dhall
103+
sha256:908b4ffbfba37a0a4edf806513a555d0dbcdd0cde7abd621f8d018d2e8ecf828
104+
105+
in upstream

spago.dhall

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{-
2+
Welcome to a Spago project!
3+
You can edit this file as you like.
4+
5+
Need help? See the following resources:
6+
- Spago documentation: https://github.com/purescript/spago
7+
- Dhall language tour: https://docs.dhall-lang.org/tutorials/Language-Tour.html
8+
9+
When creating a new Spago project, you can use
10+
`spago init --no-comments` or `spago init -C`
11+
to generate this file without the comments in this block.
12+
-}
13+
{ name = "my-project"
14+
, dependencies =
15+
[ "aff-promise"
16+
, "console"
17+
, "effect"
18+
, "functions"
19+
, "nullable"
20+
, "prelude"
21+
, "react-basic"
22+
, "react-basic-hooks"
23+
]
24+
, packages = ./packages.dhall
25+
, sources = [ "src/**/*.purs", "test/**/*.purs" ]
26+
}

src/Next/Document.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import document from "next/document";
2+
export var _html = document.Html;
3+
export var _head = document.Head;
4+
export var _main = document.Main;
5+
export var _nextScript = document.NextScript;

src/Next/Document.purs

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
module Next.Document where
2+
3+
import Prim.Row (class Union)
4+
import React.Basic.Hooks (JSX, ReactComponent, element)
5+
6+
-- | Components
7+
type Props_html =
8+
( children :: Array JSX
9+
)
10+
11+
html
12+
:: forall attrs attrs_
13+
. Union attrs attrs_ Props_html
14+
=> Record attrs
15+
-> JSX
16+
html attrs = element _html attrs
17+
18+
foreign import _html :: forall attrs. ReactComponent attrs
19+
20+
type Props_head =
21+
( children :: Array JSX
22+
, nonce :: String
23+
, crossOrigin :: String
24+
)
25+
26+
head
27+
:: forall attrs attrs_
28+
. Union attrs attrs_ Props_head
29+
=> Record attrs
30+
-> JSX
31+
head attrs = element _head attrs
32+
33+
foreign import _head :: forall attrs. ReactComponent attrs
34+
35+
type Props_main =
36+
( children :: Array JSX
37+
)
38+
39+
main
40+
:: forall attrs attrs_
41+
. Union attrs attrs_ Props_main
42+
=> Record attrs
43+
-> JSX
44+
main attrs = element _main attrs
45+
46+
foreign import _main :: forall attrs. ReactComponent attrs
47+
48+
type Props_nextScript =
49+
( children :: Array JSX
50+
, nonce :: String
51+
, crossOrigin :: String
52+
)
53+
54+
nextScript
55+
:: forall attrs attrs_
56+
. Union attrs attrs_ Props_nextScript
57+
=> Record attrs
58+
-> JSX
59+
nextScript attrs = element _nextScript attrs
60+
61+
foreign import _nextScript :: forall attrs. ReactComponent attrs

src/Next/Head.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import React from "react";
2+
import head from "next/head";
3+
4+
function onlyReactElement(list, child) {
5+
if (typeof child === 'string' || typeof child === 'number') {
6+
return list;
7+
}
8+
if (child.type === React.Fragment) {
9+
return list.concat(React.Children.toArray(child.props.children).reduce((fragmentList, fragmentChild) => {
10+
if (typeof fragmentChild === 'string' || typeof fragmentChild === 'number') {
11+
return fragmentList;
12+
}
13+
return fragmentList.concat(fragmentChild);
14+
}, []));
15+
}
16+
return list.concat(child);
17+
}
18+
19+
export function _head(props) {
20+
var children = React.Children.toArray(props.children)
21+
.reduce(onlyReactElement, [])
22+
.map(child => {
23+
if(typeof child.type === 'object' && child.type.render) {
24+
return child.type.render(Object.assign({ key: child.key }, child.props), child.ref)
25+
}
26+
else { return child }
27+
})
28+
return head({children })
29+
}

src/Next/Head.purs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
module Next.Head where
2+
3+
import Prim.Row (class Union)
4+
import React.Basic.Hooks (JSX, ReactComponent, element)
5+
6+
type Props_head =
7+
( children :: Array JSX
8+
)
9+
10+
head
11+
:: forall attrs attrs_
12+
. Union attrs attrs_ Props_head
13+
=> Record attrs
14+
-> JSX
15+
head attrs = element _head attrs
16+
17+
foreign import _head :: forall attrs. ReactComponent attrs

src/Next/Link.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { default as _link} from "next/link"

src/Next/Link.purs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
module Next.Link where
2+
3+
import Prim.Row (class Union)
4+
import React.Basic.Hooks (JSX, ReactComponent, element)
5+
6+
type Props_link =
7+
( children :: JSX
8+
, href :: String
9+
, as :: String
10+
, passHref :: Boolean
11+
, prefetch :: Boolean
12+
, replace :: Boolean
13+
, scroll :: Boolean
14+
, shallow :: Boolean
15+
)
16+
17+
link
18+
:: forall attrs attrs_
19+
. Union attrs attrs_ Props_link
20+
=> Record attrs
21+
-> JSX
22+
link attrs = element _link attrs
23+
24+
foreign import _link :: forall attrs. ReactComponent attrs

0 commit comments

Comments
 (0)