feat: add hyperlinks to version table

This commit is contained in:
Daylin Morgan 2024-02-07 15:02:55 -06:00
parent ce29752426
commit f2d39c58dc
Signed by: daylin
GPG key ID: C1E52E7DD81DF79F
4 changed files with 29 additions and 5 deletions

View file

@ -9,4 +9,9 @@ task build, "build":
exec "pnpm run build" exec "pnpm run build"
task watch, "rebuild on change": task watch, "rebuild on change":
exec "watchexec -w src nim js -d:packagesHash:master -o:site/app.js src/app.nim" exec (
"watchexec " &
"--project-origin . -w src " &
"nim js -d:packagesHash:master -o:site/app.js src/app.nim"
)

View file

@ -1,10 +1,11 @@
import std/[ import std/[
algorithm, asyncjs, algorithm, asyncjs,
strutils, sugar, tables, times strutils, sugar, tables, times, uri
] ]
import karax/[kbase] import karax/[kbase]
import jsony import jsony
import ./utils
export algorithm, tables, times, asyncjs, sugar export algorithm, tables, times, asyncjs, sugar
proc parseHook*(s: string, i: var int, v: var kstring) = proc parseHook*(s: string, i: var int, v: var kstring) =
@ -69,3 +70,14 @@ proc sortVersion*(a, b: NimPackage): int =
proc isAlias*(p: NimPackage): bool {.inline.} = p.alias != "" proc isAlias*(p: NimPackage): bool {.inline.} = p.alias != ""
proc canonicalUrl*(p: NimPackage): kstring =
var uri = parseUri($p.url)
uri.path = uri.path.replace(".git")
# NOTE: why do I use this?
if uri.path[^1] == '/':
uri.path = uri.path[0..^2]
uri.query = ""
return uri.jss

View file

@ -1,11 +1,15 @@
import std/[algorithm, sugar] import std/[algorithm, sugar]
import karax/[kbase, karaxdsl, vdom, jstrutils] import karax/[kbase, karax, karaxdsl, kdom, vdom, jstrutils, ]
import ../[context, packages, style] import ../[context, packages, style]
import ../components/[tag, package] import ../components/[tag, package]
import ../utils import ../utils
import notfound import notfound
proc openLink(link: kstring): proc() =
result = proc() =
discard open(window, link, "_self")
proc versionTable(pkg: NimPackage): VNode = proc versionTable(pkg: NimPackage): VNode =
var versions = pkg.versions var versions = pkg.versions
versions.sort((a, b: Version) => cmp(a.time, b.time), order = Descending) versions.sort((a, b: Version) => cmp(a.time, b.time), order = Descending)
@ -17,7 +21,10 @@ proc versionTable(pkg: NimPackage): VNode =
th: text "released" th: text "released"
th: text "hash" th: text "hash"
for version in versions: for version in versions:
tr: tr(
onClick = openLink(pkg.canonicalUrl & "/tree/" & version.tag.jss),
class = "link"
):
td: text version.tag td: text version.tag
td: text version.time.format("yyyy-MM-dd") td: text version.time.format("yyyy-MM-dd")
td: text ($version.hash)[0..8] td: text ($version.hash)[0..8]

View file

@ -43,7 +43,7 @@ export default defineConfig({
color: ${catppuccinColors.mauve}; color: ${catppuccinColors.mauve};
cursor: pointer; cursor: pointer;
} }
// loading animation /* loading animation */
.lds-dual-ring { .lds-dual-ring {
display: inline-block; display: inline-block;
width: 80px; width: 80px;