fix link back to journey page href (#58103)
This commit is contained in:
@@ -3,6 +3,7 @@ import { useRouter } from 'next/router'
|
|||||||
import { Link } from '@/frame/components/Link'
|
import { Link } from '@/frame/components/Link'
|
||||||
import type { JourneyContext } from '@/journeys/lib/journey-path-resolver'
|
import type { JourneyContext } from '@/journeys/lib/journey-path-resolver'
|
||||||
import { useTranslation } from '@/languages/components/useTranslation'
|
import { useTranslation } from '@/languages/components/useTranslation'
|
||||||
|
import { useVersion } from '@/versions/components/useVersion'
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
journey: JourneyContext
|
journey: JourneyContext
|
||||||
@@ -10,9 +11,11 @@ type Props = {
|
|||||||
|
|
||||||
export function JourneyTrackCard({ journey }: Props) {
|
export function JourneyTrackCard({ journey }: Props) {
|
||||||
const { locale } = useRouter()
|
const { locale } = useRouter()
|
||||||
|
const { currentVersion } = useVersion()
|
||||||
const { t } = useTranslation('journey_track_nav')
|
const { t } = useTranslation('journey_track_nav')
|
||||||
const { trackTitle, journeyTitle, journeyPath, nextGuide, numberOfGuides, currentGuideIndex } =
|
const { trackTitle, journeyTitle, journeyPath, nextGuide, numberOfGuides, currentGuideIndex } =
|
||||||
journey
|
journey
|
||||||
|
const fullPath = `/${locale}/${currentVersion}${journeyPath}?feature=journey-landing`
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
@@ -21,7 +24,7 @@ export function JourneyTrackCard({ journey }: Props) {
|
|||||||
>
|
>
|
||||||
<div className="d-flex flex-column width-full">
|
<div className="d-flex flex-column width-full">
|
||||||
<h2 className="h4">
|
<h2 className="h4">
|
||||||
<Link href={`/${locale}${journeyPath}`} className="mb-1 text-underline">
|
<Link href={fullPath} className="mb-1 text-underline">
|
||||||
{journeyTitle}
|
{journeyTitle}
|
||||||
</Link>
|
</Link>
|
||||||
</h2>
|
</h2>
|
||||||
@@ -41,7 +44,7 @@ export function JourneyTrackCard({ journey }: Props) {
|
|||||||
</Link>
|
</Link>
|
||||||
</>
|
</>
|
||||||
) : (
|
) : (
|
||||||
<Link href={`/${locale}${journeyPath}`} className="h5 text-bold color-fg f5 ml-1">
|
<Link href={fullPath} className="h5 text-bold color-fg f5 ml-1">
|
||||||
{t('more_articles')}
|
{t('more_articles')}
|
||||||
</Link>
|
</Link>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import { getPathWithoutLanguage, getPathWithoutVersion } from '@/frame/lib/path-
|
|||||||
import { renderContent } from '@/content-render/index'
|
import { renderContent } from '@/content-render/index'
|
||||||
import { executeWithFallback } from '@/languages/lib/render-with-fallback'
|
import { executeWithFallback } from '@/languages/lib/render-with-fallback'
|
||||||
import getApplicableVersions from '@/versions/lib/get-applicable-versions'
|
import getApplicableVersions from '@/versions/lib/get-applicable-versions'
|
||||||
|
import Permalink from '@/frame/lib/permalink'
|
||||||
import getLinkData from './get-link-data'
|
import getLinkData from './get-link-data'
|
||||||
|
|
||||||
export interface JourneyContext {
|
export interface JourneyContext {
|
||||||
@@ -170,7 +171,8 @@ export async function resolveJourneyContext(
|
|||||||
trackName: track.id,
|
trackName: track.id,
|
||||||
trackTitle: track.title,
|
trackTitle: track.title,
|
||||||
journeyTitle: journeyPage.title || '',
|
journeyTitle: journeyPage.title || '',
|
||||||
journeyPath: journeyPage.permalink || `/${journeyPage.relativePath || ''}`,
|
journeyPath:
|
||||||
|
journeyPage.permalink || Permalink.relativePathToSuffix(journeyPage.relativePath || ''),
|
||||||
currentGuideIndex: guideIndex,
|
currentGuideIndex: guideIndex,
|
||||||
numberOfGuides: track.guides.length,
|
numberOfGuides: track.guides.length,
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user