From 7cdf0f60d506e5f56bb03bcc3811fd0bf07b8d96 Mon Sep 17 00:00:00 2001 From: Remi PLANEL <rplanel@pasteur.fr> Date: Mon, 12 Feb 2024 09:33:28 +0100 Subject: [PATCH] Put types in folder types --- composables/useFetchArticle.ts | 38 ++--------------------- stores/articles.ts | 18 +---------- types/articles.ts | 55 ++++++++++++++++++++++++++++++++++ 3 files changed, 58 insertions(+), 53 deletions(-) create mode 100644 types/articles.ts diff --git a/composables/useFetchArticle.ts b/composables/useFetchArticle.ts index 59c1e518..760b25c9 100644 --- a/composables/useFetchArticle.ts +++ b/composables/useFetchArticle.ts @@ -1,48 +1,14 @@ -import { useArticlesStore, type CslJson } from '../stores/articles' +import { useArticlesStore } from '../stores/articles' import { ref, computed, watchEffect, toValue } from "vue" // import { useFetch } from '#app'; // import { useFetch } from "nuxt" import { type MaybeRef, useFetch } from '#imports' -import article from "@/public/articles.json" - -export interface CrossrefArticle { - DOI: string; - issue: number; - type: string; - title: string[]; - author: Array<{ family: string; given: string }>; - // "container-title-short": string; - "short-container-title": string; - "container-title": string; - abstract?: string; - published: { - "date-parts": string[]; - }; - issued: { - "date-parts": string[]; - }; -} +import type { CslJson, CrossrefArticle, SrcArticle } from '@/types/articles'; -export interface WikiArticle { - DOI: string - title: string - subtitle: string - author: Array<{ family: string; given: string }> - containerTitle: string - abstract: string - year: string - href: string - target: string - prependIcon: string -} -export interface RawArticle { - message: CrossrefArticle -} -type SrcArticle = CrossrefArticle | CslJson export function useFetchArticle(doi: MaybeRef<string> = ref("")) { // const article = ref<Article>() diff --git a/stores/articles.ts b/stores/articles.ts index 1ba95fd2..a28c03bc 100644 --- a/stores/articles.ts +++ b/stores/articles.ts @@ -1,24 +1,8 @@ import { defineStore } from 'pinia' import { ref } from 'vue' // import jsonArticles from '@/assets/articles.json' +import type { CslJson } from "@/types/articles" -export interface CslJson { - // id: string - type: string - title: string - "container-title": string - // page: string, - // volume: string, - abstract: string - // URL: string - DOI: string - // journalAbbreviation: string - // language: string - author: Array<{ family: string, given: string }> - issued: { - "date-parts": Array<string> - }, -} export const useArticlesStore = defineStore('articles', () => { const articleMap = new Map([]) diff --git a/types/articles.ts b/types/articles.ts new file mode 100644 index 00000000..92f2f10d --- /dev/null +++ b/types/articles.ts @@ -0,0 +1,55 @@ +export interface WikiArticle { + DOI: string + title: string + subtitle: string + author: Array<{ family: string; given: string }> + containerTitle: string + abstract: string + year: string + href: string + target: string + prependIcon: string +} + +export interface CslJson { + // id: string + type: string + title: string + "container-title": string + // page: string, + // volume: string, + abstract: string + // URL: string + DOI: string + // journalAbbreviation: string + // language: string + author: Array<{ family: string, given: string }> + issued: { + "date-parts": Array<string> + }, +} + +export interface CrossrefArticle { + DOI: string; + issue: number; + type: string; + title: string[]; + author: Array<{ family: string; given: string }>; + // "container-title-short": string; + "short-container-title": string; + "container-title": string; + abstract?: string; + published: { + "date-parts": string[]; + }; + issued: { + "date-parts": string[]; + }; +} + +export interface RawArticle { + message: CrossrefArticle + +} + +export type SrcArticle = CrossrefArticle | CslJson -- GitLab