Skip to content

Commit ae8f512

Browse files
authored
Improve tab navigation and search results (#89)
* improve tab navigation and search results * why are you dying
1 parent 4cea9c1 commit ae8f512

13 files changed

Lines changed: 30 additions & 24 deletions

File tree

gen_search_indexes.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ for await (const file of matchingFiles) {
3232
const strippedMarkdown = RemoveMarkdown(contentNoHtml)
3333
.replaceAll(/:::.*/g, "")
3434
.replaceAll(/:::/g, "") // remove admonitions
35-
.replaceAll(/[^\S\r\n]{2,}/g); // remove extra spaces
35+
.replaceAll(/[^\S\r\n]{2,}/g, ""); // remove extra spaces
3636

3737
const tags = frontmatter.data.tags || "";
3838

gen_search_indexes_node.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ const matchingFiles = fg.stream("**/+page.svx", { dot: true });
1919

2020
// read all routes
2121
for await (const file of matchingFiles) {
22-
2322
const rawContent = await readFile(file);
2423

2524
log.info("Transforming", file);
@@ -30,8 +29,9 @@ for await (const file of matchingFiles) {
3029
// add to posts
3130
const contentNoHtml = stripHtml(frontmatter.content).result;
3231
const strippedMarkdown = RemoveMarkdown(contentNoHtml)
33-
.replace(/:::.*/, "")
34-
.replace(/:::/, "") // remove admonitions
32+
.replaceAll(/:::.*/g, "")
33+
.replaceAll(/:::/g, "") // remove admonitions
34+
.replaceAll(/[^\S\r\n]{2,}/g, ""); // remove extra spaces
3535

3636
const tags = frontmatter.data.tags || "";
3737

@@ -42,7 +42,7 @@ for await (const file of matchingFiles) {
4242
url: "/" + filePath,
4343
tags: tags
4444
.split(",")
45-
.map((el) => el.trim())
45+
.map(el => el.trim())
4646
.filter(String),
4747
});
4848
}

src/lib/MDLayout.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
"https://instagram.com/datapackhub",
3838
]} />
3939

