Update example files and examples script

This commit is contained in:
Frank Li 2017-08-09 14:18:17 -07:00
parent ac3cc01830
commit c3a971f2eb
24 changed files with 319 additions and 112 deletions

View file

@ -2,7 +2,7 @@
title: Blog Title
author: Blog Author
authorURL: http://twitter.com/
authorFBID: 0
authorFBID: 100002976521003
---
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque elementum dignissim ultricies. Fusce rhoncus ipsum tempor eros aliquam consequat. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus elementum massa eget nulla aliquet sagittis. Proin odio tortor, vulputate ut odio in, ultrices ultricies augue. Cras ornare ultrices lorem malesuada iaculis. Etiam sit amet libero tempor, pulvinar mauris sed, sollicitudin sapien.

View file

@ -2,7 +2,7 @@
title: New Blog Post
author: Blog Author
authorURL: http://twitter.com/
authorFBID: 0
authorFBID: 100002976521003
---
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque elementum dignissim ultricies. Fusce rhoncus ipsum tempor eros aliquam consequat. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus elementum massa eget nulla aliquet sagittis. Proin odio tortor, vulputate ut odio in, ultrices ultricies augue. Cras ornare ultrices lorem malesuada iaculis. Etiam sit amet libero tempor, pulvinar mauris sed, sollicitudin sapien.

View file

