Skip to content

Commit

Permalink
Merge branch 'master' into endi/docs
Browse files Browse the repository at this point in the history
  • Loading branch information
endiliey committed Nov 29, 2019
2 parents 7e4f019 + 2f9a368 commit 9939058
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 27 deletions.
10 changes: 5 additions & 5 deletions packages/docusaurus-1.x/lib/static/js/codetabs.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,27 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

// Turn off ESLint for this file because it's sent down to users as-is.

/* eslint-disable */
window.addEventListener('load', function() {
// add event listener for all tab
document.querySelectorAll('.nav-link').forEach(function(el) {
el.addEventListener('click', function(e) {
const groupId = e.target.getAttribute('data-group');
var groupId = e.target.getAttribute('data-group');
document
.querySelectorAll(`.nav-link[data-group=${groupId}]`)
.querySelectorAll('.nav-link[data-group='.concat(groupId, ']'))
.forEach(function(el) {
el.classList.remove('active');
});
document
.querySelectorAll(`.tab-pane[data-group=${groupId}]`)
.querySelectorAll('.tab-pane[data-group='.concat(groupId, ']'))
.forEach(function(el) {
el.classList.remove('active');
});
e.target.classList.add('active');
document
.querySelector(`#${e.target.getAttribute('data-tab')}`)
.querySelector('#'.concat(e.target.getAttribute('data-tab')))
.classList.add('active');
});
});
Expand Down
37 changes: 22 additions & 15 deletions packages/docusaurus-1.x/lib/static/js/scrollSpy.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,57 +5,64 @@
* LICENSE file in the root directory of this source tree.
*/

/* eslint-disable prefer-arrow-callback */
/* eslint-disable */
(function scrollSpy() {
const OFFSET = 10;
let timer;
let headingsCache;
const findHeadings = function findHeadings() {
var OFFSET = 10;
var timer;
var headingsCache;

var findHeadings = function findHeadings() {
return headingsCache || document.querySelectorAll('.toc-headings > li > a');
};
const onScroll = function onScroll() {

var onScroll = function onScroll() {
if (timer) {
// throttle
return;
}

timer = setTimeout(function() {
timer = null;
let activeNavFound = false;
const headings = findHeadings(); // toc nav anchors
var activeNavFound = false;
var headings = findHeadings(); // toc nav anchors

/**
* On every call, try to find header right after <-- next header
* the one whose content is on the current screen <-- highlight this
*/
for (let i = 0; i < headings.length; i++) {

for (var i = 0; i < headings.length; i++) {
// headings[i] is current element
// if an element is already active, then current element is not active
// if no element is already active, then current element is active
let currNavActive = !activeNavFound;
var currNavActive = !activeNavFound;
/**
* Enter the following check up only when an active nav header is not yet found
* Then, check the bounding rectangle of the next header
* The headers that are scrolled passed will have negative bounding rect top
* So the first one with positive bounding rect top will be the nearest next header
*/

if (currNavActive && i < headings.length - 1) {
const heading = headings[i + 1];
const next = decodeURIComponent(heading.href.split('#')[1]);
const nextHeader = document.getElementById(next);
var heading = headings[i + 1];
var next = decodeURIComponent(heading.href.split('#')[1]);
var nextHeader = document.getElementById(next);

if (nextHeader) {
const top = nextHeader.getBoundingClientRect().top;
var top = nextHeader.getBoundingClientRect().top;
currNavActive = top > OFFSET;
} else {
console.error('Can not find header element', {
id: next,
heading,
heading: heading,
});
}
}
/**
* Stop searching once a first such header is found,
* this makes sure the highlighted header is the most current one
*/

if (currNavActive) {
activeNavFound = true;
headings[i].classList.add('active');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ function DocSidebarItem({item, onItemClick, collapsible}) {
<Link
activeClassName="menu__link--active"
className="menu__link"
exact
to={href}
onClick={onItemClick}>
{label}
Expand Down
6 changes: 3 additions & 3 deletions website/docs/docusaurus-core.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ sidebar_label: Client API

Docusaurus provides some API on client that can be helpful when building your site.

## `<Head />`
## `Head`

This reusable React component will manage all of your changes to the document head. It takes plain HTML tags and outputs plain HTML tags and is beginner-friendly. It is a wrapper around [React Helmet](https://github.com/nfl/react-helmet).

Expand Down Expand Up @@ -55,7 +55,7 @@ Outputs
</head>
```

## `<Link />`
## `Link`

This component enables linking to internal pages as well as a powerful performance feature called preloading. Preloading is used to prefetch resources so that the resources are fetched by the time the user navigates with this component. We use an `IntersectionObserver` to fetch a low-priority request when the `<Link>` is in the viewport and then use an `onMouseOver` event to trigger a high-priority request when it is likely that a user will navigate to the requested resource.

Expand Down Expand Up @@ -145,7 +145,7 @@ function Help() {
}
```

## `<Redirect />`
## `Redirect`

Rendering a `<Redirect>` will navigate to a new location. The new location will override the current location in the history stack, like server-side redirects (HTTP 3xx) do. You can refer to [React Router's Redirect documentation](https://reacttraining.com/react-router/web/api/Redirect) for more info on available props.

Expand Down
2 changes: 1 addition & 1 deletion website/docs/theme-classic.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ module.exports = {
### Meta image
You can configure a default image that will be used for your meta tag, in particular `og:image` and `twitter:image`;
You can configure a default image that will be used for your meta tag, in particular `og:image` and `twitter:image`.
```js
// docusaurus.config.js
Expand Down
1 change: 1 addition & 0 deletions website/src/pages/versions.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ function Version() {
permalink="/versions"
description="Docusaurus 2 Versions page listing all documented site versions">
<div className="container margin-vert--xl">
<h1>Docusaurus documentation versions</h1>
<div className="margin-bottom--lg">
<h3 id="latest">Latest version (Stable)</h3>
<p>Here you can find the latest documentation.</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ sidebar_title: Client API

Docusaurus provides some API on client that can be helpful when building your site.

## `<Head />`
## `Head`

This reusable React component will manage all of your changes to the document head. It takes plain HTML tags and outputs plain HTML tags and is beginner-friendly. It is a wrapper around [React Helmet](https://github.com/nfl/react-helmet).

Expand Down Expand Up @@ -55,7 +55,7 @@ Outputs
</head>
```

## `<Link />`
## `Link`

This component enables linking to internal pages as well as a powerful performance feature called preloading. Preloading is used to prefetch resources so that the resources are fetched by the time the user navigates with this component. We use an `IntersectionObserver` to fetch a low-priority request when the `<Link>` is in the viewport and then use an `onMouseOver` event to trigger a high-priority request when it is likely that a user will navigate to the requested resource.

Expand Down Expand Up @@ -145,7 +145,7 @@ function Help() {
}
```

## `<Redirect />`
## `Redirect`

Rendering a `<Redirect>` will navigate to a new location. The new location will override the current location in the history stack, like server-side redirects (HTTP 3xx) do. You can refer to [React Router's Redirect documentation](https://reacttraining.com/react-router/web/api/Redirect) for more info on available props.

Expand Down

0 comments on commit 9939058

Please sign in to comment.