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:
|
component Nav:
|
||||||
# Declare HTML template
|
# Declare HTML template
|
||||||
`template`:
|
`template`:
|
||||||
# tDiv(class = "", id=""):
|
tNav(class="bg-black w-48 text-white text-center"):
|
||||||
tNav(class="nav"):
|
tDiv():
|
||||||
"Hello, world!"
|
"Title"
|
||||||
`script`:
|
tA():
|
||||||
echo "Start coding!"
|
"button"
|
||||||
|
tA():
|
||||||
|
"button"
|
||||||
|
tA():
|
||||||
|
"button"
|
||||||
|
tA():
|
||||||
|
"button"
|
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="app"></div>
|
<div id="app" class="relative min-h-screen flex"></div>
|
||||||
<script src="main.js"></script>
|
<script src="main.js"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
|
@ -2,10 +2,13 @@
|
||||||
import
|
import
|
||||||
happyx,
|
happyx,
|
||||||
path_params,
|
path_params,
|
||||||
components/[navigation]
|
components/[navigation, index, content]
|
||||||
|
|
||||||
# Declare application with ID "app"
|
|
||||||
appRoutes("app"):
|
appRoutes("app"):
|
||||||
"/":
|
"/":
|
||||||
# Component usage
|
|
||||||
component Nav
|
component Nav
|
||||||
|
component Index
|
||||||
|
|
||||||
|
"/read":
|
||||||
|
component Nav
|
||||||
|
component Content
|
||||||
|
|
Loading…
Add table
Reference in a new issue