@ -16,6 +16,7 @@ const GridBlock = CompLibrary.GridBlock;
const siteConfig = require(process.cwd() + "/siteConfig.js");
class Help extends React.Component {
render() {
const supportLinks = [
{
@ -49,8 +50,4 @@ class Help extends React.Component {
}
}
Help.defaultProps = {
language: "en"
};
module.exports = Help;

View file

@ -44,7 +44,9 @@ class HomeSplash extends React.Component {
<div className="inner">
<h2 className="projectTitle">
{siteConfig.title}
<small>{siteConfig.tagline}</small>
<small>
{siteConfig.tagline}
</small>
</h2>
<div className="section promoSection">
<div className="promoRow">
@ -52,14 +54,20 @@ class HomeSplash extends React.Component {
<Button href="#try">Try It Out</Button>
<Button
href={
siteConfig.baseUrl + "docs/" + this.props.language + "/doc1.html"
siteConfig.baseUrl +
"docs/" +
this.props.language +
"/doc1.html"
}
>
Example Link
</Button>
<Button
href={
siteConfig.baseUrl + "docs/" + this.props.language + "/doc2.html"
siteConfig.baseUrl +
"docs/" +
this.props.language +
"/doc2.html"
}
>
Example Link 2
@ -177,9 +185,8 @@ class Index extends React.Component {
href={
siteConfig.baseUrl + this.props.language + "/" + "users.html"
}
target="_self"
>
More "Docusaurus" Users
More Docusaurus Users
</a>
</div>
</div>

View file

@ -49,8 +49,4 @@ class Users extends React.Component {
}
}
Users.defaultProps = {
language: "en"
};
module.exports = Users;

View file

@ -0,0 +1,46 @@
/**
* Copyright (c) 2017-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
/* List of projects/orgs using your project for the users page */
const users = [
{
caption: "User1",
image: "/test-site/img/docusaurus.svg",
infoLink: "https://www.example.com",
pinned: true
}
];
const siteConfig = {
title: "Test Site" /* title for your website */,
tagline: "A website for testing",
url: "https://deltice.github.io" /* your github url */,
baseUrl: "/test-site/" /* base url for your project */,
projectName: "test-site",
headerLinks: [
{ doc: "doc1", label: "Docs" },
{ doc: "doc4", label: "API" },
{ page: "help", label: "Help" },
{ blog: true, label: "Blog" }
],
users,
/* path to images for header/footer */
headerIcon: "img/docusaurus.svg",
footerIcon: "img/docusaurus.svg",
favicon: "img/favicon.png",
/* colors for website */
colors: {
primaryColor: "#2E8555",
secondaryColor: "#205C3B",
prismColor:
"rgba(46, 133, 85, 0.03)" /* primaryColor in rgba form, with 0.03 alpha */
}
};
module.exports = siteConfig;

View file

Before

Width:  |  Height:  |  Size: 76 KiB

After

Width:  |  Height:  |  Size: 76 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 984 B

After

Width:  |  Height:  |  Size: 984 B

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 9.4 KiB

After

Width:  |  Height:  |  Size: 9.4 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 4.3 KiB

After

Width:  |  Height:  |  Size: 4.3 KiB

Before After
Before After

View file

@ -1,74 +0,0 @@
/**
* Copyright (c) 2017-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
/* List of projects/orgs using your project for the users page */
const users = [
{
caption: "User1",
image: "/test-site/img/docusaurus.svg",
infoLink: "https://www.example.com",
pinned: true
}
];
const siteConfig = {
title: "Test Site" /* title for your website */,
url: "https://deltice.github.io" /* your github url */,
baseUrl: "/test-site/" /* base url for your project */,
projectName: "test-site",
repo: "deltice/test-site" /* repo for your project */,
users,
/* base url for editing docs, usage example: editUrl + 'en/doc1.md' */
editUrl: "https://github.com/deltice/test-site/edit/master/docs/",
/* header links for links on this site, 'LANGUAGE' will be replaced by whatever
language the page is for, ex: 'en' */
headerLinksInternal: [
{
section: "docs",
href: "/test-site/docs/LANGUAGE/doc1.html",
text: "Docs"
},
{ section: "api", href: "/test-site/docs/LANGUAGE/doc4.html", text: "API" },
{ section: "help", href: "/test-site/LANGUAGE/help.html", text: "Help" },
{ section: "blog", href: "/test-site/blog", text: "Blog" }
],
/* header links for links outside the site */
headerLinksExternal: [
{
section: "github",
href: "https://github.com/deltice/test-site",
text: "GitHub"
}
],
/* path to images for header/footer */
headerIcon: "img/docusaurus.svg",
disableHeaderTitle: false /* disable title text in header (only show headerIcon) */,
footerIcon: "img/docusaurus.svg",
favicon: "img/favicon.png",
/* colors for website */
colors: {
primaryColor: "#2E8555",
secondaryColor: "#205C3B",
prismColor:
"rgba(46, 133, 85, 0.03)" /* primaryColor in rgba form, with 0.03 alpha */
},
tagline: "My Tagline",
recruitingLink:
"https://crowdin.com/project/test-site" /* translation site "help translate" link */,
/* remove this section to disable search bar */
algolia: {
apiKey:
"0f9f28b9ab9efae89810921a351753b5" /* use your search-only api key */,
indexName: "github"
}
/* remove this to disable google analytics tracking */
/* gaTrackingId: "" */
};
module.exports = siteConfig;

View file

@ -6,7 +6,7 @@ preserve_hierarchy: true
files:
-
source: '/docs/en/*.md'
translation: '/docs/%locale%/%original_file_name%'
translation: '/website/translated_docs/%locale%/%original_file_name%'
languages_mapping: &anchor
locale:
'af': 'af'

View file

@ -0,0 +1,92 @@
const React = require("react");
const CompLibrary = require("../../core/CompLibrary");
const Container = CompLibrary.Container;
const GridBlock = CompLibrary.GridBlock;
const CWD = process.cwd();
const siteConfig = require(CWD + "/siteConfig.js");
const versions = require(CWD + "/versions.json");
class Versions extends React.Component {
render() {
const latestVersion = versions[0];
return (
<div className="docMainWrapper wrapper">
<Container className="mainContainer versionsContainer">
<div className="post">
<header className="postHeader">
<h2>{siteConfig.title + " Versions"}</h2>
</header>
<p>New versions of this project are released every so often.</p>
<a name="latest" />
<h3>Current version (Stable)</h3>
<table className="versions">
<tbody>
<tr>
<th>
{latestVersion}
</th>
<td>
<a href={""}>Documentation</a>
</td>
<td>
<a href={""}>Release Notes</a>
</td>
</tr>
</tbody>
</table>
<p>
This is the version that is configured automatically when you
first install this project.
</p>
<a name="rc" />
<h3>Pre-release versions</h3>
<table className="versions">
<tbody>
<tr>
<th>master</th>
<td>
<a href={""}>Documentation</a>
</td>
<td>
<a href={""}>Release Notes</a>
</td>
</tr>
</tbody>
</table>
<p>Other text describing this section.</p>
<a name="archive" />
<h3>Past Versions</h3>
<table className="versions">
<tbody>
{versions.map(
version =>
version !== latestVersion &&
<tr>
<th>
{version}
</th>
<td>
<a href={""}>Documentation</a>
</td>
<td>
<a href={""}>Release Notes</a>
</td>
</tr>
)}
</tbody>
</table>
<p>
You can find past versions of this project{" "}
<a href="https://github.com/"> on GitHub </a>.
</p>
</div>
</Container>
</div>
);
}
}
module.exports = Versions;

View file

@ -13,34 +13,176 @@ const CWD = process.cwd();
const fs = require("fs-extra");
const path = require("path");
const glob = require("glob");
const chalk = require("chalk");
let examplesFolder = "examples";
if (process.argv.indexOf("translations") !== -1) {
examplesFolder = "examples-translations";
}
const files = glob.sync(path.join(__dirname, "..", examplesFolder, "**"));
files.forEach(file => {
if (!fs.lstatSync(file).isDirectory()) {
let target = CWD;
if (file.includes("-examples")) {
target = path.join(CWD, "..");
}
let fileName = file.substring(
file.indexOf(examplesFolder) + examplesFolder.length
let feature;
const program = require("commander");
program
.arguments("[feature]")
.action(feat => {
feature = feat;
})
.parse(process.argv);
const outerFolder = path.basename(path.dirname(CWD));
if (feature === "translations") {
const folder = path.join(__dirname, "..", "examples", "translations");
if (fs.existsSync(CWD + "/../crowdin.yaml")) {
console.log(
`${chalk.yellow("crowdin.yaml already exists")} in ${chalk.yellow(
outerFolder + "/"
)}. Rename or remove the file to regenerate an example version.\n`
);
} else {
fs.copySync(folder + "/crowdin.yaml", CWD + "/../crowdin.yaml");
console.log(
`${chalk.green("Example crowdin.yaml file created")} in ${chalk.yellow(
outerFolder + "/"
)}.\n`
);
}
let files = glob.sync(folder + "/**/*");
files.forEach(file => {
if (fs.lstatSync(file).isDirectory()) {
return;
}
if (path.basename(file) === "crowdin.yaml") {
return;
}
const filePath = file.split(folder)[1];
try {
fs.copySync(file, path.join(target, fileName), {
fs.copySync(file, CWD + filePath, {
overwrite: false,
errorOnExist: true
});
console.log(fileName + " created in " + path.basename(target));
console.log(
`${chalk.green(
"Example " + path.basename(filePath) + " file created"
)} in ${chalk.yellow(
"website" + filePath.split(path.basename(filePath))[0]
)}.\n`
);
} catch (e) {
console.log(
fileName +
" already exists in " +
path.basename(target) +
". Remove or rename the file to regenerate this example file."
`${chalk.yellow(
path.basename(filePath) + " already exists"
)} in ${chalk.yellow(
"website" + filePath.split(path.basename(filePath))[0]
)}. Rename or remove the file to regenerate an example version.\n`
);
}
});
} else if (feature === "versions") {
const folder = path.join(__dirname, "..", "examples", "versions");
let files = glob.sync(folder + "/**/*");
files.forEach(file => {
if (fs.lstatSync(file).isDirectory()) {
return;
}
const filePath = file.split(folder)[1];
try {
fs.copySync(file, CWD + filePath, {
overwrite: false,
errorOnExist: true
});
console.log(
`${chalk.green(
"Example " + path.basename(filePath) + " file created"
)} in ${chalk.yellow(
"website" + filePath.split(path.basename(filePath))[0]
)}.\n`
);
} catch (e) {
console.log(
`${chalk.yellow(
path.basename(filePath) + " already exists"
)} in ${chalk.yellow(
"website" + filePath.split(path.basename(filePath))[0]
)}. Rename or remove the file to regenerate an example version.\n`
);
}
});
} else {
const folder = path.join(__dirname, "..", "examples", "basics");
// copy docs examples
if (fs.existsSync(CWD + "/../docs-examples-from-docusaurus")) {
console.log(
`${chalk.yellow(
"Example docs already exist!"
)} Rename or remove ${chalk.yellow(
outerFolder + "/docs-examples-from-docusaurus"
)} to regenerate example docs.\n`
);
} else {
fs.copySync(
folder + "/docs-examples-from-docusaurus",
CWD + "/../docs-examples-from-docusaurus"
);
console.log(
`${chalk.green("Example docs created")} in ${chalk.yellow(
outerFolder + "/docs-examples-from-docusaurus"
)}! Rename the folder to ${chalk.yellow(
outerFolder + "/docs"
)} to see the example docs on your site.\n`
);
}
});
// copy blog examples
if (fs.existsSync(CWD + "/blog-examples-from-docusaurus")) {
console.log(
`${chalk.yellow(
"Example blog posts already exist!"
)} Rename or remove ${chalk.yellow(
outerFolder + "/website/blog-examples-from-docusaurus"
)} to regenerate example blog posts.\n`
);
} else {
fs.copySync(
path.join(folder, "blog-examples-from-docusaurus"),
path.join(CWD, "blog-examples-from-docusaurus")
);
console.log(
`${chalk.green("Example blog posts created")} in ${chalk.yellow(
outerFolder + "/website/blog-examples-from-docusaurus"
)}! Rename the folder to ${chalk.yellow(
outerFolder + "/website/blog"
)} to see the example blog posts on your site.\n`
);
}
// copy other files
let files = glob.sync(folder + "/**/*");
files.forEach(file => {
if (fs.lstatSync(file).isDirectory()) {
return;
}
const containingFolder = path.basename(path.dirname(file));
if (
containingFolder === "blog-examples-from-docusaurus" ||
containingFolder === "docs-examples-from-docusaurus"
) {
return;
}
const filePath = file.split(folder)[1];
try {
fs.copySync(file, CWD + filePath, {
overwrite: false,
errorOnExist: true
});
console.log(
`${chalk.green(
"Example " + path.basename(filePath) + " file created"
)} in ${chalk.yellow(
"website" + filePath.split(path.basename(filePath))[0]
)}.\n`
);
} catch (e) {
console.log(
`${chalk.yellow(
path.basename(filePath) + " already exists"
)} in ${chalk.yellow(
"website" + filePath.split(path.basename(filePath))[0]
)}. Rename or remove the file to regenerate an example version.\n`
);
}
});
}

View file

@ -11,6 +11,7 @@
"babel-register": "^6.24.1",
"babel-traverse": "^6.25.0",
"babylon": "^6.17.4",
"chalk": "^2.1.0",
"classnames": "^2.2.5",
"commander": "^2.11.0",
"diff": "^3.3.0",