Skip to content

Commit e1bdfb2

Browse files
committed
feat: edit in VS Code button for local runs
1 parent 79a71f7 commit e1bdfb2

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

.vitepress/config.mts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ import apiSidebar from '../content/api/sidebar.json'
33
import mainSidebar from '../content/sidebar'
44
import nav from './nav'
55
import './theme/cliLanguage'
6+
import path from 'node:path'
7+
8+
const isDev = process.env.NODE_ENV !== 'production'
9+
const branch = process.env.CF_PAGES_BRANCH ?? 'main'
610

711
export default defineConfig({
812
srcDir: './content',
@@ -15,10 +19,14 @@ export default defineConfig({
1519
appearance: false,
1620
themeConfig: {
1721
editLink: {
22+
...(isDev && {
23+
text: 'Edit in VS Code',
24+
}),
1825
// pattern:
1926
// 'https://github.com/NativeScript/docs/blob/main/content/:filePath',
20-
pattern:
21-
'https://pr.new/github.com/NativeScript/docs/edit/main/content/:filePath?initialPath=:path',
27+
pattern: isDev
28+
? `vscode://file/${path.resolve(__dirname, '../content/:filePath')}`
29+
: `https://pr.new/github.com/NativeScript/docs/edit/${branch}/content/:filePath?initialPath=:path`,
2230
},
2331
algolia: {
2432
appId: '',

.vitepress/theme/style.css

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

.vitepress/theme/vitepress-theme.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8735,7 +8735,7 @@ const fm = {
87358735
}, ym = {
87368736
key: 0,
87378737
class: "mb-2 text-base font-semibold leading-6 text-blue-500 dark:text-cyan-400"
8738-
}, _m = { class: "text-2xl font-bold tracking-tight text-slate-900 dark:text-slate-200 sm:text-4xl" }, bm = { class: "mt-2 text-lg text-slate-700 dark:text-slate-400" }, wm = { class: "hidden w-72 flex-none xl:block" }, Sm = { class: "h-sidebar sticky top-[72px] overflow-y-auto overflow-x-hidden" }, xm = { class: "pt-16 pb-10 pr-3" }, Om = ["href"], km = /* @__PURE__ */ L({
8738+
}, _m = { class: "text-2xl font-bold tracking-tight text-slate-900 dark:text-slate-200 sm:text-4xl" }, bm = { class: "mt-2 text-lg text-slate-700 dark:text-slate-400" }, wm = { class: "hidden w-72 flex-none xl:block" }, Sm = { class: "h-sidebar sticky top-[72px] overflow-y-auto overflow-x-hidden" }, xm = { class: "pt-16 pb-10 pr-3" }, Om = ["href", "target"], km = /* @__PURE__ */ L({
87398739
__name: "default",
87408740
setup(e) {
87418741
const { page: t } = De(), n = um(), r = Fn(), o = T(() => Yo(r.value)), i = T(() => o.value.find(
@@ -8778,7 +8778,7 @@ const fm = {
87788778
F(I2, { class: "mt-4" }),
87798779
h("a", {
87808780
href: P(n).url,
8781-
target: "_blank",
8781+
target: P(n).url.startsWith("http") ? "_blank" : "_self",
87828782
class: "mt-4 block rounded-md border border-gray-400 bg-white px-4 py-2 text-center text-sm text-gray-700 hover:border-gray-600 hover:text-gray-900 dark:border-white/20 dark:bg-transparent dark:text-white dark:hover:border-white/40"
87838783
}, V(P(n).text), 9, Om),
87848784
F(N2, { class: "mt-2" })

0 commit comments

Comments
 (0)