cremeaux/scripts/directus-to-markdown/index.js

22 lines
664 B
JavaScript
Raw Normal View History

2022-02-02 17:38:21 +01:00
import DirectusToMarkdown from '@resilien/directus-to-markdown'
import urlslug from 'url-slug'
const filter = process.env.DRAFT && process.env.DRAFT == 'true' ? '' : { draft: { _eq: 'false' } }
const config = {
collections: {
actualites: {
readManyOption: {
fields: ['title', 'date', 'image', 'image_credit', 'description', 'auteur', 'draft', 'content'],
filter
},
pathBuilder: (article) => {
const [year, month, day] = article.date.split("-")
return `./content/actualites/${year}/${month}/${day}-${urlslug(article.title, { remove: /\./g })}`;
}
}
}
}
new DirectusToMarkdown(config).export();