frontmatter.js 486 B

123456789101112131415161718
  1. import matter from 'gray-matter';
  2. const disabledFrontmatterEngine = () => ({});
  3. const frontmatterOptions = {
  4. language: 'yaml',
  5. // Disable JS/JSON frontmatter parsing to avoid executable project content.
  6. // Mirrors Gatsby's mitigation for gray-matter.
  7. engines: {
  8. js: disabledFrontmatterEngine,
  9. javascript: disabledFrontmatterEngine,
  10. json: disabledFrontmatterEngine
  11. }
  12. };
  13. export function parseFrontmatter(content) {
  14. return matter(content, frontmatterOptions);
  15. }