|
1 | 1 | import { ref, computed } from 'vue' |
2 | 2 | import { AuthorsType, CffType, IdentifiersType, KeywordsType, TypeType } from '../types' |
3 | 3 |
|
4 | | -const cffInitialValue = { |
5 | | - abstract: undefined, |
6 | | - authors: [], |
7 | | - cffVersion: '1.2.0', |
8 | | - commit: undefined, |
9 | | - dateReleased: undefined, |
10 | | - identifiers: undefined, |
11 | | - keywords: undefined, |
12 | | - license: undefined, |
13 | | - message: undefined, |
14 | | - repository: undefined, |
15 | | - repositoryArtifact: undefined, |
16 | | - repositoryCode: undefined, |
17 | | - title: undefined, |
18 | | - type: 'software', |
19 | | - url: undefined, |
20 | | - version: undefined |
| 4 | +const getInitialData = () => { |
| 5 | + return { |
| 6 | + abstract: undefined, |
| 7 | + authors: [], |
| 8 | + cffVersion: '1.2.0', |
| 9 | + commit: undefined, |
| 10 | + dateReleased: undefined, |
| 11 | + identifiers: undefined, |
| 12 | + keywords: undefined, |
| 13 | + license: undefined, |
| 14 | + message: undefined, |
| 15 | + repository: undefined, |
| 16 | + repositoryArtifact: undefined, |
| 17 | + repositoryCode: undefined, |
| 18 | + title: undefined, |
| 19 | + type: 'software', |
| 20 | + url: undefined, |
| 21 | + version: undefined |
| 22 | + } as CffType |
21 | 23 | } |
22 | 24 |
|
23 | | -const cff = ref(cffInitialValue as CffType) |
| 25 | +const cff = ref(getInitialData()) |
24 | 26 |
|
25 | 27 | export function useCff () { |
26 | 28 | return { |
@@ -56,7 +58,7 @@ export function useCff () { |
56 | 58 | setUrl: (newUrl: string) => { cff.value.url = newUrl === '' ? undefined : newUrl }, |
57 | 59 | setVersion: (newVersion: string) => { cff.value.version = newVersion === '' ? undefined : newVersion }, |
58 | 60 | reset: () => { |
59 | | - cff.value = cffInitialValue as CffType |
| 61 | + cff.value = getInitialData() |
60 | 62 | } |
61 | 63 | } |
62 | 64 | } |
0 commit comments