mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-12 08:37:25 +02:00
Move Docusaurus 1 files into directory (#966)
* Move Docusaurus 1 into v1 directory * Update Circle CI commands for new v1 dir * Remove OC * Fix tests
This commit is contained in:
parent
9d4a5d5359
commit
f2927a9fc4
291 changed files with 7591 additions and 6532 deletions
78
v1/lib/core/Doc.js
Normal file
78
v1/lib/core/Doc.js
Normal file
|
@ -0,0 +1,78 @@
|
|||
/**
|
||||
* 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 React = require('react');
|
||||
const MarkdownBlock = require('./MarkdownBlock.js');
|
||||
|
||||
const translate = require('../server/translate.js').translate;
|
||||
|
||||
const editThisDoc = translate(
|
||||
'Edit this Doc|recruitment message asking to edit the doc source',
|
||||
);
|
||||
const translateThisDoc = translate(
|
||||
'Translate this Doc|recruitment message asking to translate the docs',
|
||||
);
|
||||
|
||||
// inner doc component for article itself
|
||||
class Doc extends React.Component {
|
||||
render() {
|
||||
let docSource = this.props.source;
|
||||
|
||||
if (this.props.version && this.props.version !== 'next') {
|
||||
// If versioning is enabled and the current version is not next, we need to trim out "version-*" from the source if we want a valid edit link.
|
||||
docSource = docSource.match(new RegExp(/version-.*\/(.*\.md)/, 'i'))[1];
|
||||
}
|
||||
|
||||
const editUrl =
|
||||
this.props.metadata.custom_edit_url ||
|
||||
(this.props.config.editUrl && this.props.config.editUrl + docSource);
|
||||
let editLink = editUrl && (
|
||||
<a
|
||||
className="edit-page-link button"
|
||||
href={editUrl}
|
||||
target="_blank"
|
||||
rel="noreferrer noopener">
|
||||
{editThisDoc}
|
||||
</a>
|
||||
);
|
||||
|
||||
// If internationalization is enabled, show Recruiting link instead of Edit Link.
|
||||
if (
|
||||
this.props.language &&
|
||||
this.props.language !== 'en' &&
|
||||
this.props.config.translationRecruitingLink
|
||||
) {
|
||||
editLink = (
|
||||
<a
|
||||
className="edit-page-link button"
|
||||
href={`${this.props.config.translationRecruitingLink}/${
|
||||
this.props.language
|
||||
}`}
|
||||
target="_blank"
|
||||
rel="noreferrer noopener">
|
||||
{translateThisDoc}
|
||||
</a>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="post">
|
||||
<header className="postHeader">
|
||||
{editLink}
|
||||
{!this.props.hideTitle && (
|
||||
<h1 className="postHeaderTitle">{this.props.title}</h1>
|
||||
)}
|
||||
</header>
|
||||
<article>
|
||||
<MarkdownBlock>{this.props.content}</MarkdownBlock>
|
||||
</article>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Doc;
|
Loading…
Add table
Add a link
Reference in a new issue