slidev-theme-gtlabo 1.0.7 → 1.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -37,11 +37,33 @@ const props = defineProps({
37
37
  }
38
38
  })
39
39
 
40
- // グローバル引用管理の初期化(引用番号のみ管理)
40
+ // グローバル引用管理の初期化
41
41
  if (!window.citationManager) {
42
42
  window.citationManager = {
43
- counter: 1,
44
- citations: new Map() // id -> { number, data, formatted }
43
+ citations: new Map(), // id -> { number, data, formatted }
44
+ citationKeys: Object.keys(citations), // frontmatterのキーの順番を保持
45
+ initialized: false
46
+ }
47
+ }
48
+
49
+ // frontmatterの順番でcitation番号を事前に割り当て
50
+ const initializeCitations = () => {
51
+ if (!window.citationManager.initialized) {
52
+ window.citationManager.citationKeys = Object.keys(citations)
53
+
54
+ window.citationManager.citationKeys.forEach((key, index) => {
55
+ if (!window.citationManager.citations.has(key)) {
56
+ const data = citations[key]
57
+ const newCitation = {
58
+ number: index + 1, // 1から開始
59
+ data: data,
60
+ formatted: formatCitation(data)
61
+ }
62
+ window.citationManager.citations.set(key, newCitation)
63
+ }
64
+ })
65
+
66
+ window.citationManager.initialized = true
45
67
  }
46
68
  }
47
69
 
@@ -59,24 +81,21 @@ const citationData = computed(() => {
59
81
  return data
60
82
  })
61
83
 
62
- // 引用番号を取得または生成
84
+ // 引用番号を取得
63
85
  const citationNumber = computed(() => {
64
86
  if (!citationData.value) {
65
87
  return '?'
66
88
  }
67
89
 
68
- if (!window.citationManager.citations.has(props.id)) {
69
- const newCitation = {
70
- number: window.citationManager.counter,
71
- data: citationData.value,
72
- formatted: formatCitation(citationData.value)
73
- }
74
- window.citationManager.citations.set(props.id, newCitation)
75
- window.citationManager.counter++
76
- }
90
+ // 初期化を確実に実行
91
+ initializeCitations()
77
92
 
78
93
  const citation = window.citationManager.citations.get(props.id)
79
- return citation.number
94
+ if (citation) {
95
+ return citation.number
96
+ }
97
+
98
+ return '?'
80
99
  })
81
100
 
82
101
  // フォーマットされた引用テキスト
@@ -96,7 +115,6 @@ const formattedCitation = computed(() => {
96
115
  // 引用を表示すべきかどうか
97
116
  const shouldShowCitation = computed(() => {
98
117
  const shouldShow = isMounted.value && citationData.value !== null
99
-
100
118
  return shouldShow
101
119
  })
102
120
 
@@ -158,30 +176,30 @@ const formatCitation = (data) => {
158
176
  }
159
177
 
160
178
  const formatted = citation || '引用情報が不完全です'
161
-
162
179
  return formatted
163
180
  }
164
181
 
165
182
  // 全体のグローバル状態をデバッグ出力
166
183
  const debugGlobalState = () => {
184
+ // デバッグ用(必要に応じてコメントアウト)
167
185
  }
168
186
 
169
187
  // コンポーネントのマウント時
170
188
  onMounted(() => {
171
-
172
189
  isMounted.value = true
173
190
 
191
+ // 初期化を確実に実行
192
+ initializeCitations()
193
+
174
194
  if (citationData.value) {
175
- // 引用番号を生成(副作用でglobal stateに保存される)
195
+ // 引用番号を取得(副作用でglobal stateに保存される)
176
196
  const _ = citationNumber.value
177
197
  debugGlobalState()
178
- } else {
179
198
  }
180
199
  })
181
200
 
182
201
  // コンポーネントのアンマウント時
183
202
  onUnmounted(() => {
184
-
185
203
  isMounted.value = false
186
204
  debugGlobalState()
187
205
  })
@@ -17,9 +17,9 @@
17
17
  :key="citation.key"
18
18
  class="citation-item border-l-2 border-sky-400 pl-3 py-1"
19
19
  >
20
- <!-- 引用キー -->
20
+ <!-- 引用番号(frontmatterの順番に基づく) -->
21
21
  <div class="text-sm font-semibold text-sky-700 mb-1">
22
- [{{ citation.key }}]
22
+ [{{ citation.number }}]
23
23
  </div>
24
24
 
25
25
  <!-- 引用情報 -->
@@ -164,19 +164,23 @@ const props = defineProps({
164
164
  // 表示順序
165
165
  sortBy: {
166
166
  type: String,
167
- default: 'key', // 'key', 'author', 'year' など
167
+ default: 'frontmatter', // 'frontmatter', 'key', 'author', 'year' など
168
168
  }
169
169
  })
170
170
 
171
- // 参考文献リストを生成
171
+ // 参考文献リストを生成(frontmatterの順番を維持)
172
172
  const citationsList = computed(() => {
173
173
  if (!citations || typeof citations !== 'object') {
174
174
  return []
175
175
  }
176
176
 
177
- const list = Object.keys(citations).map(key => ({
177
+ // frontmatterの記述順でキーを取得
178
+ const originalKeys = Object.keys(citations)
179
+
180
+ const list = originalKeys.map((key, index) => ({
178
181
  key,
179
- data: citations[key]
182
+ data: citations[key],
183
+ number: index + 1 // frontmatterの順番に基づく番号
180
184
  }))
181
185
 
182
186
  // ソート処理
@@ -194,8 +198,11 @@ const citationsList = computed(() => {
194
198
  return yearB - yearA // 降順(新しい順)
195
199
  })
196
200
  case 'key':
197
- default:
198
201
  return list.sort((a, b) => a.key.localeCompare(b.key))
202
+ case 'frontmatter':
203
+ default:
204
+ // frontmatterの順番を維持(デフォルト)
205
+ return list
199
206
  }
200
207
  })
201
208
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "slidev-theme-gtlabo",
3
- "version": "1.0.7",
3
+ "version": "1.0.8",
4
4
  "description": "A Slidev theme for laboratory presentations with customizable components",
5
5
  "author": "mksmkss",
6
6
  "license": "MIT",
package/uno.config.ts CHANGED
@@ -6,8 +6,8 @@ export default defineConfig({
6
6
  md: '1rem',
7
7
  },
8
8
  colors: {
9
- 'text-main': 'rgba(31, 41, 55, 1)',
10
- 'theme-color': 'rgba(2, 132, 199, 1)',
9
+ 'text-main': '#1f2937',
10
+ 'theme-color': '#0284c7',
11
11
  },
12
12
  },
13
13
  })