diff --git a/components/Nav/Navbar.vue b/components/Nav/Navbar.vue index f580e4c8b290b5f5cb7b42c13076cc062341253c..e870e4c8e67b244773a9a8d18c84a93861e49191 100644 --- a/components/Nav/Navbar.vue +++ b/components/Nav/Navbar.vue @@ -38,7 +38,7 @@ const computedNavigation = computed(() => { }); </script> <template> - <v-app-bar :elevation="0" border density="prominent" scroll-behavior="hide"> + <v-app-bar :elevation="0" border density="prominent" scroll-behavior="hide" scroll-threshold="150"> <template #prepend> <v-app-bar-nav-icon @click.stop="drawer = !drawer"></v-app-bar-nav-icon> <!-- <Logo height="45px" /> --> diff --git a/content/3.defense-systems/abi2.md b/content/3.defense-systems/abi2.md index af6bebe3d5c3ac8c5dfe4a5a5f1467adf986ef71..f7175bc53060f9e8a09c7c1f3b17316661531f5d 100644 --- a/content/3.defense-systems/abi2.md +++ b/content/3.defense-systems/abi2.md @@ -18,7 +18,8 @@ relevantAbstracts: The Abi2 system is composed of one protein: Abi_2. -Here is an example found in the RefSeq database: +Here is an example found in the RefSeq database: +  diff --git a/content/3.defense-systems/abia.md b/content/3.defense-systems/abia.md index fc0a3f645015dab1a552bd7302a14a3093e96339..82ca565193c97af2731ff427a6b1ae179251d533 100644 --- a/content/3.defense-systems/abia.md +++ b/content/3.defense-systems/abia.md @@ -19,8 +19,6 @@ relevantAbstracts: # AbiA -:ref{doi=10.1093/nar/gkac467} - The AbiA system have been describe in a total of 2 subsystems. Here is some example found in the RefSeq database: diff --git a/content/3.defense-systems/avs.md b/content/3.defense-systems/avs.md index f0595e0552767458e4fc42f557bd693e1dc21a2f..06614abfcfd0e683c957686a97c8d0b8648ff456 100644 --- a/content/3.defense-systems/avs.md +++ b/content/3.defense-systems/avs.md @@ -11,6 +11,9 @@ tableColumns: Effector: Diverse effectors (Nucleic acid degrading, putative Nucleotide modifying, putative Membrane disrupting) PFAM: PF00753, PF13289, PF13365 +relevantAbstracts: + - doi: 10.1126/science.aba0372 + - doi: 10.1126/science.abm4096 --- # Avs @@ -173,12 +176,4 @@ Subsystem CcAvs4 with a system from *Corallococcus coralloides* in *Escherichia ## Relevant abstracts -::relevant-abstracts ---- -items: - - doi: 10.1126/science.aba0372 - - doi: 10.1126/science.abm4096 - ---- -:: - + diff --git a/package-lock.json b/package-lock.json index 484806b25bc89ba9105f0198aec73bacc0b5943f..eb72b2f9a328342a1546f57261da38ee4fccf69e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -7,6 +7,7 @@ "dependencies": { "@observablehq/plot": "^0.6.11", "@pinia/nuxt": "^0.4.11", + "d3": "^7.8.5", "meilisearch": "^0.35.0", "pinia": "^2.1.6", "vue-json-csv": "^2.1.0", @@ -2625,7 +2626,8 @@ }, "node_modules/d3": { "version": "7.8.5", - "license": "ISC", + "resolved": "https://registry.npmjs.org/d3/-/d3-7.8.5.tgz", + "integrity": "sha512-JgoahDG51ncUfJu6wX/1vWQEqOflgXyl4MaHqlcSruTez7yhaRKR9i8VjjcQGeS2en/jnFivXuaIMnseMMt0XA==", "dependencies": { "d3-array": "3", "d3-axis": "3", diff --git a/package.json b/package.json index fc09b4037ca9d62846fdf2b53f4302e39a8cf9a8..a438a08f64d2d78a897db005c41a56bfe2bbfef0 100644 --- a/package.json +++ b/package.json @@ -20,9 +20,10 @@ "dependencies": { "@observablehq/plot": "^0.6.11", "@pinia/nuxt": "^0.4.11", - "yaml": "^2.3.3", + "d3": "^7.8.5", "meilisearch": "^0.35.0", "pinia": "^2.1.6", - "vue-json-csv": "^2.1.0" + "vue-json-csv": "^2.1.0", + "yaml": "^2.3.3" } } diff --git a/server/plugins/content.ts b/server/plugins/content.ts index f20c59b59606f25a79a0a46618bf5dbad6e1bc06..878a8d231c136c40b6ea15379a9727a6569ac4b2 100644 --- a/server/plugins/content.ts +++ b/server/plugins/content.ts @@ -1,4 +1,8 @@ import YAML from 'yaml' +import * as d3 from "d3"; + + + export default defineNitroPlugin((nitroApp) => { nitroApp.hooks.hook('content:file:beforeParse', @@ -11,19 +15,8 @@ export default defineNitroPlugin((nitroApp) => { 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") + // file.body = file.body.replace(/(^#[\s+]\w*[\s\S])/gm, "$1\n:contributors\n\n") } - // try to look at :ref{doi=xxxx} - // const matchRef = file.body.match(/(?<=:ref{doi=).*(?=})/gm) - // if (matchRef?.length > 0) { - - // // put the ref found in references list - // const filteredMatchRef = Array.from(new Set(matchRef)).map((doi: string) => ({ doi })) - // parsedFrontMatter.references = filteredMatchRef - // const newFrontMatterStr = YAML.stringify(parsedFrontMatter) - // file.body = file.body.replace(/---\n(.*?)\n---/gs, `---\n${newFrontMatterStr}\n---`) - // } - } } }) @@ -33,44 +26,55 @@ export default defineNitroPlugin((nitroApp) => { 'content:file:afterParse', (file) => { if (file?._id?.startsWith('content:3.defense-systems:') && file._id.endsWith('.md')) { - if (file?.body?.children?.length > 0) { - // console.log("====================") - // console.log(file.contributors) - // console.log("dans after") - // console.log(file._id) - // console.log(file?.title) - // console.log(file?.layout) - - // get the ref tags - // console.log(file.body.children.length) - const refTags = file.body.children - .filter(({ tag, props }) => tag === "ref" && props?.doi) - .reduce((acc, curr) => { - // console.log(curr) - // console.log(acc) - acc.add(curr.props.doi) - return acc - }, new Set()) - // console.log(refTags) - if (refTags.size > 0) file.references = Array.from(refTags).map(doi => ({ doi })) - - // console.log(file.references) - // console.log(file.body.children.slice(4))} - file.body.children.push({ - type: "element", - tag: 'relevant-abstracts', - props: {}, - children: [] - }) + // has contributors + if (file?.contributors?.length > 0) { + console.log("has contributors") + console.log(file.body.children.slice(0, 2)) + const h1Index = file.body.children.findIndex(({ tag }) => tag === "h1") + if (h1Index >= 0) { + file.body.children.splice(h1Index + 1, 0, { + type: "element", + tag: 'contributors', + props: {}, + children: [] + }) + } + } - file.body.children.push({ - type: "element", - tag: 'references', - props: {}, - children: [] + const root = d3.hierarchy(file.body) + const refNodes = [] + root.eachAfter(({ data }) => { + if (data?.tag === 'ref') refNodes.push(data) }) + const refTags = new Set( + refNodes + .map(({ props }) => props?.doi ?? null) + .filter(doi => doi !== null) + ) + 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: [] + }) + } + 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: [] + }) + } } } })