mirror of
https://github.com/daylinmorgan/nimpkgs.git
synced 2024-12-21 18:50:43 -06:00
feat: add proper 404 page
This commit is contained in:
parent
dccb441088
commit
62dfd6ff17
4 changed files with 30 additions and 8 deletions
18
site/404.html
Normal file
18
site/404.html
Normal file
|
@ -0,0 +1,18 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8"/>
|
||||
<meta content="width=device-width, initial-scale=1" name="viewport"/>
|
||||
<link rel="icon" href="img/logo-crown.svg" type="image/svg+xml">
|
||||
<title>nimpkgs</title>
|
||||
<link href="uno.css" rel="stylesheet" type="text/css">
|
||||
<!--
|
||||
<link href="https://fonts.googleapis.com/css2?family=Recursive:slnt,wght,CASL,CRSV,MONO@-15..0,300..800,0..1,0..1,1&display=swap" rel="stylesheet">
|
||||
-->
|
||||
<link href="https://fonts.googleapis.com/css2?family=Recursive:wght,CASL,MONO@300..1000,0..1,1&display=swap" rel="stylesheet">
|
||||
</head>
|
||||
<body id="body" class="text-ctp-text max-w-screen bg-ctp-base">
|
||||
<div id="ROOT"></div>
|
||||
<script type="text/javascript" src="app.js"></script>
|
||||
</body>
|
||||
</html>
|
13
src/app.nim
13
src/app.nim
|
@ -1,17 +1,20 @@
|
|||
import std/strutils
|
||||
import karax/[karax, karaxdsl, vdom]
|
||||
|
||||
import components/[header, button, footer]
|
||||
import pages/pages
|
||||
import context
|
||||
import jsconsole
|
||||
import context, utils
|
||||
|
||||
proc render(data: RouterData): VNode =
|
||||
console.log ctx
|
||||
result = buildHtml(tdiv(class = "lg:w-3/4 max-w-[90%] mx-auto md:text-lg text-sm min-h-screen flex flex-col")):
|
||||
var uri = currentUri()
|
||||
result = buildHtml(tdiv(
|
||||
class = "lg:w-3/4 max-w-[90%] mx-auto md:text-lg text-sm min-h-screen flex flex-col")
|
||||
):
|
||||
headerBar()
|
||||
tdiv(class = "mb-5"):
|
||||
if not ctx.loaded:
|
||||
if uri.path != "/" and not uri.path.startsWith("#"):
|
||||
notfound.render()
|
||||
elif not ctx.loaded:
|
||||
tdiv(class = "flex h-50"):
|
||||
tdiv(class = "mx-auto my-auto lds-dual-ring")
|
||||
else:
|
||||
|
|
|
@ -50,8 +50,7 @@ proc searchPackages*(q: Query): seq[NimPackage] =
|
|||
result.add pkg
|
||||
|
||||
proc getSearchFromUri*(): kstring =
|
||||
var url = initUri()
|
||||
parseUri($window.location.href, url)
|
||||
var url = currentUri()
|
||||
if url.query == "": return ""
|
||||
for k, v in decodeQuery(url.query):
|
||||
if k == "query":
|
||||
|
|
|
@ -14,13 +14,15 @@ proc noProtocol*(s: kstring): kstring =
|
|||
.replace("https://", "")
|
||||
.jss
|
||||
|
||||
proc currentUri*(): Uri {.inline.} =
|
||||
parseUri($window.location.href)
|
||||
|
||||
func replace*(c: kstring, sub: string, by = " "): kstring =
|
||||
($c).replace(sub, by).jss
|
||||
|
||||
proc setSearchUrl*(searchQuery: kstring): proc() =
|
||||
proc() =
|
||||
var url = parseUri($window.location.href)
|
||||
var url = currentUri()
|
||||
url.anchor = "/search"
|
||||
url = url ? {"query": $searchQuery}
|
||||
window.history.pushState(js{}, "".jss, url.jss)
|
||||
|
|
Loading…
Reference in a new issue