Skip to content

Commit 96beabe

Browse files
authored
Merge branch 'main' into fix-search
2 parents b17f1a9 + c6d9d3c commit 96beabe

File tree

7 files changed

+153
-19
lines changed

7 files changed

+153
-19
lines changed

app/components/AppFooter.vue

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
<script setup lang="ts">
22
const route = useRoute()
33
const isHome = computed(() => route.name === 'index')
4+
5+
const modalRef = useTemplateRef('modalRef')
6+
const showModal = () => modalRef.value?.showModal?.()
47
</script>
58

69
<template>
@@ -33,6 +36,73 @@ const isHome = computed(() => route.name === 'index')
3336
<LinkBase to="https://chat.npmx.dev">
3437
{{ $t('footer.chat') }}
3538
</LinkBase>
39+
40+
<button
41+
type="button"
42+
class="group inline-flex gap-x-1 items-center justify-center underline-offset-[0.2rem] underline decoration-1 decoration-fg/30 font-mono text-fg hover:(decoration-accent text-accent) focus-visible:(decoration-accent text-accent) transition-colors duration-200"
43+
@click.prevent="showModal"
44+
aria-haspopup="dialog"
45+
>
46+
{{ $t('footer.keyboard_shortcuts') }}
47+
</button>
48+
49+
<Modal
50+
ref="modalRef"
51+
:modalTitle="$t('footer.keyboard_shortcuts')"
52+
class="w-auto max-w-lg"
53+
>
54+
<p class="mb-2 font-mono text-fg-subtle">
55+
{{ $t('shortcuts.section.global') }}
56+
</p>
57+
<ul class="mb-6 flex flex-col gap-2">
58+
<li class="flex gap-2 items-center">
59+
<kbd class="kbd">/</kbd>
60+
<span>{{ $t('shortcuts.focus_search') }}</span>
61+
</li>
62+
<li class="flex gap-2 items-center">
63+
<kbd class="kbd">?</kbd>
64+
<span>{{ $t('shortcuts.show_kbd_hints') }}</span>
65+
</li>
66+
<li class="flex gap-2 items-center">
67+
<kbd class="kbd">,</kbd>
68+
<span>{{ $t('shortcuts.settings') }}</span>
69+
</li>
70+
<li class="flex gap-2 items-center">
71+
<kbd class="kbd">c</kbd>
72+
<span>{{ $t('shortcuts.compare') }}</span>
73+
</li>
74+
</ul>
75+
<p class="mb-2 font-mono text-fg-subtle">
76+
{{ $t('shortcuts.section.search') }}
77+
</p>
78+
<ul class="mb-6 flex flex-col gap-2">
79+
<li class="flex gap-2 items-center">
80+
<kbd class="kbd">↑</kbd>/<kbd class="kbd">↓</kbd>
81+
<span>{{ $t('shortcuts.navigate_results') }}</span>
82+
</li>
83+
<li class="flex gap-2 items-center">
84+
<kbd class="kbd">Enter</kbd>
85+
<span>{{ $t('shortcuts.go_to_result') }}</span>
86+
</li>
87+
</ul>
88+
<p class="mb-2 font-mono text-fg-subtle">
89+
{{ $t('shortcuts.section.package') }}
90+
</p>
91+
<ul class="mb-6 flex flex-col gap-2">
92+
<li class="flex gap-2 items-center">
93+
<kbd class="kbd">.</kbd>
94+
<span>{{ $t('shortcuts.open_code_view') }}</span>
95+
</li>
96+
<li class="flex gap-2 items-center">
97+
<kbd class="kbd">d</kbd>
98+
<span>{{ $t('shortcuts.open_docs') }}</span>
99+
</li>
100+
<li class="flex gap-2 items-center">
101+
<kbd class="kbd">c</kbd>
102+
<span>{{ $t('shortcuts.compare_from_package') }}</span>
103+
</li>
104+
</ul>
105+
</Modal>
36106
</div>
37107
</div>
38108
<p class="text-xs text-fg-muted text-center sm:text-start m-0">
@@ -42,3 +112,9 @@ const isHome = computed(() => route.name === 'index')
42112
</div>
43113
</footer>
44114
</template>
115+
116+
<style scoped>
117+
.kbd {
118+
@apply items-center justify-center text-sm text-fg bg-bg-muted border border-border rounded px-2;
119+
}
120+
</style>

