8000 feat: use runtime constant for repository URL (#158) · vuejs-jp/learn.nuxt.com@facdc5c · GitHub
[go: up one dir, main page]

Skip to content
This repository was archived by the owner on May 1, 2025. It is now read-only.

Commit facdc5c

Browse files
Archetipo95antfu
andauthored
feat: use runtime constant for repository URL (#158)
Co-authored-by: Anthony Fu <github@antfu.me>
1 parent 228afad commit facdc5c

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

components/PanelDocs.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<script setup lang="ts">
22
import type { NavItem, ParsedContent } from '@nuxt/content'
33
4+
const runtime = useRuntimeConfig()
45
const {
56
navigation,
67
page,
@@ -58,7 +59,7 @@ const ui = useUiState()
5859
5960
const sourceUrl = computed(() =>
6061
page.value?._file
61-
? `https://github.com/nuxt/learn.nuxt.com/edit/main/content/${page.value._file}`
62+
? `${runtime.public.repoUrl}/edit/main/content/${page.value._file}`
6263
: undefined,
6364
)
6465

components/TheNav.vue

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ const guide = useGuideStore()
55
const runtime = useRuntimeConfig()
66
const commands = useCommandsStore()
77
8-
const repo = 'https://github.com/nuxt/learn.nuxt.com'
98
const buildTime = new Date(runtime.public.buildTime)
109
const timeAgo = useTimeAgo(buildTime)
1110
@@ -53,7 +52,7 @@ addCommands(
5352
<NuxtTutorialLogo h-2em />
5453
</NuxtLink>
5554
<NuxtLink
56-
:href="repo"
55+
:href="runtime.public.repoUrl"
5756
target="_blank"
5857
>
5958
<div block translate-y--2 rounded bg-orange:10 px2 py1 text-xs text-orange>
@@ -94,7 +93,7 @@ addCommands(
9493
<template #popper>
9594
<div px5 py4 grid="~ gap-y-3 gap-x-2 cols-[max-content_1fr] items-center">
9695
<div i-ph-package-duotone text-xl />
97-
<NuxtLink :to="`${repo}/commit/${runtime.public.gitSha}`" target="_blank" title="View on GitHub">
96+
<NuxtLink :to="`${runtime.public.repoUrl}/commit/${runtime.public.gitSha}`" target="_blank" title="View on GitHub">
9897
<time :datetime="buildTime.toISOString()" :title="buildTime.toLocaleString()">
9998
Built {{ timeAgo }} (<code>{{ runtime.public.gitSha.slice(0, 5) }}</code>)
10099
</time>
@@ -116,7 +115,7 @@ addCommands(
116115
rounded p2
117116
title="GitHub"
118117
hover="bg-active"
119-
:href="repo"
118+
:href="runtime.public.repoUrl"
120119
target="_blank"
121120
>
122121
<div i-carbon-logo-github text-2xl />

nuxt.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ export default defineNuxtConfig({
6767
public: {
6868
buildTime: Date.now(),
6969
gitSha: execaSync('git', ['rev-parse', 'HEAD']).stdout.trim(),
70+
repoUrl: 'https://github.com/nuxt/learn.nuxt.com',
7071
},
7172
app: {
7273
devtools: {

0 commit comments

Comments
 (0)
0