mirror of
https://github.com/daylinmorgan/nimpkgs.git
synced 2024-11-14 07:37:53 -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 std/strutils
|
||||||
import karax/[karax, karaxdsl, vdom]
|
import karax/[karax, karaxdsl, vdom]
|
||||||
|
|
||||||
import components/[header, button, footer]
|
import components/[header, button, footer]
|
||||||
import pages/pages
|
import pages/pages
|
||||||
import context
|
import context, utils
|
||||||
import jsconsole
|
|
||||||
|
|
||||||
proc render(data: RouterData): VNode =
|
proc render(data: RouterData): VNode =
|
||||||
console.log ctx
|
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()
|
headerBar()
|
||||||
tdiv(class = "mb-5"):
|
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 = "flex h-50"):
|
||||||
tdiv(class = "mx-auto my-auto lds-dual-ring")
|
tdiv(class = "mx-auto my-auto lds-dual-ring")
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -50,8 +50,7 @@ proc searchPackages*(q: Query): seq[NimPackage] =
|
||||||
result.add pkg
|
result.add pkg
|
||||||
|
|
||||||
proc getSearchFromUri*(): kstring =
|
proc getSearchFromUri*(): kstring =
|
||||||
var url = initUri()
|
var url = currentUri()
|
||||||
parseUri($window.location.href, url)
|
|
||||||
if url.query == "": return ""
|
if url.query == "": return ""
|
||||||
for k, v in decodeQuery(url.query):
|
for k, v in decodeQuery(url.query):
|
||||||
if k == "query":
|
if k == "query":
|
||||||
|
|
|
@ -14,13 +14,15 @@ proc noProtocol*(s: kstring): kstring =
|
||||||
.replace("https://", "")
|
.replace("https://", "")
|
||||||
.jss
|
.jss
|
||||||
|
|
||||||
|
proc currentUri*(): Uri {.inline.} =
|
||||||
|
parseUri($window.location.href)
|
||||||
|
|
||||||
func replace*(c: kstring, sub: string, by = " "): kstring =
|
func replace*(c: kstring, sub: string, by = " "): kstring =
|
||||||
($c).replace(sub, by).jss
|
($c).replace(sub, by).jss
|
||||||
|
|
||||||
proc setSearchUrl*(searchQuery: kstring): proc() =
|
proc setSearchUrl*(searchQuery: kstring): proc() =
|
||||||
proc() =
|
proc() =
|
||||||
var url = parseUri($window.location.href)
|
var url = currentUri()
|
||||||
url.anchor = "/search"
|
url.anchor = "/search"
|
||||||
url = url ? {"query": $searchQuery}
|
url = url ? {"query": $searchQuery}
|
||||||
window.history.pushState(js{}, "".jss, url.jss)
|
window.history.pushState(js{}, "".jss, url.jss)
|
||||||
|
|
Loading…
Reference in a new issue