Skip to content

Commit 14229dc

Browse files
authored
setup router (#10)
1 parent f61ca83 commit 14229dc

File tree

11 files changed

+37
-24
lines changed

11 files changed

+37
-24
lines changed

.eslintrc.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ module.exports = {
2626
plugins: ['svelte3', '@typescript-eslint'],
2727
rules: {
2828
'no-multiple-empty-lines': 'off',
29-
'no-undef': 'off'
29+
'no-undef': 'off',
30+
'no-use-before-define': 'off'
3031
}
3132
}

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@
5353
},
5454
"dependencies": {
5555
"@lottiefiles/svelte-lottie-player": "^0.2.0",
56-
"sirv-cli": "^1.0.0"
56+
"sirv-cli": "^1.0.0",
57+
"svelte-spa-router": "^3.1.0"
5758
},
5859
"jest": {
5960
"transform": {

src/App.svelte

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
11
<script lang="ts">
2-
import { Navbar } from './components'
3-
import { Home } from './pages'
2+
import Router from 'svelte-spa-router'
3+
// import { Navbar } from './components'
4+
import { Home, Question, NotFound } from './pages'
5+
6+
const routes = {
7+
'/': Home,
8+
'/question': Question,
9+
'*': NotFound
10+
}
411
</script>
512

6-
<Navbar/>
7-
<Home/>
13+
<!--<Navbar/>-->
14+
<Router {routes}/>

src/components/HeaderInformation/HeaderInformation.svelte

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<script lang="ts">
2+
import { link } from 'svelte-spa-router'
23
import { Button, ButtonInverse } from '../../components'
34
</script>
45

@@ -9,7 +10,7 @@
910
In publishing and graphic design, Lorem ipsum is a placeholder text commonly used to demonstrate the visual form of a document or a typeface.
1011
</div>
1112
<div class="header-buttons">
12-
<Button label="Questions"/>
13+
<a href="/question" use:link><Button label="Questions"/></a>
1314
<span class="button-spacing">
1415
<ButtonInverse label="About"/>
1516
</span>
@@ -53,6 +54,6 @@
5354
}
5455
5556
.button-spacing {
56-
margin-left: 1rem;
57+
margin-left: 1rem;
5758
}
58-
</style>
59+
</style>

src/pages/Home/Home.stories.svelte

Lines changed: 0 additions & 15 deletions
This file was deleted.

src/pages/NotFound/NotFound.svelte

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<h1>404</h1>

src/pages/NotFound/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { default as NotFound } from './NotFound.svelte'

src/pages/Question/Question.svelte

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<h1>question</h1>

src/pages/Question/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { default as Question } from './Question.svelte'

src/pages/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
export { Home } from './Home'
2+
export { NotFound } from './NotFound'
3+
export { Question } from './Question'

yarn.lock

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9456,6 +9456,11 @@ regexp.prototype.flags@^1.3.1:
94569456
call-bind "^1.0.2"
94579457
define-properties "^1.1.3"
94589458

9459+
9460+
version "1.3.0"
9461+
resolved "https://registry.yarnpkg.com/regexparam/-/regexparam-1.3.0.tgz#2fe42c93e32a40eff6235d635e0ffa344b92965f"
9462+
integrity sha512-6IQpFBv6e5vz1QAqI+V4k8P2e/3gRrqfCJ9FI+O1FLQTO+Uz6RXZEZOPmTJ6hlGj7gkERzY5BRCv09whKP96/g==
9463+
94599464
regexpp@^3.0.0, regexpp@^3.1.0:
94609465
version "3.1.0"
94619466
resolved "https://registry.yarnpkg.com/regexpp/-/regexpp-3.1.0.tgz#206d0ad0a5648cffbdb8ae46438f3dc51c9f78e2"
@@ -10584,6 +10589,13 @@ svelte-preprocess@^4.0.0:
1058410589
detect-indent "^6.0.0"
1058510590
strip-indent "^3.0.0"
1058610591

10592+
svelte-spa-router@^3.1.0:
10593+
version "3.1.0"
10594+
resolved "https://registry.yarnpkg.com/svelte-spa-router/-/svelte-spa-router-3.1.0.tgz#a929f0def7e12c41f32bc356f91685aeadcd75bf"
10595+
integrity sha512-jlM/xwjn57mylr+pzHYCOOy+IPQauT46gOucNGTBu6jHcFXu3F+oaojN4PXC1LYizRGxFB6QA0qnYbZnRfX7Sg==
10596+
dependencies:
10597+
regexparam "1.3.0"
10598+
1058710599
svelte@^3.37.0:
1058810600
version "3.37.0"
1058910601
resolved "https://registry.yarnpkg.com/svelte/-/svelte-3.37.0.tgz#dc7cd24bcc275cdb3f8c684ada89e50489144ccd"

0 commit comments

Comments
 (0)