-
-
Notifications
You must be signed in to change notification settings - Fork 8.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge github.com:facebook/docusaurus into lex111/decouple-admonitions
- Loading branch information
Showing
16 changed files
with
239 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"name": "@docusaurus/module-type-aliases", | ||
"version": "2.0.0-alpha.50", | ||
"description": "Docusaurus module type aliases", | ||
"types": "./src/index.d.ts", | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"license": "MIT" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/** | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
declare module '@generated/client-modules' { | ||
const clientModules: readonly any[]; | ||
export default clientModules; | ||
} | ||
|
||
declare module '@generated/docusaurus.config' { | ||
const config: any; | ||
export default config; | ||
} | ||
|
||
declare module '@generated/registry' { | ||
const registry: { | ||
readonly [key: string]: [() => Promise<any>, string, string]; | ||
}; | ||
export default registry; | ||
} | ||
|
||
declare module '@generated/routes' { | ||
type Route = { | ||
readonly path: string; | ||
readonly component: any; | ||
readonly exact?: boolean; | ||
}; | ||
const routes: Route[]; | ||
export default routes; | ||
} | ||
|
||
declare module '@generated/routesChunkNames' { | ||
const routesChunkNames: any; | ||
export default routesChunkNames; | ||
} | ||
|
||
declare module '@theme/*' { | ||
const component: any; | ||
export default component; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
packages/docusaurus-theme-classic/src/theme/hooks/useScrollPosition.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/** | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
import {useState, useEffect} from 'react'; | ||
import ExecutionEnvironment from '@docusaurus/ExecutionEnvironment'; | ||
|
||
const getScrollPosition = () => ({ | ||
scrollX: ExecutionEnvironment.canUseDOM ? window.pageXOffset : 0, | ||
scrollY: ExecutionEnvironment.canUseDOM ? window.pageYOffset : 0, | ||
}); | ||
|
||
const useScrollPosition = (effect, deps = []) => { | ||
const [scrollPosition, setScrollPosition] = useState(getScrollPosition()); | ||
|
||
const handleScroll = () => { | ||
const currentScrollPosition = getScrollPosition(); | ||
|
||
setScrollPosition(currentScrollPosition); | ||
|
||
if (effect) { | ||
effect(currentScrollPosition); | ||
} | ||
}; | ||
|
||
useEffect(() => { | ||
window.addEventListener('scroll', handleScroll); | ||
|
||
return () => | ||
window.removeEventListener('scroll', handleScroll, { | ||
passive: true, | ||
}); | ||
}, deps); | ||
|
||
return scrollPosition; | ||
}; | ||
|
||
export default useScrollPosition; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.