Skip to content

Commit 177f978

Browse files
committed
Reorganize the project since v2 does not require website directory
1 parent bc3be6f commit 177f978

40 files changed

+59
-278
lines changed

.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
package-lock=false
2+
loglevel=error

website/docusaurus.config.js renamed to docusaurus.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ module.exports = {
109109
],
110110
plugins: [
111111
['@docusaurus/plugin-content-docs', {
112-
path: '../docs',
112+
path: 'docs',
113113
sidebarPath: require.resolve('./sidebars.json'),
114114
// This is a holdover because we set up original docusaurus
115115
// to support translations and v2 doesn't support them yet

gulpfile.js

Lines changed: 23 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -2,60 +2,45 @@
22

33
// This file is only for generating the docs
44
// No need to use any of this if working on the main website
5-
6-
const { src, dest, series } = require('gulp');
7-
const pump = require('pump');
8-
const through2 = require('through2');
5+
const del = require('del');
6+
const gulplog = require('gulplog');
7+
const { series } = require('gulp');
98
const frontMatter = require('gray-matter');
109
const download = require('github-download-directory');
1110

1211
// Exports for task registration
13-
exports.default = series(fetchDocs, convertComments);
12+
exports.default = series(clean, generateDocs);
1413

1514
const owner = 'gulpjs';
1615
const repo = 'gulp';
1716
const directory = 'docs';
18-
const outDirectory = 'converted-docs';
1917

2018
const fmOptions = {
2119
delimiters: ['<!-- front-matter', '-->']
2220
};
2321

24-
function fetchDocs() {
25-
return download(owner, repo, directory, { sha: "master" });
26-
}
27-
28-
function convertComments(cb) {
29-
pump([
30-
// Only process markdown files in the directory we fetched
31-
src('**/*.md', { cwd: directory }),
32-
pluginless(convertToDocusaurus),
33-
// Overwrite the markdown files we fetched
34-
dest(outDirectory)
35-
], cb)
22+
async function clean() {
23+
return del(directory);
3624
}
3725

38-
/* utils */
39-
function convertToDocusaurus(file) {
40-
var config = frontMatter(file.contents, fmOptions);
41-
if (!config.data.id) {
42-
console.error(`File missing front-matter. Path: ${file.path}`);
43-
return; // Filter out any file without frontmatter
44-
}
45-
46-
file.contents = Buffer.from(config.stringify());
26+
async function generateDocs() {
27+
// Fetch
28+
const files = await download.fetchFiles(owner, repo, directory, { sha: "master" });
4729

48-
return file;
49-
}
30+
// Process
31+
const docusaurusFiles = files.reduce((result, {path, contents}) => {
32+
const config = frontMatter(contents, fmOptions);
33+
if (!config.data.id) {
34+
gulplog.debug(`File missing front-matter. Path: ${path}`);
35+
return result;
36+
}
5037

51-
function pluginless(fn) {
52-
return through2.obj(handler);
38+
return result.concat({
39+
path,
40+
contents: Buffer.from(config.stringify())
41+
});
42+
}, []);
5343

54-
function handler(file, _, cb) {
55-
try {
56-
cb(null, fn(file));
57-
} catch(err) {
58-
cb(err);
59-
}
60-
}
44+
// Write
45+
await Promise.all(docusaurusFiles.map(download.output))
6146
}

package.json

Lines changed: 34 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,46 @@
22
"name": "gulpjs.github.io",
33
"version": "0.0.0",
44
"private": true,
5+
"engines": {
6+
"node": ">=8.0.0"
7+
},
58
"scripts": {
6-
"clean": "rm -r docs converted-docs",
79
"fetch-docs": "gulp",
810
"prestart": "npm run fetch-docs",
9-
"start": "cd website && npm run start",
11+
"start": "docusaurus start",
1012
"prebuild": "npm run fetch-docs",
11-
"build": "cd website && npm run build",
12-
"pregh-pages": "npm run fetch-docs",
13-
"gh-pages": "cd website && npm run publish-gh-pages"
14-
},
15-
"engines": {
16-
"node": ">=8.0.0"
13+
"build": "docusaurus build",
14+
"predeploy": "npm run fetch-docs",
15+
"deploy": "docusaurus deploy",
16+
"swizzle": "docusaurus swizzle"
1717
},
1818
"devDependencies": {
19-
"github-download-directory": "^1.1.1",
19+
"@docusaurus/core": "^2.0.0-alpha.50",
20+
"@docusaurus/plugin-content-docs": "^2.0.0-alpha.50",
21+
"@docusaurus/plugin-google-analytics": "^2.0.0-alpha.50",
22+
"@docusaurus/plugin-google-gtag": "^2.0.0-alpha.50",
23+
"@docusaurus/plugin-sitemap": "^2.0.0-alpha.50",
24+
"@docusaurus/theme-classic": "^2.0.0-alpha.50",
25+
"@docusaurus/theme-search-algolia": "^2.0.0-alpha.50",
26+
"del": "^5.1.0",
27+
"github-download-directory": "^1.2.0",
2028
"gray-matter": "^3.1.1",
21-
"gulp": "^4.0.0",
22-
"pump": "^2.0.1",
23-
"through2": "^2.0.3"
29+
"gulp": "^4.0.2",
30+
"gulplog": "^1.0.0",
31+
"react": "^16.13.1",
32+
"react-dom": "^16.13.1",
33+
"remark-admonitions": "^1.2.1"
34+
},
35+
"browserslist": {
36+
"production": [
37+
">0.2%",
38+
"not dead",
39+
"not op_mini all"
40+
],
41+
"development": [
42+
"last 1 chrome version",
43+
"last 1 firefox version",
44+
"last 1 safari version"
45+
]
2446
}
2547
}
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.
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.
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.
File renamed without changes.
File renamed without changes.
File renamed without changes.

website/README.md

Lines changed: 0 additions & 193 deletions
This file was deleted.

website/package.json

Lines changed: 0 additions & 34 deletions
This file was deleted.

0 commit comments

Comments
 (0)