Switch to single page application #2
5 changed files with 44 additions and 10 deletions
12
src/components/content.nim
Normal file
12
src/components/content.nim
Normal file
|
@ -0,0 +1,12 @@
|
|||
# Import HappyX
|
||||
import happyx
|
||||
|
||||
|
||||
# Declare component
|
||||
component Content:
|
||||
# Declare HTML template
|
||||
`template`:
|
||||
tDiv(class = "p-10"):
|
||||
"read"
|
||||
`script`:
|
||||
echo "Start coding!"
|
13
src/components/index.nim
Normal file
13
src/components/index.nim
Normal file
|
@ -0,0 +1,13 @@
|
|||
# Import HappyX
|
||||
import happyx
|
||||
|
||||
|
||||
# Declare component
|
||||
component Index:
|
||||
# Declare HTML template
|
||||
`template`:
|
||||
tDiv(class = "p-10"):
|
||||
tH1():
|
||||
"Blog in a Matrix"
|
||||
`script`:
|
||||
echo "Start coding!"
|
|
@ -6,8 +6,14 @@ import happyx
|
|||
component Nav:
|
||||
# Declare HTML template
|
||||
`template`:
|
||||
# tDiv(class = "", id=""):
|
||||
tNav(class="nav"):
|
||||
"Hello, world!"
|
||||
`script`:
|
||||
echo "Start coding!"
|
||||
tNav(class="bg-black w-48 text-white text-center"):
|
||||
tDiv():
|
||||
"Title"
|
||||
tA():
|
||||
"button"
|
||||
tA():
|
||||
"button"
|
||||
tA():
|
||||
"button"
|
||||
tA():
|
||||
"button"
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
</head>
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
<div id="app" class="relative min-h-screen flex"></div>
|
||||
<script src="main.js"></script>
|
||||
</body>
|
||||
</html>
|
11
src/main.nim
11
src/main.nim
|
@ -2,10 +2,13 @@
|
|||
import
|
||||
happyx,
|
||||
path_params,
|
||||
components/[navigation]
|
||||
components/[navigation, index, content]
|
||||
|
||||
# Declare application with ID "app"
|
||||
appRoutes("app"):
|
||||
"/":
|
||||
# Component usage
|
||||
component Nav
|
||||
component Nav
|
||||
component Index
|
||||
|
||||
"/read":
|
||||
component Nav
|
||||
component Content
|
||||
|
|
Loading…
Add table
Reference in a new issue