forked from facebook/docusaurus
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(v2): implement theme component overriding (facebook#1435)
* feat(v2): implement component overriding * siteDir theme overriding should work for > 1 level directory * fallback for essential component like Loading * rename default -> classic
- Loading branch information
Showing
38 changed files
with
533 additions
and
206 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
File renamed without changes.
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
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,21 @@ | ||
{ | ||
"name": "@docusaurus/theme-classic", | ||
"version": "2.0.0-alpha.13", | ||
"description": "Classic theme for Docusaurus", | ||
"main": "src/index.js", | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"license": "MIT", | ||
"dependencies": { | ||
"docsearch.js": "^2.5.2" | ||
}, | ||
"peerDependencies": { | ||
"@docusaurus/core": "^2.0.0", | ||
"react": "^16.8.4", | ||
"react-dom": "^16.8.4" | ||
}, | ||
"engines": { | ||
"node": ">=8" | ||
} | ||
} |
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,36 @@ | ||
/** | ||
* Copyright (c) 2017-present, Facebook, Inc. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
const path = require('path'); | ||
|
||
const DEFAULT_OPTIONS = {}; | ||
|
||
class DocusaurusThemeDefault { | ||
constructor(context, opts) { | ||
this.options = {...DEFAULT_OPTIONS, ...opts}; | ||
this.context = context; | ||
} | ||
|
||
getName() { | ||
return 'docusaurus-theme-classic'; | ||
} | ||
|
||
configureWebpack() { | ||
return { | ||
resolve: { | ||
alias: { | ||
'@theme/Footer': path.resolve(__dirname, './theme/Footer'), | ||
'@theme/Navbar': path.resolve(__dirname, './theme/Navbar'), | ||
'@theme/NotFound': path.resolve(__dirname, './theme/NotFound'), | ||
'@theme/Search': path.resolve(__dirname, './theme/Search'), | ||
}, | ||
}, | ||
}; | ||
} | ||
} | ||
|
||
module.exports = DocusaurusThemeDefault; |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
28 changes: 28 additions & 0 deletions
28
packages/docusaurus/lib/client/theme-fallback/Layout/index.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,28 @@ | ||
/** | ||
* Copyright (c) 2017-present, Facebook, Inc. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
import React from 'react'; | ||
import Head from '@docusaurus/Head'; // eslint-disable-line | ||
import useDocusaurusContext from '@docusaurus/useDocusaurusContext'; // eslint-disable-line | ||
|
||
function Layout(props) { | ||
const context = useDocusaurusContext(); | ||
const {siteConfig = {}} = context; | ||
const {baseUrl, favicon, tagline, title: defaultTitle} = siteConfig; | ||
const {children, title} = props; | ||
return ( | ||
<React.Fragment> | ||
<Head defaultTitle={`${defaultTitle} · ${tagline}`}> | ||
{title && <title>{`${title} · ${tagline}`}</title>} | ||
{favicon && <link rel="shortcut icon" href={baseUrl + favicon} />} | ||
</Head> | ||
{children} | ||
</React.Fragment> | ||
); | ||
} | ||
|
||
export default Layout; |
110 changes: 110 additions & 0 deletions
110
packages/docusaurus/lib/client/theme-fallback/Loading/index.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,110 @@ | ||
/** | ||
* Copyright (c) 2017-present, Facebook, Inc. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
import React from 'react'; | ||
|
||
export default props => { | ||
if (props.error) { | ||
console.warn(props.error); | ||
return <div align="center">Error</div>; | ||
} | ||
|
||
if (props.pastDelay) { | ||
return ( | ||
<div | ||
style={{ | ||
display: 'flex', | ||
justifyContent: 'center', | ||
alignItems: 'center', | ||
height: '100vh', | ||
}}> | ||
<svg | ||
id="loader" | ||
style={{ | ||
width: 128, | ||
height: 110, | ||
position: 'absolute', | ||
top: 'calc(100vh - 64%)', | ||
}} | ||
viewBox="0 0 45 45" | ||
xmlns="http://www.w3.org/2000/svg" | ||
stroke="#61dafb"> | ||
<g | ||
fill="none" | ||
fillRule="evenodd" | ||
transform="translate(1 1)" | ||
strokeWidth="2"> | ||
<circle cx="22" cy="22" r="6" strokeOpacity="0"> | ||
<animate | ||
attributeName="r" | ||
begin="1.5s" | ||
dur="3s" | ||
values="6;22" | ||
calcMode="linear" | ||
repeatCount="indefinite" | ||
/> | ||
<animate | ||
attributeName="stroke-opacity" | ||
begin="1.5s" | ||
dur="3s" | ||
values="1;0" | ||
calcMode="linear" | ||
repeatCount="indefinite" | ||
/> | ||
<animate | ||
attributeName="stroke-width" | ||
begin="1.5s" | ||
dur="3s" | ||
values="2;0" | ||
calcMode="linear" | ||
repeatCount="indefinite" | ||
/> | ||
</circle> | ||
<circle cx="22" cy="22" r="6" strokeOpacity="0"> | ||
<animate | ||
attributeName="r" | ||
begin="3s" | ||
dur="3s" | ||
values="6;22" | ||
calcMode="linear" | ||
repeatCount="indefinite" | ||
/> | ||
<animate | ||
attributeName="stroke-opacity" | ||
begin="3s" | ||
dur="3s" | ||
values="1;0" | ||
calcMode="linear" | ||
repeatCount="indefinite" | ||
/> | ||
<animate | ||
attributeName="stroke-width" | ||
begin="3s" | ||
dur="3s" | ||
values="2;0" | ||
calcMode="linear" | ||
repeatCount="indefinite" | ||
/> | ||
</circle> | ||
<circle cx="22" cy="22" r="8"> | ||
<animate | ||
attributeName="r" | ||
begin="0s" | ||
dur="1.5s" | ||
values="6;1;2;3;4;5;6" | ||
calcMode="linear" | ||
repeatCount="indefinite" | ||
/> | ||
</circle> | ||
</g> | ||
</svg> | ||
</div> | ||
); | ||
} | ||
|
||
return null; | ||
}; |
28 changes: 28 additions & 0 deletions
28
packages/docusaurus/lib/client/theme-fallback/NotFound/index.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,28 @@ | ||
/** | ||
* Copyright (c) 2017-present, Facebook, Inc. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
import React from 'react'; | ||
import Layout from '@theme/Layout'; | ||
|
||
function NotFound() { | ||
return ( | ||
<Layout title="Page Not Found"> | ||
<div | ||
style={{ | ||
display: 'flex', | ||
justifyContent: 'center', | ||
alignItems: 'center', | ||
height: '50vh', | ||
fontSize: '20px', | ||
}}> | ||
<h1>Oops, page not found </h1> | ||
</div> | ||
</Layout> | ||
); | ||
} | ||
|
||
export default NotFound; |
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 was deleted.
Oops, something went wrong.
Oops, something went wrong.