-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cfc63c1
commit fe31a5c
Showing
5 changed files
with
133 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,34 @@ | ||
const Site = require('./site'); | ||
const chalk = require('chalk'); | ||
|
||
const Site = require('./site'); | ||
const runTask = require('./utils/runTask'); | ||
|
||
module.exports = async function(args) { | ||
const site = new Site(); | ||
try { | ||
const site = new Site(); | ||
|
||
const build = [ | ||
'cleanBuild', | ||
[ | ||
'copyCNAME', | ||
'generatePostsFromMarkdown', | ||
'generatePages', | ||
'generatePagesForTags', | ||
'copyMinorStaticAssets', | ||
'copyMajorStaticAssets' | ||
] | ||
]; | ||
const build = [ | ||
'cleanBuild', | ||
[ | ||
'copyCNAME', | ||
'generatePostsFromMarkdown', | ||
'generatePages', | ||
'generatePagesForTags', | ||
'copyMinorStaticAssets', | ||
'copyMajorStaticAssets' | ||
] | ||
]; | ||
|
||
const server = [...build, 'startServer']; | ||
const server = [...build, 'startServer']; | ||
|
||
const [task] = args; | ||
try { | ||
const [task] = args; | ||
if (['s', 'server'].includes(task)) { | ||
await runTask(server, site); | ||
} else { | ||
await runTask(build, site); | ||
} | ||
} catch (error) { | ||
console.log(chalk.red(`${error.message}\n`)); | ||
process.exit(1); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
const fs = require('fs-extra'); | ||
const sitemap = require('sitemap'); | ||
|
||
const { BUILD } = require('../utils/constants'); | ||
|
||
module.exports = async function(site) { | ||
try { | ||
let siteConfig = site.getConfig(); | ||
let options = { | ||
hostname: siteConfig.domain | ||
}; | ||
|
||
const siteMapForSite = sitemap.createSitemap({ options }); | ||
fs.writeFileSync(`${BUILD}/sitemap.xml`, siteMapForSite.toString()); | ||
} catch (error) { | ||
throw error; | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters