Skip to content

Instantly share code, notes, and snippets.

@goofrider
Last active May 18, 2023 18:30
Show Gist options
  • Save goofrider/7951b1bd0ef8d1780c7e4c5f3094e94b to your computer and use it in GitHub Desktop.
Save goofrider/7951b1bd0ef8d1780c7e4c5f3094e94b to your computer and use it in GitHub Desktop.
Regex for Removing YAML Front Matter before processing Jekyll file in Gulp
// taken from https://codepen.io/tech4him1/pen/dNyydZ
var replace = require('gulp-replace');
// Regex to recognize YAML Front Matter (at beginning of file, 3 hyphens, than any charecter, including newlines, then 3 hyphens).
var YAMLFrontMatter = /^---[.\r\n]*---/;
gulp.src('./!(_)**/*.md')
.pipe(replace(YAMLFrontMatter, ''))
.pipe(gulp.dest('./'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment