Skip to content

Commit 6ef6720

Browse files
authored
Merge pull request #249 from tnga/fixes
fix: Fix navigation links and add smooth scrolling to hash fragments
2 parents 50a11a5 + c0c146b commit 6ef6720

File tree

5 files changed

+26
-7
lines changed

5 files changed

+26
-7
lines changed

public/assets/badges/webcheck.svg

Lines changed: 1 addition & 1 deletion
Loading

src/web-check-live/components/Form/Row.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ export const ExpandableRow = (props: RowProps) => {
151151
return (
152152
<StyledRow as="li" key={`${row.lbl}-${index}`}>
153153
<span className="lbl" title={row.title?.toString()}>{row.lbl}</span>
154-
<span className="val" title={row.val} onClick={() => copyToClipboard(row.val)}>
154+
<span className="val" title={row.val?.toString()} onClick={() => copyToClipboard(row.val)}>
155155
{formatValue(row.val)}
156156
</span>
157157
{ row.plaintext && <PlainText>{row.plaintext}</PlainText> }

src/web-check-live/components/Results/RobotsTxt.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,17 @@ const cardStyles = `
1111
`;
1212

1313
const RobotsTxtCard = ( props: { data: { robots: RowProps[]}, title: string, actionButtons: any}): JSX.Element => {
14-
const robots = props.data;
14+
const { data } = props;
15+
const robots = data?.robots || [];
16+
1517
return (
1618
<Card heading={props.title} actionButtons={props.actionButtons} styles={cardStyles}>
1719
<div className="content">
1820
{
19-
robots.robots.length === 0 && <p>No crawl rules found.</p>
21+
robots.length === 0 && <p>No crawl rules found.</p>
2022
}
2123
{
22-
robots.robots.map((row: RowProps, index: number) => {
24+
robots.map((row: RowProps, index: number) => {
2325
return (
2426
<Row key={`${row.lbl}-${index}`} lbl={row.lbl} val={row.val} />
2527
)

src/web-check-live/views/About.tsx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import styled from '@emotion/styled';
2+
import { useEffect } from 'react';
3+
import { useLocation } from 'react-router-dom';
24

35
import colors from 'web-check-live/styles/colors';
46
import Heading from 'web-check-live/components/Form/Heading';
@@ -118,6 +120,21 @@ const makeAnchor = (title: string): string => {
118120
};
119121

120122
const About = (): JSX.Element => {
123+
const location = useLocation();
124+
125+
useEffect(() => {
126+
// Scroll to hash fragment if present
127+
if (location.hash) {
128+
// Add a small delay to ensure the page has fully rendered
129+
setTimeout(() => {
130+
const element = document.getElementById(location.hash.slice(1));
131+
if (element) {
132+
element.scrollIntoView({ behavior: 'smooth', block: 'start' });
133+
}
134+
}, 100);
135+
}
136+
}, [location]);
137+
121138
return (
122139
<div>
123140
<AboutContainer>

src/web-check-live/views/Home.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ const Home = (): JSX.Element => {
278278
<Heading as="h2" size="small" color={colors.primary}>Supported Checks</Heading>
279279
<ul>
280280
{docs.map((doc, index) => (<li key={index}>{doc.title}</li>))}
281-
<li><Link to="/about">+ more!</Link></li>
281+
<li><Link to="/check/about">+ more!</Link></li>
282282
</ul>
283283
</div>
284284
<div className="links">
@@ -288,7 +288,7 @@ const Home = (): JSX.Element => {
288288
<a target="_blank" rel="noreferrer" href="https://app.netlify.com/start/deploy?repository=https://github.com/lissy93/web-check" title="Deploy your own private or public instance of Web-Check to Netlify">
289289
<Button>Deploy your own</Button>
290290
</a>
291-
<Link to="/about#api-documentation" title="View the API documentation, to use Web-Check programmatically">
291+
<Link to="/check/about#api-documentation" title="View the API documentation, to use Web-Check programmatically">
292292
<Button>API Docs</Button>
293293
</Link>
294294
</div>

0 commit comments

Comments
 (0)