Skip to content

Using CSV as data file format in Eleventy 3 (using ESM) #3413

Closed Answered by xplosionmind
xplosionmind asked this question in Q&A
Discussion options

You must be logged in to vote

I played around a bit, and I found the solution!

Here it is:

import { parse as csvParse } from 'csv-parse/sync';

export default function(eleventyConfig) {
	eleventyConfig.addDataExtension('csv', contents => csvParse(contents, {
		columns: true,
		skip_empty_lines: true
	}));
}

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by xplosionmind
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant