Using CSV as data file format in Eleventy 3 (using ESM) #3413
-
Hi all! As @pdehaan kindly suggested in #2234 (comment), I have been using this line of code to activate CSV support for data files in Eleventy: module.exports = function(eleventyConfig) {
eleventyConfig.addDataExtension('csv', contents => require('csv-parse/sync').parse(contents, {columns: true, skip_empty_lines: true}));
} By attempting to convert the configuration to ESM in Eleventy 3.0.0.beta1, I am failing to use Does anyone have any suggestions? Thank you so much! |
Beta Was this translation helpful? Give feedback.
Answered by
xplosionmind
Aug 17, 2024
Replies: 1 comment
-
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
}));
} |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
xplosionmind
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I played around a bit, and I found the solution!
Here it is: