diff --git a/_ci/deploy.sh b/_ci/deploy.sh index 811fba00..8b267cf7 100755 --- a/_ci/deploy.sh +++ b/_ci/deploy.sh @@ -9,6 +9,8 @@ echo "$(tput sgr0)" # reset gulp deploy +gulp seo + echo "$(tput setaf 64)" # green echo "---------------------------------------------" echo " ✓ done S3 deployment " diff --git a/gulpfile.babel.js b/gulpfile.babel.js index ba557b45..be998310 100644 --- a/gulpfile.babel.js +++ b/gulpfile.babel.js @@ -3,12 +3,18 @@ import { src, dest, parallel, series, watch } from 'gulp' import plugins from 'gulp-load-plugins' import del from 'del' -import pkg from './package.json' import parallelize from 'concurrent-transform' import browser from 'browser-sync' import autoprefixer from 'autoprefixer' import cssnano from 'cssnano' import critical from 'critical' +import request from 'request' +import fs from 'fs' +import yaml from 'js-yaml' + +// get all the configs: `pkg` and `site` +import pkg from './package.json' +const site = yaml.safeLoad(fs.readFileSync('./_config.yml')) // load plugins const $ = plugins() @@ -48,8 +54,8 @@ const PORT = 1337 const COMPATIBILITY = ['last 2 versions', 'ie >= 10'] // paths -const SRC = '_src', - DIST = '_site', +const SRC = site.source, + DIST = site.destination, S3BUCKET = 'kremalicious.com', S3PATH = '/', S3REGION = 'eu-central-1' @@ -319,6 +325,33 @@ export const revReplace = (done) => { } +// +// Ping search engines +// +export const seo = (done) => { + + const googleUrl = 'http://www.google.com/webmasters/tools/ping?sitemap=', + bingUrl = 'http://www.bing.com/webmaster/ping.aspx?siteMap=' + + const response = (error, response) => { + if (error) { + $.util.log($.util.colors.red(error)) + } else { + $.util.log($.util.colors.gray('Status:', response && response.statusCode)) + + if (response.statusCode === 200) { + $.util.log($.util.colors.green('Successfully notified')) + } + } + } + + request(googleUrl + site.url + '/sitemap.xml', response) + request(bingUrl + site.url + '/sitemap.xml', response) + + done() +} + + // // Dev Server // diff --git a/package.json b/package.json index c36c0983..7d575b47 100644 --- a/package.json +++ b/package.json @@ -33,6 +33,7 @@ "critical": ">=0.8.4", "cssnano": ">=3.6.2", "del": ">=1.2.0", + "fs": "0.0.1-security", "gulp": "github:gulpjs/gulp#4.0", "gulp-awspublish": ">=2.0.2", "gulp-awspublish-router": ">=0.1.1", @@ -53,7 +54,9 @@ "gulp-stylus": ">=2.3.1", "gulp-svg-sprite": ">=1.2.2", "gulp-uglify": ">=1.2.0", - "gulp-util": ">=3.0.6" + "gulp-util": ">=3.0.6", + "js-yaml": "^3.8.3", + "request": "^2.81.0" }, "engines": { "node": ">=5.0.0"