Skip to content

Commit 6157d3e

Browse files
authored
Merge pull request #237 from data-driven-forms/algolia-search
Fixed demo links to enable crawlers.
2 parents c435e75 + 9fd8cb5 commit 6157d3e

File tree

6 files changed

+35
-51
lines changed

6 files changed

+35
-51
lines changed

packages/react-renderer-demo/src/app/.eslintrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
},
1212
"settings": {
1313
"react": {
14-
"version": 16.6
14+
"version": "16.6"
1515
}
1616
},
1717
"globals": {

packages/react-renderer-demo/src/app/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
"start": "next start",
1111
"vendor": "webpack --env vendor --config ./config/webpack.config.js --progress",
1212
"deploy": "firebase deploy --only functions",
13-
"analyze": "ANALYZE=true next build"
13+
"analyze": "ANALYZE=true next build",
14+
"lint": "eslint ./src"
1415
},
1516
"repository": {
1617
"type": "git",

packages/react-renderer-demo/src/app/src/components/layout.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -209,14 +209,16 @@ const Layout = ({ children }) => {
209209
[classes.contentShift]: open,
210210
[classes.mainGradient]: router.pathname === '/',
211211
[classes.mainGradientShift]: router.pathname === '/' && open,
212-
'DocSearch-content': true,
213212
}) }
214213
>
215214
<div className={ classes.contentWrapper }>
216-
<div style={{
217-
paddingRight: 32,
218-
paddingLeft: 32,
219-
}}>
215+
<div
216+
className="DocSearch-content"
217+
style={{
218+
paddingRight: 32,
219+
paddingLeft: 32,
220+
221+
}}>
220222
{ children }
221223
</div>
222224
<ConnectedLinks />

packages/react-renderer-demo/src/app/src/components/mdx/mdx-components.js

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import Paper from '@material-ui/core/Paper';
1313
import { headerToId } from '../../helpers/list-of-contents';
1414
import ShareButton from './share-button';
1515
import { makeStyles } from '@material-ui/core/styles';
16+
import { useRouter } from 'next/router';
1617

