File tree Expand file tree Collapse file tree
package-code/[[org]]/[packageName]/v/[version] Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -44,7 +44,8 @@ useHead({
4444})
4545
4646if (import .meta .server ) {
47- setJsonLd (createWebSiteSchema ())
47+ const { siteUrl } = useAppUrls ()
48+ setJsonLd (createWebSiteSchema (siteUrl ))
4849}
4950
5051onKeyDown (
Original file line number Diff line number Diff line change 11<script setup lang="ts">
2+ const { docsUrl } = useAppUrls ()
23const route = useRoute ()
34const isHome = computed (() => route .name === ' index' )
45
@@ -92,7 +93,7 @@ const showModal = () => modalRef.value?.showModal?.()
9293 </li >
9394 </ul >
9495 </Modal >
95- <LinkBase to =" https://docs.npmx.dev " >
96+ <LinkBase : to =" docsUrl " >
9697 {{ $t('footer.docs') }}
9798 </LinkBase >
9899 <LinkBase to =" https://repo.npmx.dev" >
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ withDefaults(
1212 },
1313)
1414
15+ const { docsUrl } = useAppUrls ()
1516const { isConnected, npmUser } = useConnector ()
1617
1718const desktopLinks = computed <NavigationConfig >(() => [
@@ -85,7 +86,7 @@ const mobileLinks = computed<NavigationConfigWithGroups>(() => [
8586 {
8687 name: ' Docs' ,
8788 label: $t (' footer.docs' ),
88- href: ' https://docs.npmx.dev ' ,
89+ href: docsUrl ,
8990 target: ' _blank' ,
9091 type: ' link' ,
9192 external: true ,
Original file line number Diff line number Diff line change @@ -27,9 +27,8 @@ function toggleSkill(dirName: string) {
2727type InstallMethod = ' skills-npm' | ' skills-cli'
2828const selectedMethod = ref <InstallMethod >(' skills-npm' )
2929
30- const baseUrl = computed (() =>
31- typeof window !== ' undefined' ? window .location .origin : ' https://npmx.dev' ,
32- )
30+ const { siteUrl } = useAppUrls ()
31+ const baseUrl = computed (() => (typeof window !== ' undefined' ? window .location .origin : siteUrl ))
3332
3433const installCommand = computed (() => {
3534 if (! props .skills .length ) return null
Original file line number Diff line number Diff line change 1+ import { NPMX_DOCS_SITE_PROD } from '#shared/utils/constants'
2+
3+ export function useAppUrls ( ) {
4+ const { env, siteUrl } = useAppConfig ( )
5+ return {
6+ siteUrl,
7+ // TODO(serhalp): Handle preview environment. The docs site is a separate deployment, so we'd
8+ // need to infer its preview URL from the site preview URL somehow...?
9+ docsUrl : env === 'dev' ? 'http://localhost:3001' : NPMX_DOCS_SITE_PROD ,
10+ }
11+ }
Original file line number Diff line number Diff line change @@ -18,11 +18,13 @@ export function setJsonLd(schema: WithContext<Thing> | WithContext<Thing>[]): vo
1818/**
1919 * Create WebSite schema with search action
2020 */
21- export function createWebSiteSchema ( options ?: {
22- name ?: string
23- description ?: string
24- } ) : WithContext < WebSite > {
25- const siteUrl = 'https://npmx.dev'
21+ export function createWebSiteSchema (
22+ siteUrl : string ,
23+ options ?: {
24+ name ?: string
25+ description ?: string
26+ } ,
27+ ) : WithContext < WebSite > {
2628 return {
2729 '@context' : 'https://schema.org' ,
2830 '@type' : 'WebSite' ,
Original file line number Diff line number Diff line change @@ -129,7 +129,8 @@ function handleClearFilter(chip: FilterChip) {
129129const activeTab = shallowRef <' members' | ' teams' >(' members' )
130130
131131// Canonical URL for this org page
132- const canonicalUrl = computed (() => ` https://npmx.dev/@${orgName .value } ` )
132+ const { siteUrl } = useAppUrls ()
133+ const canonicalUrl = computed (() => ` ${siteUrl }/@${orgName .value } ` )
133134
134135useHead ({
135136 link: [{ rel: ' canonical' , href: canonicalUrl }],
Original file line number Diff line number Diff line change @@ -249,7 +249,8 @@ function copyPermalinkUrl() {
249249}
250250
251251// Canonical URL for this code page
252- const canonicalUrl = computed (() => ` https://npmx.dev${getCodeUrl (route .params )} ` )
252+ const { siteUrl } = useAppUrls ()
253+ const canonicalUrl = computed (() => ` ${siteUrl }${getCodeUrl (route .params )} ` )
253254
254255// Toggle markdown view mode
255256const markdownViewModes = [
Original file line number Diff line number Diff line change @@ -471,8 +471,9 @@ const createPackageInfo = computed(() => {
471471})
472472
473473// Canonical URL for this package page
474+ const { siteUrl } = useAppUrls ()
474475const canonicalUrl = computed (() => {
475- const base = ` https://npmx.dev /package/${packageName .value }`
476+ const base = ` ${ siteUrl } /package/${packageName .value }`
476477 return requestedVersion .value ? ` ${base }/v/${requestedVersion .value } ` : base
477478})
478479
Original file line number Diff line number Diff line change 22
33import Git from 'simple-git'
44import * as process from 'node:process'
5+ import { NPMX_SITE_PROD } from '../shared/utils/constants'
56
67export { version } from '../package.json'
78
@@ -87,6 +88,11 @@ export const getProductionUrl = () =>
8788 : undefined
8889 : undefined
8990
91+ export const getSiteUrl = ( isDevelopment : boolean ) => {
92+ if ( isDevelopment ) return 'http://localhost:3000'
93+ return getPreviewUrl ( ) || getProductionUrl ( ) || NPMX_SITE_PROD
94+ }
95+
9096const git = Git ( )
9197export async function getGitInfo ( ) {
9298 let branch
@@ -140,12 +146,14 @@ export async function getEnv(isDevelopment: boolean) {
140146 : 'release'
141147 const previewUrl = getPreviewUrl ( )
142148 const productionUrl = getProductionUrl ( )
149+ const siteUrl = getSiteUrl ( isDevelopment )
143150 return {
144151 commit,
145152 shortCommit,
146153 branch,
147154 env,
148155 previewUrl,
149156 productionUrl,
157+ siteUrl,
150158 } as const
151159}
You can’t perform that action at this time.
0 commit comments