i18n/locales/en.json

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,24 @@
1515
"docs": "docs",
1616
"source": "source",
1717
"social": "social",
18-
"chat": "chat"
18+
"chat": "chat",
19+
"keyboard_shortcuts": "keyboard shortcuts"
20+
},
21+
"shortcuts": {
22+
"section": {
23+
"global": "Global",
24+
"search": "Search",
25+
"package": "Package"
26+
},
27+
"focus_search": "Focus search",
28+
"show_kbd_hints": "Highlight keyboard hints",
29+
"settings": "Open settings",
30+
"compare": "Open compare",
31+
"compare_from_package": "Open compare (prefilled with current package)",
32+
"navigate_results": "Navigate results",
33+
"go_to_result": "Go to result",
34+
"open_code_view": "Open code view",
35+
"open_docs": "Open docs"
1936
},
2037
"search": {
2138
"label": "Search npm packages",

lunaria/files/en-GB.json

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,24 @@
1515
"docs": "docs",
1616
"source": "source",
1717
"social": "social",
18-
"chat": "chat"
18+
"chat": "chat",
19+
"keyboard_shortcuts": "keyboard shortcuts"
20+
},
21+
"shortcuts": {
22+
"section": {
23+
"global": "Global",
24+
"search": "Search",
25+
"package": "Package"
26+
},
27+
"focus_search": "Focus search",
28+
"show_kbd_hints": "Highlight keyboard hints",
29+
"settings": "Open settings",
30+
"compare": "Open compare",
31+
"compare_from_package": "Open compare (prefilled with current package)",
32+
"navigate_results": "Navigate results",
33+
"go_to_result": "Go to result",
34+
"open_code_view": "Open code view",
35+
"open_docs": "Open docs"
1936
},
2037
"search": {
2138
"label": "Search npm packages",

lunaria/files/en-US.json

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,24 @@
1515
"docs": "docs",
1616
"source": "source",
1717
"social": "social",
18-
"chat": "chat"
18+
"chat": "chat",
19+
"keyboard_shortcuts": "keyboard shortcuts"
20+
},
21+
"shortcuts": {
22+
"section": {
23+
"global": "Global",
24+
"search": "Search",
25+
"package": "Package"
26+
},
27+
"focus_search": "Focus search",
28+
"show_kbd_hints": "Highlight keyboard hints",
29+
"settings": "Open settings",
30+
"compare": "Open compare",
31+
"compare_from_package": "Open compare (prefilled with current package)",
32+
"navigate_results": "Navigate results",
33+
"go_to_result": "Go to result",
34+
"open_code_view": "Open code view",
35+
"open_docs": "Open docs"
1936
},
2037
"search": {
2138
"label": "Search npm packages",

server/utils/atproto/oauth.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,10 @@ async function getOAuthSession(
6767
})
6868

6969
const currentSession = serverSession.data
70-
if (!currentSession) return { oauthSession: undefined, serverSession }
70+
// TODO (jg): why can a session be `{}`?
71+
if (!currentSession || !currentSession.public?.did) {
72+
return { oauthSession: undefined, serverSession }
73+
}
7174

7275
const oauthSession = await client.restore(currentSession.public.did)
7376
return { oauthSession, serverSession }

server/utils/docs/client.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
import { doc, type DocNode } from '@deno/doc'
1111
import type { DenoDocNode, DenoDocResult } from '#shared/types/deno-doc'
12+
import { isBuiltin } from 'node:module'
1213

1314
// =============================================================================
1415
// Configuration
@@ -81,12 +82,9 @@ function createLoader(): (
8182
_cacheSetting?: string,
8283
_checksum?: string,
8384
) => {
84-
let url: URL
85-
try {
86-
url = new URL(specifier)
87-
} catch (e) {
88-
// eslint-disable-next-line no-console
89-
console.error(e)
85+
const url = URL.parse(specifier)
86+
87+
if (url === null) {
9088
return undefined
9189
}
9290

@@ -139,7 +137,11 @@ function createResolver(): (specifier: string, referrer: string) => string {
139137
}
140138

141139
// Handle bare specifiers - resolve through esm.sh
142-
if (!specifier.startsWith('http://') && !specifier.startsWith('https://')) {
140+
if (
141+
!specifier.startsWith('http://') &&
142+
!specifier.startsWith('https://') &&
143+
!isBuiltin(specifier)
144+
) {
143145
// Try to resolve bare specifier relative to esm.sh base
144146
const baseUrl = new URL(referrer)
145147
if (baseUrl.hostname === 'esm.sh') {

shared/types/userSession.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
import type { NodeSavedSession, NodeSavedState } from '@atproto/oauth-client-node'
22

33
export interface UserServerSession {
4-
public: {
5-
did: string
6-
handle: string
7-
pds: string
8-
avatar?: string
9-
}
4+
public?:
5+
| {
6+
did: string
7+
handle: string
8+
pds: string
9+
avatar?: string
10+
}
11+
| undefined
1012
// Only to be used in the atproto session and state stores
1113
// Will need to change to Record<string, T> and add a current logged in user if we ever want to support
1214
// multiple did logins per server session
13-
oauthSession: NodeSavedSession | undefined
14-
oauthState: NodeSavedState | undefined
15+
oauthSession?: NodeSavedSession | undefined
16+
oauthState?: NodeSavedState | undefined
1517
}

0 commit comments

Comments
 (0)