1
0
mirror of https://github.com/oceanprotocol/docs.git synced 2024-11-01 15:55:34 +01:00

make DocFooter more flexible, add to swagger template

This commit is contained in:
Matthias Kretschmann 2018-11-29 22:24:24 +01:00
parent ba5f6bab1d
commit fe5902e5b1
Signed by: m
GPG Key ID: 606EEEF3C479A91F
2 changed files with 26 additions and 18 deletions

View File

@ -4,31 +4,31 @@ import { ReactComponent as Pencil } from '../images/pencil.svg'
import styles from './DocFooter.module.scss'
import { githubContentPath, githubDevOceanPath } from '../../config'
const DocFooter = ({ post }) => {
const { sourceInstanceName } = post.parent
const DocFooter = ({ post, url, externalName }) => {
let path
let externalRepoName
if (post) {
const { sourceInstanceName } = post.parent
switch (sourceInstanceName) {
case 'dev-ocean':
path = githubDevOceanPath
externalRepoName = sourceInstanceName
externalName = sourceInstanceName
break
default:
path = githubContentPath
}
url = `${path}/${post.parent.relativePath}`
}
return (
<footer className={styles.footer}>
<a
href={`${path}/${post.parent.relativePath}`}
className={!post.html ? styles.active : null}
>
<a href={url} className={post && !post.html ? styles.active : null}>
<Pencil /> Edit this page on GitHub
{externalRepoName && (
{externalName && (
<span className={styles.externalRepoName}>
{externalRepoName}
{externalName}
</span>
)}
</a>
@ -37,7 +37,9 @@ const DocFooter = ({ post }) => {
}
DocFooter.propTypes = {
post: PropTypes.object.isRequired
post: PropTypes.object,
url: PropTypes.string,
externalName: PropTypes.string
}
export default DocFooter

View File

@ -8,6 +8,7 @@ import Content from '../components/Content'
import HeaderSection from '../components/HeaderSection'
import Sidebar from '../components/Sidebar'
import DocHeader from '../components/DocHeader'
import DocFooter from '../components/DocFooter'
import SEO from '../components/Seo'
import stylesDoc from './Doc.module.scss'
import styles from './ApiSwagger.module.scss'
@ -275,6 +276,11 @@ export default class ApiSwaggerTemplate extends Component {
)}
<Paths paths={paths} />
<DocFooter
url={`https://github.com/oceanprotocol/${title.toLowerCase()}`}
externalName={`${title} Swagger spec`}
/>
</article>
</main>
</Content>