mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-28 00:17:14 +02:00
refactor: use docusaurus structure
This commit is contained in:
parent
44eb7655ca
commit
45cf88e059
24 changed files with 152 additions and 123 deletions
|
@ -1,5 +1,6 @@
|
|||
module.exports = async function build(sourceDir, cliOptions = {}) {
|
||||
module.exports = async function build(siteDir, cliOptions = {}) {
|
||||
process.env.NODE_ENV = 'production';
|
||||
console.log('Build command invoked ...');
|
||||
console.log(siteDir);
|
||||
console.log(cliOptions);
|
||||
console.log('Build');
|
||||
};
|
||||
|
|
7
lib/commands/init.js
Normal file
7
lib/commands/init.js
Normal file
|
@ -0,0 +1,7 @@
|
|||
module.exports = async function init(projectDir, cliOptions = {}) {
|
||||
console.log('Init command invoked ...');
|
||||
console.log(projectDir);
|
||||
console.log(cliOptions);
|
||||
|
||||
// TODO
|
||||
};
|
|
@ -16,22 +16,22 @@ const load = require('../loader');
|
|||
const createDevConfig = require('../webpack/dev');
|
||||
|
||||
async function getPort(port) {
|
||||
portfinder.basePort = parseInt(port, 10) || 8080;
|
||||
portfinder.basePort = parseInt(port, 10) || 3000;
|
||||
return await portfinder.getPortPromise();
|
||||
}
|
||||
|
||||
module.exports = async function dev(sourceDir, cliOptions = {}) {
|
||||
module.exports = async function start(siteDir, cliOptions = {}) {
|
||||
// load site props from preprocessed files in source directory
|
||||
const props = await load(sourceDir);
|
||||
const props = await load(siteDir);
|
||||
|
||||
// Reload for any add/change/remove of file
|
||||
const reload = () => {
|
||||
load(sourceDir).catch(err => {
|
||||
load(siteDir).catch(err => {
|
||||
console.error(chalk.red(err.stack));
|
||||
});
|
||||
};
|
||||
const fsWatcher = chokidar.watch(['**/*.md', 'config.js'], {
|
||||
cwd: sourceDir,
|
||||
cwd: siteDir,
|
||||
ignoreInitial: true
|
||||
});
|
||||
fsWatcher.on('add', reload);
|
||||
|
@ -47,7 +47,7 @@ module.exports = async function dev(sourceDir, cliOptions = {}) {
|
|||
let config = createDevConfig(props);
|
||||
config.plugin('WebpackNiceLog').use(webpackNiceLog, [
|
||||
{
|
||||
name: 'Blogi',
|
||||
name: 'Munseo',
|
||||
onDone: () => {
|
||||
console.log(
|
||||
`\n${chalk.blue('Development server available at ')}${chalk.cyan(
|
||||
|
@ -89,7 +89,7 @@ module.exports = async function dev(sourceDir, cliOptions = {}) {
|
|||
logLevel: 'error',
|
||||
port,
|
||||
add: (app, middleware, options) => {
|
||||
const staticDir = path.resolve(sourceDir, 'public');
|
||||
const staticDir = path.resolve(siteDir, 'public');
|
||||
if (fs.existsSync(staticDir)) {
|
||||
app.use(mount(publicPath, serveStatic(staticDir)));
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue