Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: use runtime constant for repository URL #158

Merged
merged 5 commits into from
Aug 20, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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'
antfu marked this conversation as resolved.
Show resolved Hide resolved
},
app: {
devtools: {
Expand Down
Loading