Skip to content

Commit 6f4f537

Browse files
authored
Merge pull request #11622 from github/repo-sync
repo sync
2 parents d6bb1af + 58d3867 commit 6f4f537

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
11
.fadeBottom {
22
background: linear-gradient(to top, var(--color-canvas-default), transparent);
33
}
4+
5+
/* Because of the sticky header */
6+
.hashAnchor {
7+
&:target {
8+
scroll-margin-top: 75px;
9+
}
10+
}

components/sublanding/LearningTrack.tsx

+7-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { ArrowRightIcon } from '@primer/octicons-react'
44
import { useState } from 'react'
55
import { FeaturedTrack } from 'components/context/ProductSubLandingContext'
66
import { TruncateLines } from 'components/ui/TruncateLines'
7+
import slugger from 'github-slugger'
78
import styles from './LearningTrack.module.scss'
89

910
type Props = {
@@ -17,14 +18,19 @@ export const LearningTrack = ({ track }: Props) => {
1718
setNumVisible(track?.guides?.length || 0)
1819
}
1920
const { t } = useTranslation('product_sublanding')
21+
const slug = track?.title ? slugger.slug(track?.title) : ''
2022

2123
return (
2224
<div data-testid="learning-track" className="my-3 px-4 col-12 col-md-6">
2325
<div className="Box d-flex flex-column">
2426
<div className="Box-header color-bg-subtle p-4 d-flex flex-1 flex-items-start flex-wrap">
2527
<div className="d-flex flex-auto flex-items-start col-8 col-md-12 col-xl-8">
2628
<div className="my-xl-0 mr-xl-3">
27-
<h5 className="mb-3 color-text f3 text-semibold">{track?.title}</h5>
29+
<h5 id={slug} className={cx('mb-3 color-text f3 text-semibold', styles.hashAnchor)}>
30+
<a className="color-unset" href={`#${slug}`}>
31+
{track?.title}
32+
</a>
33+
</h5>
2834
<TruncateLines as="p" maxLines={3} className="color-text">
2935
{track?.description}
3036
</TruncateLines>

tests/rendering/learning-tracks.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ describe('learning tracks', () => {
2222
const $ = await getDOM('/en/code-security/guides')
2323
expect($('[data-testid=learning-track]').length).toBeGreaterThanOrEqual(4)
2424
$('[data-testid=learning-track]').each((i, trackElem) => {
25-
const href = $(trackElem).find('.Box-header a').first().attr('href')
25+
const href = $(trackElem).find('.Box-header a:nth-child(2)').first().attr('href')
2626
const found = href.match(/.*\?learn=(.*)/i)
2727
expect(found).not.toBeNull()
2828
const trackName = found[1]

0 commit comments

Comments
 (0)