Skip to content

Commit 8a5556e

Browse files
committed
feat: add a link to the GitHub source code
1 parent 4d4d62a commit 8a5556e

File tree

3 files changed

+82
-5
lines changed

3 files changed

+82
-5
lines changed

package-lock.json

Lines changed: 46 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,14 @@
1414
"dependencies": {
1515
"@astrojs/markdown-remark": "6.1.0",
1616
"@astrojs/svelte": "7.0.4",
17+
"@fortawesome/free-brands-svg-icons": "6.7.2",
18+
"@fortawesome/free-solid-svg-icons": "6.7.2",
1719
"@jsonquerylang/jsonquery": "4.1.1",
1820
"astro": "5.3.0",
1921
"fracturedjsonjs": "4.0.2",
2022
"rehype-autolink-headings": "7.1.0",
21-
"svelte": "5.20.1"
23+
"svelte": "5.20.1",
24+
"svelte-fa": "4.0.3"
2225
},
2326
"devDependencies": {
2427
"@biomejs/biome": "1.9.4",

src/components/Menu.astro

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,21 @@
11
---
2+
import { faGithub } from '@fortawesome/free-brands-svg-icons'
3+
import { faUpRightFromSquare } from '@fortawesome/free-solid-svg-icons'
4+
import Fa from 'svelte-fa'
5+
26
const currentPath = new URL(Astro.request.url).pathname
37
48
const pages = [
59
{ path: '/', text: 'Playground' },
610
{ path: '/docs/', text: 'Documentation' },
711
{ path: '/reference/', text: 'Function reference' },
8-
{ path: '/implementations/', text: 'Implementations' }
12+
{ path: '/implementations/', text: 'Implementations' },
13+
{
14+
path: 'https://github.com/orgs/jsonquerylang/',
15+
text: 'Source code',
16+
icon: faGithub,
17+
externalLink: true
18+
}
919
]
1020
1121
function isCurrentPath(path: string) {
@@ -15,8 +25,18 @@ function isCurrentPath(path: string) {
1525
---
1626

1727
<div class="menu">
18-
{pages.map(({path, text}) =>
19-
<a href={path} class={isCurrentPath(path) ? 'active' : ''}>{text}</a>
28+
{pages.map(({path, text, icon, externalLink }) =>
29+
<a
30+
href={path}
31+
class={isCurrentPath(path) ? 'active' : ''}
32+
target={externalLink ? '_blank' : undefined}
33+
>
34+
{icon && <Fa icon={icon} />}
35+
{text}
36+
{externalLink && <span class="external-link">
37+
<Fa icon={faUpRightFromSquare} />
38+
</span>}
39+
</a>
2040
)}
2141
</div>
2242

@@ -48,5 +68,14 @@ function isCurrentPath(path: string) {
4868
a.active:focus {
4969
background: var(--link-color-highlight);
5070
}
71+
72+
a .external-link {
73+
visibility: hidden;
74+
}
75+
76+
a:hover .external-link,
77+
a:active .external-link {
78+
visibility: visible;
79+
}
5180
}
5281
</style>

0 commit comments

Comments
 (0)