Skip to content

Commit

Permalink
Fix your-badge link (badges#3058)
Browse files Browse the repository at this point in the history
  • Loading branch information
paulmelnikow authored Feb 20, 2019
1 parent 84db9e6 commit bc523e3
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 3 deletions.
6 changes: 6 additions & 0 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ parserOptions:
# though that setting is only for ES6 modules, not CommonJS modules.
sourceType: 'script'

overrides:
files:
- gatsby-browser.js
parserOptions:
sourceType: 'module'

plugins:
- mocha
- no-extension-in-require
Expand Down
4 changes: 2 additions & 2 deletions frontend/components/usage.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ export default class Usage extends React.PureComponent {
<section>
<H2 id="your-badge">Your Badge</H2>

<H3 id="static-badge">Static</H3>
<H3>Static</H3>
<StaticBadgeMaker baseUrl={baseUrl} />

<VerticalSpace />
Expand Down Expand Up @@ -215,7 +215,7 @@ export default class Usage extends React.PureComponent {
/>
</p>

<H3 id="endpoint">Endpoint (Beta)</H3>
<H3>Endpoint (Beta)</H3>

<p>
<Snippet
Expand Down
2 changes: 1 addition & 1 deletion frontend/pages/endpoint.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ const EndpointPage = () => (
<GlobalStyle />
<Meta />
<Header />
<H3 id="static-badge">Endpoint (Beta)</H3>
<H3>Endpoint (Beta)</H3>
<Snippet snippet={`${baseUrl}/badge/endpoint.svg?url=...&style=...`} />
<p>Endpoint response:</p>
<JsonExample
Expand Down
16 changes: 16 additions & 0 deletions gatsby-browser.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Adapted from https://github.com/gatsbyjs/gatsby/issues/8413

function scrollToElementId(id) {
const el = document.querySelector(id)
if (el) {
return window.scrollTo(0, el.offsetTop - 20)
} else {
return false
}
}

export function onRouteUpdate({ location: { hash } }) {
if (hash) {
window.setTimeout(() => scrollToElementId(hash), 10)
}
}

0 comments on commit bc523e3

Please sign in to comment.