1718
import dynamic from 'next/dynamic';
1819
const CodeEditor = dynamic(import('../code-editor'), {
@@ -21,13 +22,14 @@ const CodeEditor = dynamic(import('../code-editor'), {
2122

2223
const useHeadingStyles = makeStyles(() => ({
2324
anchorOffset: {
25+
textDecoration: 'none',
26+
color: 'inherit',
27+
paddingTop: 92, // compensate for fixed header size and spacing
28+
marginTop: -92, // compensate for fixed header size and spacing
2429
position: 'relative',
25-
top: -92, // compensate for fixed header size and spacing
26-
display: 'block',
30+
display: 'inline-block',
2731
},
2832
heading: {
29-
marginBottom: 10,
30-
marginTop: 10,
3133
'& button': {
3234
visibility: 'hidden',
3335
},
@@ -38,21 +40,22 @@ const useHeadingStyles = makeStyles(() => ({
3840
}));
3941

4042
const Heading = ({ level, children, variant, component, ...rest }) => {
43+
const router = useRouter();
4144
const classes = useHeadingStyles();
4245
const id = headerToId(children);
46+
const path = `${router.pathname}#${id}`;
4347
return (
44-
<React.Fragment>
45-
<a id={ id } className={ classes.anchorOffset } data-mdlink="md-heading" />
48+
<a id={ id } href={ path } className={ classes.anchorOffset } data-mdlink="md-heading">
4649
<Typography
4750
id={ `heading-${id}` }
4851
className={ classes.heading }
4952
variant={ `h${level}` }
5053
component={ component }
5154
>
5255
{ children }
53-
<ShareButton text={ id }/>
56+
<ShareButton path={ path }/>
5457
</Typography>
55-
</React.Fragment>
58+
</a>
5659
);
5760
};
5861

packages/react-renderer-demo/src/app/src/components/mdx/share-button.js

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,25 @@ import PropTypes from 'prop-types';
33
import IconButton from '@material-ui/core/IconButton';
44
import CopyToClipboard from 'react-copy-to-clipboard';
55
import SvgIcon from '@material-ui/core/SvgIcon';
6-
import { useRouter } from 'next/router';
76

87
const HashTagSvg = (props) => (
98
<path width="16px" height="16px" { ...props } d="M46.9 13.9c-.5-.6-1.2-.94-2.07-.94h-6.67l1.86-8.98c.17-.85 0-1.7-.52-2.3-.48-.6-1.2-.94-2.07-.94-1.6 0-3.2 1.27-3.54 2.93l-.5 2.42c0 .07-.07.13-.07.2l-1.37 6.62H20.7l1.88-8.96c.16-.85 0-1.7-.53-2.3-.48-.6-1.2-.94-2.07-.94-1.65 0-3.2 1.27-3.56 2.93l-.52 2.58v.08l-1.37 6.64H7.3c-1.67 0-3.22 1.3-3.58 2.96-.16.86 0 1.7.52 2.3.48.6 1.2.93 2.07.93h6.97l-2 9.65H4c-1.67 0-3.22 1.27-3.56 2.94-.2.8 0 1.67.5 2.27.5.6 1.2.93 2.08.93H10l-1.84 9.05c-.2.84 0 1.67.52 2.3.5.6 1.25.92 2.08.92 1.66 0 3.2-1.3 3.55-2.94l1.94-9.33h11.22l-1.87 9.05c-.15.84.03 1.67.53 2.3.5.6 1.2.92 2.07.92 1.65 0 3.22-1.3 3.56-2.94l1.9-9.33h7c1.6 0 3.2-1.28 3.53-2.93.2-.87 0-1.7-.52-2.3-.48-.62-1.2-.96-2.05-.96h-6.7l2.02-9.65h6.93c1.67 0 3.22-1.27 3.56-2.92.2-.85 0-1.7-.5-2.3l-.04.03zM17.53 28.77l1.95-9.65H30.7l-1.97 9.66H17.5h.03z"></path>
109
);
1110

12-
const ShareButton = ({ text }) => {
13-
const router = useRouter();
14-
const path = `${router.pathname}#${text}`;
15-
return (
16-
<CopyToClipboard text={ `${router.pathname}#${text}` }>
17-
<a href={ path }>
18-
<IconButton size="medium">
19-
<SvgIcon fontSize="small" viewBox="0 0 48 48">
20-
<HashTagSvg />
21-
</SvgIcon>
22-
</IconButton>
23-
</a>
24-
</CopyToClipboard>
25-
);
26-
};
11+
const ShareButton = ({ path }) => (
12+
<CopyToClipboard text={ path }>
13+
<a href={ path }>
14+
<IconButton size="medium">
15+
<SvgIcon fontSize="small" viewBox="0 0 48 48">
16+
<HashTagSvg />
17+
</SvgIcon>
18+
</IconButton>
19+
</a>
20+
</CopyToClipboard>
21+
);
2722

2823
ShareButton.propTypes = {
29-
text: PropTypes.string.isRequired,
24+
path: PropTypes.string.isRequired,
3025
};
3126

3227
export default ShareButton;

packages/react-renderer-demo/src/app/src/helpers/list-of-contents.js

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -84,28 +84,11 @@ const useStyles = makeStyles(theme => ({
8484
paddingLeft: 16,
8585
paddingRight: 16,
8686
},
87-
listItemActive: {
88-
position: 'relative',
89-
background: theme.palette.common.white,
90-
'&::before': {
91-
position: 'absolute',
92-
left: -0,
93-
display: 'block',
94-
content: '""',
95-
width: 2,
96-
height: '100%',
97-
background: theme.palette.grey[700],
98-
},
99-
},
100-
contentHeader: {
101-
paddingLeft: 16,
102-
paddingRight: 16,
103-
},
10487
}));
10588

10689
const scrollListener = (setActive) => {
107-
const min = 120;
108-
const max = 150;
90+
const min = -10;
91+
const max = 20;
10992
const elem = Array.from(document.querySelectorAll('[data-mdlink]'))
11093
.find(elem => {
11194
const { top } = elem.getBoundingClientRect();

0 commit comments

Comments
 (0)