I'm curious to know the location where gulp-front-matter is storing my front matter information

I'm currently experimenting with the npm package in order to remove certain front matter from a markdown file and then retrieve the stripped markdown content. This leads me to my inquiry regarding the code snippet provided by the module documentation:

var frontMatter = require('gulp-front-matter');

gulp.task('blog-posts', function() {
    gulp.src('./posts/*.md')
        .pipe(frontMatter({          // optional configuration 
            property: 'frontMatter', // property added to file object  
            remove: true // should we remove front-matter header? 
        }))
        .pipe(…); 
    });

There's a comment stating

// property added to the file object
. What exactly does this mean? How can I access the front matter data? To be more precise, how do I reach the 'file' object?

Answer №1

Forget about it. This particular module assumes that users will be utilizing this specific package, granting access to the file object. It seems I've found the solution to my inquiry: gulp-data is aiming to become the go-to method for "attaching data to the file object for other plugins to consume," a concept that is currently lacking a standard in gulp.

Here's the functional code snippet:

var gulp = require('gulp');
var markdown = require('gulp-markdown');
var frontMatter = require('gulp-front-matter');
var data = require('gulp-data');

markdown.marked.setOptions({
    gfm: false
});

gulp.task('default', function () {
    return gulp.src('*.md')
        .pipe(frontMatter({ 
            property: 'pig',
            remove: true 
        }))
        .pipe(data(function(file) {
            console.log(file.pig.layout);
        }))
        .pipe(markdown({tables: true}))
        .pipe(gulp.dest('dist'));

});

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Issue with specific route causing server to throw 500 error

Recently, I have been working on a small school project that involves creating our own API and connecting it to an Angular front end. While following some tutorials, I encountered an issue where my application started throwing internal server error 500 af ...

What methods can be used to selectively intercept routes?

On the /job page, when a user clicks on a job in the Link component, it intercepts the route to /job/<jobId>. Is there a way to conditionally redirect the user to the actual page (rendering the entire page without intercepting the route) without hav ...

What is the process for implementing csrf within a loop?

I'm struggling with implementing CSRF protection within a loop. I have tried various methods but none seem to work for me. Route router.get('/:id', ensureAuthenticated, (req, res) => { res.render('stories/show', storiesV ...

Encountering an issue when attempting to add a CustomResourceDefinition in AKS, specifically when trying to execute it using

I am facing an issue with adding customresourcedeployment in aks. Previously, we were using the V1beta1 version which appears to be deprecated now. I have attempted to transition to the v1 version, but encountered a schema validation error. The original V1 ...

Retrieve the URL with a GET request and remove a specific object

Currently, I am working on developing a CRUD (Create, Read, Update, Delete) App using Express and LowDB. So far, I have successfully implemented the create and read functions, but I am facing issues with the delete function. This is an example of what th ...

Determining the Optimal Time to Utilize Mongoose for Index

I'm trying to understand how indexing works and its impact on query speed. When looking at this example: var FavoriteSchema = new Schema({ user: { type: ObjectId, ref: 'User', required: true, index: true, ...

Updating file extension name in ReactJS: A quick guide

Looking to modify a file name and extension within the react.js public folder. Changing index.html to index.php https://i.stack.imgur.com/zp1Ga.jpg ** ...

Node.js is raising an error because it cannot locate the specified module, even though the path

Currently in the process of developing my own npm package, I decided to create a separate project for testing purposes. This package is being built in typescript and consists of a main file along with several additional module files. In the main file, I ha ...

How to optimize performance in Node/Express by ending long-running POST requests early

As a beginner in Node/Express, I am facing the challenge of managing a series of long-running processes. For example: post to Express endpoint -> save data (can return now) -> handle data -> handle data -> handle data -> another process -> ...

Encountered issue: SyntaxError - An unforeseen token ':' was found

Sorry for the lack of posts around here. If my post is missing anything, I apologize. This marks my venture into the world of APIs using Express and node.js. The code snippet below is throwing an error that reads...SyntaxError: Unexpected token ':&ap ...

Modifying array of objects in mongoose using a specific key within the object's value

When my two EJS forms are submitted, they trigger an HTTP post request to the route /api/users/makePicks/:id. This route interacts with a controller that updates the Users model in my MongoDB database with the NFL picks provided in the EJS form. The goal ...

Troubleshooting bitrate and quality issues in AWS MediaConvert

Whenever I attempt to initiate a MediaConvert job in CBR, VBR, or QVBR mode with Bitrate or MaxBitrate exceeding 250,000, an error occurs. The message reads: "Unable to write to output file [s3:///videos//***/original.mp4]: [Failed to write data: Access D ...

Encountering a malfunction while executing an npm command specified in the package.json file

Currently, I am following a tutorial on Node, React, and Express on Udemy. In the tutorial, when I execute the command npm run data:import I encounter the following error: undefined npm ERR! code ELIFECYCLE npm ERR! errno 1 ...

What is the best way to include the npm packages I installed in my Visual Studio 2017 project within the _Layout file?

After searching through some questions, I came across a few without an answer. To enhance my project, I downloaded packages such as jQuery 3 using npm. In the Dependencies section, it lists npm and shows jquery, bootstrap, and popper. I am unsure how to ...

Using NPM Modules in React Native

Currently, I am in the process of integrating the npm module wallet-address-validator into a React Native application within my expo development environment. To begin, I executed the command: npm install wallet-address-validator Next, I initiated: expo ...

Utilizing node.js for continuous polling in order to retrieve real-time database updates

I recently made the switch from Java server pages to Node JS in order to utilize server push technology. My goal is to create a straightforward application that sends data to users whenever a new record is inserted into a MySQL database. The database nam ...

What is causing the issue with fetching data from MongoDB in my basic web application?

Recently, I have been trying to integrate MongoDB into my Express Node.js web application. Being fairly new to Node.js, I decided to follow a tutorial video [link to video] for guidance. Unfortunately, I encountered some difficulties while setting up the M ...

Leverage the power of npm packages within a Flutter mobile app's webview

I am currently developing a Flutter mobile app and I am interested in incorporating an npm package that utilizes web3.js and offers additional custom features. My understanding is that Dart code in Flutter is not compiled to JavaScript, so I have been lo ...

Troubleshooting the Ui-router refresh problem

I set up my ui-router configuration as follows: app.config(function($stateProvider, $urlRouterProvider, $locationProvider) { $stateProvider .state('home', { url: "/home", templateUrl : 'h ...

Exploring Node.js with the power of EcmaScript through Javascript Mapping

I am currently using Map in NodeJS version 0.10.36 with the harmony flag enabled. While I am able to create a map, set and retrieve data successfully, I am facing issues with other methods such as size, keys(), entries(), and forEach as they are returning ...