Skip to content

Commit 0fef0a3

Browse files
committed
feat: add view source button
1 parent 148bd22 commit 0fef0a3

File tree

4 files changed

+24
-6
lines changed

4 files changed

+24
-6
lines changed

src/component/LucideIcon.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
Search as SearchIcon,
66
ZoomIn,
77
RefreshCcwDot,
8+
Code2,
89
} from 'lucide'
910
import { For } from 'solid-js'
1011
import { Dynamic } from 'solid-js/web'
@@ -55,3 +56,7 @@ export const AddToSearch = (props: LucideProps) => (
5556
export const AppUpdateRequired = (props: LucideProps) => (
5657
<LucideIcon icon={RefreshCcwDot} {...props} />
5758
)
59+
60+
export const ViewSourceIcon = (props: LucideProps) => (
61+
<LucideIcon icon={Code2} {...props} />
62+
)

src/component/Sidebar.tsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
Sidebar as AppUpdateRequiredSidebar,
99
} from './AppUpdate.jsx'
1010
import { DeviceSidebar } from './DeviceSidebar.js'
11-
import { Search, Warning } from './LucideIcon.js'
11+
import { Search, ViewSourceIcon, Warning } from './LucideIcon.js'
1212
import { Sidebar as SearchSidebar } from './Search.js'
1313
import './Sidebar.css'
1414
import { WIPSidebar } from './WIPSidebar.jsx'
@@ -41,6 +41,7 @@ const SidebarNav = () => (
4141
<DeviceDetailButton />
4242
<WarningButton />
4343
<AppUpdateRequiredButton />
44+
<ViewSourceButton />
4445
</nav>
4546
)
4647

@@ -103,3 +104,12 @@ const WarningButton = () => {
103104
</>
104105
)
105106
}
107+
108+
const ViewSourceButton = () => (
109+
<>
110+
<a class="button" href={REPOSITORY_URL} target="_blank">
111+
<ViewSourceIcon strokeWidth={2} />
112+
</a>
113+
<hr />
114+
</>
115+
)

src/vite-env.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ declare const BUILD_TIME: string
44
declare const REGISTRY_ENDPOINT: string
55
// Base URL of the site without a trailing slash
66
declare const BASE_URL: string
7+
declare const REPOSITORY_URL: string

vite.config.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
import { fromEnv } from '@nordicsemiconductor/from-env'
2-
import fs from 'fs'
32
import { defineConfig } from 'vite'
43
import solidPlugin from 'vite-plugin-solid'
5-
import path from 'node:path'
64
import { trimTrailingSlash } from './src/util/trimTrailingSlash.js'
5+
import pJson from './package.json'
76

8-
const { version: defaultVersion, homepage } = JSON.parse(
9-
fs.readFileSync(path.join(process.cwd(), 'package.json'), 'utf-8'),
10-
)
7+
const {
8+
version: defaultVersion,
9+
homepage,
10+
repository: { url: repositoryUrl },
11+
} = pJson
1112
const version = process.env.VERSION ?? defaultVersion
1213
const { registryEndpoint } = fromEnv({
1314
registryEndpoint: 'REGISTRY_ENDPOINT',
@@ -34,5 +35,6 @@ export default defineConfig({
3435
BUILD_TIME: JSON.stringify(new Date().toISOString()),
3536
REGISTRY_ENDPOINT: JSON.stringify(new URL(registryEndpoint).toString()),
3637
BASE_URL: JSON.stringify(base),
38+
REPOSITORY_URL: JSON.stringify(repositoryUrl.replace('git+', '')),
3739
},
3840
})

0 commit comments

Comments
 (0)