feat: Mise à jour de l'import

This commit is contained in:
Simon 2022-12-12 10:55:19 +01:00
parent 8cfaf3452a
commit 02975190a4
1 changed files with 6 additions and 4 deletions

View File

@ -1,14 +1,15 @@
import DirectusToMarkdown from '@resilien/directus-to-markdown' import DirectusToMarkdown from '@resilien/directus-to-markdown'
import urlslug from 'url-slug' import urlslug from 'url-slug'
const filter = process.env.DRAFT && process.env.DRAFT == 'true' ? '' : { draft: { _eq: 'false' } } const filterDraft = process.env.DRAFT && process.env.DRAFT == 'true' ? '' : { draft: { _eq: 'false' } }
const filterAssociation = process.env.DRAFT && process.env.DRAFT == 'true' ? '' : { display_website: { _eq: 'true' } }
const config = { const config = {
collections: { collections: {
actualites: { actualites: {
readByQueryOption: { readByQueryOption: {
fields: ['title', 'date', 'image', 'image_credit', 'description', 'auteur', 'draft', 'content'], fields: ['title', 'date', 'image', 'image_credit', 'description', 'auteur', 'draft', 'content'],
filter filterDraft
}, },
pathBuilder: (article) => { pathBuilder: (article) => {
const [year, month, day] = article.date.split("-") const [year, month, day] = article.date.split("-")
@ -28,14 +29,15 @@ const config = {
'bureau.sort', 'bureau.sort',
'bureau.Contact_id.*', 'bureau.Contact_id.*',
'content', 'content',
] ],
filterAssociation
}, },
pathBuilder: (association) => { pathBuilder: (association) => {
if (!association.title) { if (!association.title) {
association.title = association.denomination association.title = association.denomination
} }
console.log("Import de l'association « " + association.title + " »")
if (association.bureau && association.bureau.length > 0) { if (association.bureau && association.bureau.length > 0) {
console.log(association.bureau.length)
const bureau = [] const bureau = []
for (const contact of association.bureau) { for (const contact of association.bureau) {
const detail = contact.Contact_id const detail = contact.Contact_id