40-
<main class="md px-4 md:px-8 lg:px-16 prose-headings:text-stone-200">
40+
<main class="md px-4 md:px-8 lg:px-16 prose-headings:text-stone-200" id="main_content">
4141
{#if version}
4242
<Version {version} />
4343
{/if}

src/lib/Topbar.svelte

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,18 @@
4747
<svelte:window onkeydown={e => handleKeyInput(e)} />
4848

4949
<div class="bg-stone-800 flex w-full items-center justify-between p-2 h-12 sticky top-0 border-b border-stone-700 z-20">
50+
<a
51+
class="absolute -translate-y-30 -translate-x-1/2 left-1/2 focus:outline-2 outline-blue-500 focus:translate-y-0"
52+
href="#nav_side">Go To Nav</a>
53+
<a
54+
class="absolute -translate-y-30 -translate-x-1/2 left-1/2 focus:outline-2 outline-blue-500 focus:translate-y-0"
55+
href="#main_content">Go To Content</a>
5056
<div class="flex items-center grow">
5157
<button
52-
class="px-2 pr-3 sm:hidden"
58+
class="px-2 pr-3 sm:hidden focus:outline-2 focus:outline-dph-orange"
5359
aria-label="{windowInfo.isNavOpen ? 'Collapse' : 'Expand'} Sidebar"
5460
onclick={() => (windowInfo.isNavOpen = !windowInfo.isNavOpen)}><IconMenu /></button>
55-
<a class="flex items-center hover:text-white p-1" href="/">
61+
<a class="flex items-center hover:text-white p-1 focus:outline-2 focus:outline-dph-orange" href="/">
5662
<img
5763
alt="Datapack Hub Logo"
5864
src="/logos/dph.svg"
@@ -66,21 +72,21 @@
6672
<div class="flex items-center gap-2">
6773
<a
6874
href="https://github.com/Datapack-Hub/wiki/blob/main/src/routes{page.url.pathname}/%2Bpage.svx"
69-
class="bg-black/45 p-2 rounded-lg py-1 flex items-center gap-2 hover:text-stone-100 aspect-square sm:aspect-auto"
75+
class="bg-black/45 p-2 rounded-lg py-1 flex items-center gap-2 hover:text-stone-100 aspect-square sm:aspect-auto focus:outline-2 focus:outline-dph-orange"
7076
aria-label="Edit">
7177
<IconEdit />
7278
<span class="hidden sm:block">Edit</span>
7379
</a>
7480
<button
75-
class="bg-black/45 p-2 rounded-lg py-1 flex items-center gap-2 hover:text-stone-100 aspect-square sm:aspect-auto"
81+
class="bg-black/45 p-2 rounded-lg py-1 flex items-center gap-2 hover:text-stone-100 aspect-square sm:aspect-auto focus:outline-2 focus:outline-dph-orange"
7682
aria-label="Copy URL"
7783
onclick={copyUrl}>
7884
<IconShare />
7985
<span class="hidden sm:block">{shareText}</span>
8086
</button>
8187
<a
8288
href="https://discord.gg/xHTHbZqXr6"
83-
class="bg-black/45 p-2 rounded-lg py-1 flex items-center gap-2 hover:text-stone-100 aspect-square sm:aspect-auto"
89+
class="bg-black/45 p-2 rounded-lg py-1 flex items-center gap-2 hover:text-stone-100 aspect-square sm:aspect-auto focus:outline-2 focus:outline-dph-orange"
8490
aria-label="Discord">
8591
<IconDiscord />
8692
<span class="hidden sm:block">Discord</span>

src/lib/sidebar/SearchBox.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
<button
1616
aria-label="Open Search Modal"
17-
class="bg-black/45 px-2 py-1 rounded-lg flex justify-between items-center mt-1 mb-2 w-full"
17+
class="bg-black/45 px-2 py-1 rounded-lg flex justify-between items-center mt-1 mb-2 w-full focus:outline-2 focus:outline-dph-orange"
1818
onclick={async () => await dialog.showModal()}>
1919
<div class="flex items-center gap-2">
2020
<IconSearch />

src/lib/sidebar/Sidebar.svelte

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,14 @@
4141
class="{windowInfo.isNavOpen
4242
? 'fixed w-full sm:w-80'
4343
: 'w-fit hidden sm:flex'} flex flex-col bg-stone-800 items-center h-[calc(100dvh-3rem)] sm:sticky top-12 z-50 border-r border-stone-700">
44-
<div class="flex flex-col p-2 pt-1 grow overflow-y-auto w-full">
44+
<div class="flex flex-col p-2 pt-1 grow overflow-y-auto w-full" id="nav_side">
4545
{#if windowInfo.isNavOpen}
4646
<SearchBox keyActivated />
4747
<div class="flex items-center mb-2 gap-1">
4848
<button
4949
class="{page == 'wiki'
5050
? 'bg-stone-700'
51-
: 'bg-stone-800'} hover:text-stone-400 px-2 py-1 rounded-md flex items-center gap-1"
51+
: 'bg-stone-800'} hover:text-stone-400 px-2 py-1 rounded-md flex items-center gap-1 focus:outline-2 focus:outline-dph-orange"
5252
onclick={() => {
5353
page = "wiki";
5454
sessionStorage.setItem("page", "wiki");
@@ -58,7 +58,7 @@
5858
<button
5959
class="{page == 'guides'
6060
? 'bg-stone-700'
61-
: 'bg-stone-800'} hover:text-stone-400 px-2 py-1 rounded-md flex items-center gap-1"
61+
: 'bg-stone-800'} hover:text-stone-400 px-2 py-1 rounded-md flex items-center gap-1 focus:outline-2 focus:outline-dph-orange"
6262
onclick={() => {
6363
page = "guides";
6464
sessionStorage.setItem("page", "guides");
@@ -91,7 +91,7 @@
9191
{/if}
9292
<button
9393
aria-label="{windowInfo.isNavOpen ? 'Collapse' : 'Expand'} Sidebar"
94-
class="hidden sm:block text-stone-200 text-lg motion-safe:transition-all {windowInfo.isNavOpen
94+
class="hidden sm:block text-stone-200 text-lg motion-safe:transition-all focus:outline-2 focus:outline-dph-orange {windowInfo.isNavOpen
9595
? 'rotate-0'
9696
: 'rotate-180'}"
9797
onclick={() => (windowInfo.isNavOpen = !windowInfo.isNavOpen)}>

src/lib/sidebar/navigation/SidebarCategory.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
<details ontoggle={() => (windowInfo.isNavOpen = true)} class="w-full group marker:hidden">
1818
<summary
19-
class="rounded-lg cursor-pointer p-1 w-full flex gap-2 items-center text-left hover:bg-stone-700 hover:text-white hover:font-medium marker:hidden">
19+
class="rounded-lg cursor-pointer p-1 w-full flex gap-2 items-center text-left hover:bg-stone-700 hover:text-white hover:font-medium marker:hidden focus:outline-2 focus:outline-dph-orange">
2020
<Icon />
2121
{#if windowInfo.isNavOpen}
2222
<span class="grow">{name}</span>

src/lib/sidebar/navigation/SidebarPage.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<a
1616
href={page}
1717
onclick={() => (windowInfo.width < 768 ? (windowInfo.isNavOpen = !windowInfo.isNavOpen) : null)}
18-
class="hover:bg-stone-700 hover:text-white hover:font-medium py-1 rounded-lg flex gap-2 pl-1 items-center">
18+
class="hover:bg-stone-700 hover:text-white hover:font-medium py-1 rounded-lg flex gap-2 pl-1 items-center focus:outline-2 focus:outline-dph-orange">
1919
<Icon />
2020

2121
{#if windowInfo.isNavOpen}

src/routes/+error.svx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<script lang="ts">
22
import { page } from "$app/state";
3-
import {Version, Discord} from '$lib/reusables';
3+
import { Discord} from '$lib/reusables';
44

55
let messages = new Map([
66
[404, "This page does not exist. It might have been removed, or never existed in the first place. Try searching for the page you need, or if this page should exist, let us know in our discord (use the link below)"],
@@ -9,5 +9,5 @@
99
</script>
1010

1111
# Error {page.status}: {page.error?.message}
12-
{messages.get($page.status)}
12+
{messages.get(page.status)}
1313
<Discord />

src/routes/+page.svx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
---
2+
title: Home
23
description: "Welcome to the Datapack Wiki, a resource for everything related to Minecraft Datapacks. We've got guides, tutorials, and documentation to help you build your knowledge about data packs."
34
---
45

0 commit comments

Comments
 (0)