Skip to content

Commit

Permalink
feat(preview): prévisualise un corpus
Browse files Browse the repository at this point in the history
  • Loading branch information
thom4parisot committed Jan 9, 2025
1 parent 8c6c160 commit d6386a5
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions front/src/components/Preview.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,20 @@ function mapContent({ query, data }) {
bib_content: root?.bib,
}
} else if (query === 'getCorpus') {
return {
md_content: '',
metadata_content: '',
bib_content: '',
}
return data?.corpus?.at(0)?.articles?.reduce(
(obj, { article }) => ({
md_content: obj.md_content + '\n' + article.workingVersion.md,
metadata_content: Object.keys(obj.metadata_content).length
? { ...data.corpus.metadata, ...obj.metadata_content }
: article.workingVersion.metadata,
bib_content: obj.md_content + '\n' + article.workingVersion.bib,
}),
{
md_content: '',
metadata_content: {},
bib_content: '',
}
)
}

throw Error('Unknown query mapping. Cannot preview this content.')
Expand Down

0 comments on commit d6386a5

Please sign in to comment.