Skip to content
Snippets Groups Projects
Commit 2ab2d177 authored by Remi  PLANEL's avatar Remi PLANEL
Browse files

merge relevant Abstracts with references

parent 5fcc30a4
No related branches found
No related tags found
1 merge request!131Merge relevant Abstract and references
Pipeline #117801 failed
......@@ -9,32 +9,20 @@ export interface Props {
enumerate?: boolean;
title?: string;
abstract?: string;
isRelevant?: boolean;
}
const props = withDefaults(defineProps<Props>(), {
enumerate: true,
divider: false,
isRelevant: false,
});
// onBeforeMount(async () => {
// await useArticlesStore().initialize()
// })
const { article } = useFetchArticle(props.doi);
const { mobile } = useDisplay();
const show = ref(false);
// const computedArticle = computed(() => { return { ...article.value } })
// watch(article, (newArticle) => {
// console.log("article updated")
// }, { deep: true })
console.log("aritcle dans composant")
console.log(article)
const articleTitle = computed(() => {
return props?.title ?? article?.value?.title ?? props.doi;
......@@ -46,6 +34,9 @@ const articleAbstract = computed(() => {
<template>
<v-list-item :href="article?.href" :id="props.doi" :target="article?.target" density="compact" color="transparent"
class="px-1">
<template #prepend>
<v-icon icon="md:star" :color="props.isRelevant ? 'info' : 'transparent'"></v-icon>
</template>
<template #append>
<v-btn v-if="articleAbstract" size="x-small" variant="plain"
:append-icon="show ? 'mdi-chevron-up' : 'mdi-chevron-down'" class="px-0"
......@@ -91,7 +82,6 @@ const articleAbstract = computed(() => {
.article-ref .v-card-item .v-card-subtitle,
.article-ref .v-card-item * .v-btn {
font-size: 0.8rem !important;
line-height: 1rem !important;
}
......
......@@ -15,11 +15,11 @@ const computedDois = computed(() => {
</script>
<template>
<div v-if="computedDois?.length > 0">
<ProseH2 id="relevant-abstracts">Relevant abstracts</ProseH2>
<ProseH2 id="references">References</ProseH2>
<v-list density="compact" bg-color="transparent">
<ArticleDoi v-for="(item, index) in computedDois" :key="item.doi" :index="index + 1" :doi="item.doi"
:title="item?.title" :divider="item.divider" :abstract="item?.abstract" />
:title="item?.title" :divider="item.divider" :abstract="item?.abstract" :is-relevant="item?.isRelevant ?? false" />
</v-list>
</div>
</template>
\ No newline at end of file
......@@ -5,22 +5,6 @@ import * as d3 from "d3";
export default defineNitroPlugin((nitroApp) => {
// nitroApp.hooks.hook('content:file:beforeParse',
// (file) => {
// if (file?._id?.startsWith('content:3.defense-systems:') && file?._id?.endsWith('.md')) {
// const frontMatterRegex = /(?<=---\n).*?(?=\n---)/sg;
// const fontMatterMatch = file.body.match(frontMatterRegex);
// if (fontMatterMatch?.length > 0) {
// const frontMatter = fontMatterMatch[0]
// const parsedFrontMatter = YAML.parse(frontMatter)
// if (parsedFrontMatter?.contributors?.length > 0) {
// // file.body = file.body.replace(/(^#[\s+]\w*[\s\S])/gm, "$1\n:contributors\n\n")
// }
// }
// }
// })
nitroApp.hooks.hook(
'content:file:afterParse',
......@@ -53,30 +37,38 @@ export default defineNitroPlugin((nitroApp) => {
})
.filter(doi => doi !== null)
)
console.log(refTags)
if (refTags.size > 0) file.references = Array.from(refTags).map(doi => ({ doi }))
// Update the TOC
// if relevant abstract available
if (file?.relevantAbstracts?.length > 0) {
// check if relevant Abstracts exists
file.body.toc.links.push({ id: "relevant-abstracts", depth: 2, text: 'Relevant abstracts' })
file.body.children.push({
type: "element",
tag: 'relevant-abstracts',
props: {},
children: []
})
}
// Add isRelevant flag
file.relevantAbstracts = file.relevantAbstracts.map(article => ({ ...article, isRelevant: true }))
} else { file.relevantAbstracts = [] }
if (file?.references?.length > 0) {
file.body.toc.links.push({ id: "references", depth: 2, text: 'References' })
file.body.children.push({
type: "element",
tag: 'references',
props: {},
children: []
})
// create a set of relevant abstract:
const relevantAbstractsSet = new Set(file.relevantAbstracts.map(art => art.doi))
for (const ref of file.references) {
if (!relevantAbstractsSet.has(ref.doi)) {
file.relevantAbstracts.push(ref)
}
}
}
}
if (file?.relevantAbstracts?.length > 0) {
file.body.toc.links.push({ id: "references", depth: 2, text: 'References' })
file.body.children.push({
type: "element",
tag: 'relevant-abstracts',
props: {},
children: []
})
}
}
})
})
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment