Skip to content

Commit

Permalink
feat: use runtime constant for repository URL (#158)
Browse files Browse the repository at this point in the history
Co-authored-by: Anthony Fu <[email protected]>
  • Loading branch information
Archetipo95 and antfu authored Aug 20, 2024
1 parent 228afad commit facdc5c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
3 changes: 2 additions & 1 deletion components/PanelDocs.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<script setup lang="ts">
import type { NavItem, ParsedContent } from '@nuxt/content'
const runtime = useRuntimeConfig()
const {
navigation,
page,
Expand Down Expand Up @@ -58,7 +59,7 @@ const ui = useUiState()
const sourceUrl = computed(() =>
page.value?._file
? `https://github.com/nuxt/learn.nuxt.com/edit/main/content/${page.value._file}`
? `${runtime.public.repoUrl}/edit/main/content/${page.value._file}`
: undefined,
)
Expand Down
7 changes: 3 additions & 4 deletions components/TheNav.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ const guide = useGuideStore()
const runtime = useRuntimeConfig()
const commands = useCommandsStore()
const repo = 'https://github.com/nuxt/learn.nuxt.com'
const buildTime = new Date(runtime.public.buildTime)
const timeAgo = useTimeAgo(buildTime)
Expand Down Expand Up @@ -53,7 +52,7 @@ addCommands(
<NuxtTutorialLogo h-2em />
</NuxtLink>
<NuxtLink
:href="repo"
:href="runtime.public.repoUrl"
target="_blank"
>
<div block translate-y--2 rounded bg-orange:10 px2 py1 text-xs text-orange>
Expand Down Expand Up @@ -94,7 +93,7 @@ addCommands(
<template #popper>
<div px5 py4 grid="~ gap-y-3 gap-x-2 cols-[max-content_1fr] items-center">
<div i-ph-package-duotone text-xl />
<NuxtLink :to="`${repo}/commit/${runtime.public.gitSha}`" target="_blank" title="View on GitHub">
<NuxtLink :to="`${runtime.public.repoUrl}/commit/${runtime.public.gitSha}`" target="_blank" title="View on GitHub">
<time :datetime="buildTime.toISOString()" :title="buildTime.toLocaleString()">
Built {{ timeAgo }} (<code>{{ runtime.public.gitSha.slice(0, 5) }}</code>)
</time>
Expand All @@ -116,7 +115,7 @@ addCommands(
rounded p2
title="GitHub"
hover="bg-active"
:href="repo"
:href="runtime.public.repoUrl"
target="_blank"
>
<div i-carbon-logo-github text-2xl />
Expand Down
1 change: 1 addition & 0 deletions nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ export default defineNuxtConfig({
public: {
buildTime: Date.now(),
gitSha: execaSync('git', ['rev-parse', 'HEAD']).stdout.trim(),
repoUrl: 'https://github.com/nuxt/learn.nuxt.com',
},
app: {
devtools: {
Expand Down

0 comments on commit facdc5c

Please sign in to comment.