diff --git a/composables/useFetchArticle.ts b/composables/useFetchArticle.ts index 59c1e51851cd53369ccd27d4db85c17b86508d28..760b25c9f3b8f8523c732b9ad79f972dc7b0874c 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 1ba95fd2d0584f76814bd6818b4ab794bf0f534a..a28c03bc198d9a37f77cf10e1831765f45fcfc05 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 0000000000000000000000000000000000000000..92f2f10debb602df6ceac169d3b7cc74b202ebfe --- /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