This repository was archived by the owner on Oct 13, 2022. It is now read-only.
File tree 13 files changed +78
-127
lines changed
13 files changed +78
-127
lines changed Original file line number Diff line number Diff line change
1
+ < Nav page ={
2
+ props.path === '/ ' ? 'home' :
3
+ props.path === '/about ' ? 'about' :
4
+ props.path.startsWith('/blog') ? 'blog' :
5
+ null
6
+ }/>
7
+
8
+ < main >
9
+ < svelte:component this ={Page} {...props} />
10
+ </ main >
11
+
12
+ < style >
13
+ main {
14
+ position : relative;
15
+ max-width : 56em ;
16
+ background-color : white;
17
+ padding : 2em ;
18
+ margin : 0 auto;
19
+ box-sizing : border-box;
20
+ }
21
+ </ style >
22
+
23
+ < script >
24
+ import Nav from '../components/Nav.html' ;
25
+
26
+ export default {
27
+ components : {
28
+ Nav
29
+ }
30
+ } ;
31
+ </ script >
Original file line number Diff line number Diff line change 1
1
import { init } from 'sapper/runtime.js' ;
2
2
import { routes } from './manifest/client.js' ;
3
+ import App from './App.html' ;
3
4
4
- // `routes` is an array of route objects injected by Sapper
5
- init ( document . querySelector ( '#sapper' ) , routes ) ;
6
-
7
- if ( module . hot ) module . hot . accept ( ) ;
5
+ init ( {
6
+ target : document . querySelector ( '#sapper' ) ,
7
+ routes,
8
+ App
9
+ } ) ;
Original file line number Diff line number Diff line change @@ -3,11 +3,15 @@ import compression from 'compression';
3
3
import sapper from 'sapper' ;
4
4
import serve from 'serve-static' ;
5
5
import { routes } from './manifest/server.js' ;
6
+ import App from './App.html' ;
6
7
7
8
polka ( ) // You can also use Express
8
9
. use (
9
10
compression ( { threshold : 0 } ) ,
10
11
serve ( 'assets' ) ,
11
- sapper ( { routes } )
12
+ sapper ( {
13
+ routes,
14
+ App
15
+ } )
12
16
)
13
17
. listen ( process . env . PORT ) ;
Original file line number Diff line number Diff line change 6
6
color : # 333 ;
7
7
}
8
8
9
- main {
10
- position : relative;
11
- max-width : 56em ;
12
- background-color : white;
13
- padding : 2em ;
14
- margin : 0 auto;
15
- box-sizing : border-box;
16
- }
17
-
18
9
h1 , h2 , h3 , h4 , h5 , h6 {
19
10
margin : 0 0 0.5em 0 ;
20
11
font-weight : 400 ;
File renamed without changes.
Original file line number Diff line number Diff line change 6
6
"dev" : " sapper dev" ,
7
7
"build" : " sapper build" ,
8
8
"export" : " sapper export" ,
9
- "start" : " sapper start " ,
9
+ "start" : " node build " ,
10
10
"cy:run" : " cypress run" ,
11
11
"cy:open" : " cypress open" ,
12
12
"test" : " run-p --race dev cy:run"
13
13
},
14
14
"dependencies" : {
15
15
"compression" : " ^1.7.1" ,
16
- "npm-run-all" : " ^4.1.2" ,
17
16
"polka" : " ^0.3.4" ,
18
- "sapper" : " ^0.10.0" ,
19
- "serve-static" : " ^1.13.1" ,
17
+ "sapper" : " ^0.12.0" ,
18
+ "serve-static" : " ^1.13.1"
19
+ },
20
+ "devDependencies" : {
21
+ "npm-run-all" : " ^4.1.2" ,
20
22
"svelte" : " ^2.0.0" ,
21
- "svelte-loader" : " ^2.3.3 " ,
22
- "webpack" : " ^4.1 .0"
23
+ "svelte-loader" : " ^2.9.0 " ,
24
+ "webpack" : " ^4.7 .0"
23
25
}
24
26
}
Original file line number Diff line number Diff line change 2
2
< title > Not found</ title >
3
3
</ svelte:head >
4
4
5
- < Layout page ='home '>
6
- < h1 > Not found</ h1 >
5
+ < h1 > Not found</ h1 >
7
6
8
- < p > Please check the URL</ p >
9
- </ Layout >
7
+ < p > Please check the URL</ p >
10
8
11
9
< style >
12
10
h1 , p {
@@ -30,14 +28,4 @@ <h1>Not found</h1>
30
28
font-size : 4em ;
31
29
}
32
30
}
33
- </ style >
34
-
35
- < script >
36
- import Layout from './_components/Layout.html' ;
37
-
38
- export default {
39
- components : {
40
- Layout
41
- }
42
- } ;
43
- </ script >
31
+ </ style >
Original file line number Diff line number Diff line change 2
2
< title > Internal server error</ title >
3
3
</ svelte:head >
4
4
5
- < Layout page ='home '>
6
- < h1 > Internal server error</ h1 >
7
- </ Layout >
5
+ < h1 > Internal server error</ h1 >
8
6
9
7
< style >
10
8
h1 {
@@ -21,14 +19,4 @@ <h1>Internal server error</h1>
21
19
font-size : 4em ;
22
20
}
23
21
}
24
- </ style >
25
-
26
- < script >
27
- import Layout from './_components/Layout.html' ;
28
-
29
- export default {
30
- components : {
31
- Layout
32
- }
33
- } ;
34
- </ script >
22
+ </ style >
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 2
2
< title > About</ title >
3
3
</ svelte:head >
4
4
5
- < Layout page ='about '>
6
- < h1 > About this site</ h1 >
5
+ < h1 > About this site</ h1 >
7
6
8
- < p > This is the 'about' page. There's not much here.</ p >
9
- </ Layout >
10
-
11
- < script >
12
- import Layout from './_components/Layout.html' ;
13
-
14
- export default {
15
- components : {
16
- Layout
17
- }
18
- } ;
19
- </ script >
7
+ < p > This is the 'about' page. There's not much here.</ p >
Original file line number Diff line number Diff line change 2
2
< title > {post.title}</ title >
3
3
</ svelte:head >
4
4
5
- < Layout page ='blog '>
6
- < h1 > {post.title}</ h1 >
5
+ < h1 > {post.title}</ h1 >
7
6
8
- < div class ='content '>
9
- {@html post.html}
10
- </ div >
11
- </ Layout >
7
+ < div class ='content '>
8
+ {@html post.html}
9
+ </ div >
12
10
13
11
< style >
14
12
/*
@@ -47,13 +45,7 @@ <h1>{post.title}</h1>
47
45
</ style >
48
46
49
47
< script >
50
- import Layout from '../_components/Layout.html' ;
51
-
52
48
export default {
53
- components : {
54
- Layout
55
- } ,
56
-
57
49
preload ( { params, query } ) {
58
50
// the `slug` parameter is available because this file
59
51
// is called [slug].html
Original file line number Diff line number Diff line change 2
2
< title > Blog</ title >
3
3
</ svelte:head >
4
4
5
- < Layout page ='blog '>
6
- < h1 > Recent posts</ h1 >
5
+ < h1 > Recent posts</ h1 >
7
6
8
- < ul >
9
- {#each posts as post}
10
- <!-- we're using the non-standard `rel=prefetch` attribute to
11
- tell Sapper to load the data for the page as soon as
12
- the user hovers over the link or taps it, instead of
13
- waiting for the 'click' event -->
14
- < li > < a rel ='prefetch ' href ='blog/{post.slug} '> {post.title}</ a > </ li >
15
- {/each}
16
- </ ul >
17
- </ Layout >
7
+ < ul >
8
+ {#each posts as post}
9
+ <!-- we're using the non-standard `rel=prefetch` attribute to
10
+ tell Sapper to load the data for the page as soon as
11
+ the user hovers over the link or taps it, instead of
12
+ waiting for the 'click' event -->
13
+ < li > < a rel ='prefetch ' href ='blog/{post.slug} '> {post.title}</ a > </ li >
14
+ {/each}
15
+ </ ul >
18
16
19
17
< style >
20
18
ul {
@@ -24,13 +22,7 @@ <h1>Recent posts</h1>
24
22
</ style >
25
23
26
24
< script >
27
- import Layout from '../_components/Layout.html' ;
28
-
29
25
export default {
30
- components : {
31
- Layout
32
- } ,
33
-
34
26
preload ( { params, query } ) {
35
27
return this . fetch ( `blog.json` ) . then ( r => r . json ( ) ) . then ( posts => {
36
28
return { posts } ;
Original file line number Diff line number Diff line change 2
2
< title > Sapper project template</ title >
3
3
</ svelte:head >
4
4
5
- < Layout page ='home '>
6
- < h1 > Great success!</ h1 >
5
+ < h1 > Great success!</ h1 >
7
6
8
- < figure >
9
- < img alt ='Borat ' src ='great-success.png '>
10
- < figcaption > HIGH FIVE!</ figcaption >
11
- </ figure >
7
+ < figure >
8
+ < img alt ='Borat ' src ='great-success.png '>
9
+ < figcaption > HIGH FIVE!</ figcaption >
10
+ </ figure >
12
11
13
- < p > < strong > Try editing this file (routes/index.html) to test hot module reloading.</ strong > </ p >
14
- </ Layout >
12
+ < p > < strong > Try editing this file (routes/index.html) to test hot module reloading.</ strong > </ p >
15
13
16
14
< style >
17
15
h1 , figure , p {
@@ -45,14 +43,4 @@ <h1>Great success!</h1>
45
43
font-size : 4em ;
46
44
}
47
45
}
48
- </ style >
49
-
50
- < script >
51
- import Layout from './_components/Layout.html' ;
52
-
53
- export default {
54
- components : {
55
- Layout
56
- }
57
- } ;
58
- </ script >
46
+ </ style >
You can’t perform that action at this time.
0 commit comments