slidev-theme-gtlabo 2.1.3 → 2.1.5
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.
- package/components/Citation.vue +12 -9
- package/components/Header.vue +9 -90
- package/package.json +1 -1
package/components/Citation.vue
CHANGED
|
@@ -8,11 +8,19 @@
|
|
|
8
8
|
</template>
|
|
9
9
|
|
|
10
10
|
<script setup>
|
|
11
|
-
import { computed, inject, onMounted, onUnmounted } from 'vue'
|
|
11
|
+
import { computed, inject, onMounted, onUnmounted, isRef } from 'vue'
|
|
12
12
|
import { useSlideContext } from '@slidev/client'
|
|
13
13
|
|
|
14
14
|
const { $slidev, $page } = useSlideContext()
|
|
15
15
|
|
|
16
|
+
// $page を数値として取得するヘルパー
|
|
17
|
+
const getPageNumber = () => {
|
|
18
|
+
if (isRef($page)) {
|
|
19
|
+
return $page.value
|
|
20
|
+
}
|
|
21
|
+
return $page
|
|
22
|
+
}
|
|
23
|
+
|
|
16
24
|
// 方法1: frontmatterから取得(従来通り)
|
|
17
25
|
const frontmatterCitations = $slidev.configs.citations || {}
|
|
18
26
|
|
|
@@ -129,13 +137,10 @@ const formatCitation = (data) => {
|
|
|
129
137
|
|
|
130
138
|
// 現在のページに引用を登録(slide-bottom.vue用)
|
|
131
139
|
const registerCitation = () => {
|
|
132
|
-
const page =
|
|
133
|
-
console.log('=== Citation registerCitation ===')
|
|
134
|
-
console.log('$page:', page)
|
|
135
|
-
console.log('props.id:', props.id)
|
|
140
|
+
const page = getPageNumber()
|
|
136
141
|
|
|
137
142
|
if (!page) {
|
|
138
|
-
console.
|
|
143
|
+
console.warn('Citation: page is null or undefined')
|
|
139
144
|
return
|
|
140
145
|
}
|
|
141
146
|
|
|
@@ -148,13 +153,11 @@ const registerCitation = () => {
|
|
|
148
153
|
pageSet.add(props.id)
|
|
149
154
|
notifyListeners()
|
|
150
155
|
}
|
|
151
|
-
console.log('→ 登録完了')
|
|
152
|
-
console.log('window.pageCitations.data:', [...window.pageCitations.data.entries()])
|
|
153
156
|
}
|
|
154
157
|
|
|
155
158
|
// 現在のページから引用を解除
|
|
156
159
|
const unregisterCitation = () => {
|
|
157
|
-
const page =
|
|
160
|
+
const page = getPageNumber()
|
|
158
161
|
if (!page) return
|
|
159
162
|
|
|
160
163
|
const pageSet = window.pageCitations.data.get(page)
|
package/components/Header.vue
CHANGED
|
@@ -97,7 +97,7 @@
|
|
|
97
97
|
</template>
|
|
98
98
|
|
|
99
99
|
<script setup>
|
|
100
|
-
import { computed
|
|
100
|
+
import { computed, inject } from 'vue'
|
|
101
101
|
import { useSlideContext } from '@slidev/client'
|
|
102
102
|
|
|
103
103
|
// Slidevコンテキストからconfigsにアクセス
|
|
@@ -115,8 +115,6 @@ const chapters = computed(() => ({
|
|
|
115
115
|
...frontmatterChapters
|
|
116
116
|
}))
|
|
117
117
|
|
|
118
|
-
console.log('Header2.vue - chapters:', chapters.value)
|
|
119
|
-
|
|
120
118
|
const props = defineProps({
|
|
121
119
|
// タイトル用のプロパティ
|
|
122
120
|
chapter: {
|
|
@@ -146,45 +144,27 @@ const isSection = computed(() => {
|
|
|
146
144
|
|
|
147
145
|
// タイトル表示用のデータ
|
|
148
146
|
const displayData = computed(() => {
|
|
149
|
-
console.log('=== displayData 計算開始 ===')
|
|
150
|
-
console.log('props.chapterData:', props.chapterData)
|
|
151
|
-
console.log('props.currentSection:', props.currentSection)
|
|
152
|
-
console.log('props.chapter:', props.chapter)
|
|
153
|
-
console.log('props.currentChapter:', props.currentChapter)
|
|
154
|
-
console.log('chapters.value:', chapters.value)
|
|
155
|
-
|
|
156
147
|
// chapterDataが直接渡された場合はそれを使用
|
|
157
148
|
if (props.chapterData) {
|
|
158
|
-
console.log('→ chapterData を使用')
|
|
159
149
|
return props.chapterData
|
|
160
150
|
}
|
|
161
151
|
|
|
162
152
|
// currentSectionが指定されている場合、セクションデータを取得
|
|
163
153
|
if (props.currentSection && (props.chapter || props.currentChapter)) {
|
|
164
154
|
const chapterKey = props.chapter || props.currentChapter
|
|
165
|
-
console.log('→ セクション検索: chapterKey =', chapterKey)
|
|
166
|
-
|
|
167
155
|
const chapterData = chapters.value[chapterKey]
|
|
168
|
-
console.log('→ chapterData:', chapterData)
|
|
169
|
-
console.log('→ sections:', chapterData?.sections)
|
|
170
|
-
console.log('→ 検索するsection:', props.currentSection)
|
|
171
|
-
console.log('→ sectionData:', chapterData?.sections?.[props.currentSection])
|
|
172
|
-
|
|
173
156
|
if (chapterData?.sections?.[props.currentSection]) {
|
|
174
157
|
return chapterData.sections[props.currentSection]
|
|
175
158
|
}
|
|
176
|
-
console.log('→ セクションが見つかりません')
|
|
177
159
|
return null
|
|
178
160
|
}
|
|
179
161
|
|
|
180
162
|
// chapterキーが渡された場合は内部データから取得
|
|
181
163
|
const chapterKey = props.chapter || props.currentChapter
|
|
182
164
|
if (chapterKey && chapters.value[chapterKey]) {
|
|
183
|
-
console.log('→ 章データを使用')
|
|
184
165
|
return chapters.value[chapterKey]
|
|
185
166
|
}
|
|
186
167
|
|
|
187
|
-
console.log('→ 何も見つかりません')
|
|
188
168
|
return null
|
|
189
169
|
})
|
|
190
170
|
|
|
@@ -203,17 +183,11 @@ const isCurrentPageAppendix = computed(() => {
|
|
|
203
183
|
// 章リストを生成(refを除外し、appendixの表示を条件分岐)
|
|
204
184
|
const chapterList = computed(() => {
|
|
205
185
|
const chaptersData = chapters.value
|
|
206
|
-
console.log('=== chapterList 計算 ===')
|
|
207
|
-
console.log('chaptersData:', chaptersData)
|
|
208
|
-
console.log('typeof chaptersData:', typeof chaptersData)
|
|
209
|
-
console.log('Object.keys:', chaptersData ? Object.keys(chaptersData) : 'null')
|
|
210
|
-
|
|
211
186
|
if (!chaptersData || typeof chaptersData !== 'object') {
|
|
212
|
-
console.log('→ chaptersData が無効')
|
|
213
187
|
return []
|
|
214
188
|
}
|
|
215
189
|
|
|
216
|
-
|
|
190
|
+
return Object.keys(chaptersData)
|
|
217
191
|
.filter(chapterKey => chapterKey !== 'ref')
|
|
218
192
|
.map(chapterKey => {
|
|
219
193
|
const chapter = chaptersData[chapterKey]
|
|
@@ -228,26 +202,15 @@ const chapterList = computed(() => {
|
|
|
228
202
|
isAppendix: chapterKey.startsWith('ap')
|
|
229
203
|
}
|
|
230
204
|
})
|
|
231
|
-
|
|
232
|
-
console.log('chapterList result:', result)
|
|
233
|
-
return result
|
|
234
205
|
})
|
|
235
206
|
|
|
236
207
|
// 表示する章リスト(appendixページかどうかで切り替え)
|
|
237
208
|
const displayChapterList = computed(() => {
|
|
238
|
-
console.log('=== displayChapterList 計算 ===')
|
|
239
|
-
console.log('isCurrentPageAppendix:', isCurrentPageAppendix.value)
|
|
240
|
-
console.log('chapterList:', chapterList.value)
|
|
241
|
-
|
|
242
|
-
let result
|
|
243
209
|
if (isCurrentPageAppendix.value) {
|
|
244
|
-
|
|
210
|
+
return chapterList.value.filter(chapter => chapter.isAppendix)
|
|
245
211
|
} else {
|
|
246
|
-
|
|
212
|
+
return chapterList.value.filter(chapter => !chapter.isAppendix)
|
|
247
213
|
}
|
|
248
|
-
|
|
249
|
-
console.log('displayChapterList result:', result)
|
|
250
|
-
return result
|
|
251
214
|
})
|
|
252
215
|
|
|
253
216
|
// appendixの開始ページを計算(SectionDivider考慮版)
|
|
@@ -255,64 +218,30 @@ const appendixStartPage = computed(() => {
|
|
|
255
218
|
const totalPages = $slidev.nav.total
|
|
256
219
|
const appendixChapters = chapterList.value.filter(chapter => chapter.isAppendix)
|
|
257
220
|
|
|
258
|
-
console.log('appendixStartPage計算:')
|
|
259
|
-
console.log(' totalPages:', totalPages)
|
|
260
|
-
console.log(' appendixChapters:', appendixChapters)
|
|
261
|
-
|
|
262
221
|
if (appendixChapters.length === 0) {
|
|
263
|
-
|
|
264
|
-
return totalPages + 1 // appendixがない場合は存在しないページ番号を返す
|
|
222
|
+
return totalPages + 1
|
|
265
223
|
}
|
|
266
224
|
|
|
267
225
|
// appendixの実際のセクション数を計算
|
|
268
226
|
const appendixSectionCount = appendixChapters.reduce((total, chapter) => {
|
|
269
|
-
|
|
270
|
-
console.log(` 章${chapter.key}: ${sectionCount}セクション`)
|
|
271
|
-
return total + sectionCount
|
|
227
|
+
return total + Math.max(1, chapter.sections.length)
|
|
272
228
|
}, 0)
|
|
273
229
|
|
|
274
230
|
// appendix用SectionDividerの数
|
|
275
231
|
const appendixDividerCount = appendixChapters.length
|
|
276
232
|
|
|
277
|
-
console.log(' appendixSectionCount:', appendixSectionCount)
|
|
278
|
-
console.log(' appendixDividerCount:', appendixDividerCount)
|
|
279
|
-
|
|
280
233
|
// 全ページ数からappendixのセクション数とSectionDivider数を引いて開始位置を計算
|
|
281
|
-
|
|
282
|
-
console.log(' appendixあり - 結果:', result)
|
|
283
|
-
return result
|
|
234
|
+
return totalPages - appendixSectionCount - appendixDividerCount + 1
|
|
284
235
|
})
|
|
285
236
|
|
|
286
237
|
// 調整されたページ総数(SectionDivider考慮版)
|
|
287
238
|
const adjustedTotal = computed(() => {
|
|
288
|
-
// chapterList(全体)からappendixを検索
|
|
289
239
|
const appendixChapters = chapterList.value.filter(chapter => chapter.isAppendix)
|
|
290
|
-
const normalChapters = chapterList.value.filter(chapter => !chapter.isAppendix && chapter.key !== 'ref')
|
|
291
|
-
|
|
292
|
-
// SectionDividerの数を計算
|
|
293
|
-
const normalChapterDividers = normalChapters.length // 通常章のSectionDivider数
|
|
294
|
-
const appendixChapterDividers = appendixChapters.length // appendix章のSectionDivider数
|
|
295
|
-
const totalDividers = normalChapterDividers + appendixChapterDividers
|
|
296
|
-
|
|
297
|
-
// デバッグ用ログ
|
|
298
|
-
console.log('全chapterList:', chapterList.value)
|
|
299
|
-
console.log('normalChapters:', normalChapters)
|
|
300
|
-
console.log('appendixChapters:', appendixChapters)
|
|
301
|
-
console.log('normalChapterDividers:', normalChapterDividers)
|
|
302
|
-
console.log('appendixChapterDividers:', appendixChapterDividers)
|
|
303
|
-
console.log('totalDividers:', totalDividers)
|
|
304
|
-
console.log('$slidev.nav.total:', $slidev.nav.total)
|
|
305
240
|
|
|
306
241
|
if (appendixChapters.length === 0) {
|
|
307
|
-
|
|
308
|
-
const result = $slidev.nav.total - 1
|
|
309
|
-
console.log('appendixなし - 計算結果:', result)
|
|
310
|
-
return result
|
|
242
|
+
return $slidev.nav.total - 1
|
|
311
243
|
} else {
|
|
312
|
-
|
|
313
|
-
const result = appendixStartPage.value - 2
|
|
314
|
-
console.log('appendixあり - 計算結果:', result)
|
|
315
|
-
return result
|
|
244
|
+
return appendixStartPage.value - 2
|
|
316
245
|
}
|
|
317
246
|
})
|
|
318
247
|
|
|
@@ -355,7 +284,6 @@ const getSectionWidth = (totalSections) => {
|
|
|
355
284
|
|
|
356
285
|
// 指定されたセクションが完了しているかチェック
|
|
357
286
|
const isCompleted = (chapterIndex, sectionIndex) => {
|
|
358
|
-
// 参考文献ページの場合はすべて完了状態
|
|
359
287
|
if (isReferencePage.value) {
|
|
360
288
|
return true
|
|
361
289
|
}
|
|
@@ -364,17 +292,12 @@ const isCompleted = (chapterIndex, sectionIndex) => {
|
|
|
364
292
|
const currentSecIdx = currentSectionIndex.value
|
|
365
293
|
|
|
366
294
|
if (currentIdx === -1) return false
|
|
367
|
-
|
|
368
|
-
// 現在の章より前の章はすべて完了
|
|
369
295
|
if (chapterIndex < currentIdx) return true
|
|
370
296
|
|
|
371
|
-
// 現在の章の場合
|
|
372
297
|
if (chapterIndex === currentIdx) {
|
|
373
|
-
// セクションが指定されている場合
|
|
374
298
|
if (currentSecIdx >= 0) {
|
|
375
299
|
return sectionIndex < currentSecIdx
|
|
376
300
|
}
|
|
377
|
-
// セクションが指定されていない場合は何も完了していない
|
|
378
301
|
return false
|
|
379
302
|
}
|
|
380
303
|
|
|
@@ -383,7 +306,6 @@ const isCompleted = (chapterIndex, sectionIndex) => {
|
|
|
383
306
|
|
|
384
307
|
// 指定されたセクションが現在の位置かチェック
|
|
385
308
|
const isCurrent = (chapterIndex, sectionIndex) => {
|
|
386
|
-
// 参考文献ページの場合は何も現在位置にしない(すべて完了状態)
|
|
387
309
|
if (isReferencePage.value) {
|
|
388
310
|
return false
|
|
389
311
|
}
|
|
@@ -394,18 +316,15 @@ const isCurrent = (chapterIndex, sectionIndex) => {
|
|
|
394
316
|
if (currentIdx === -1) return false
|
|
395
317
|
if (chapterIndex !== currentIdx) return false
|
|
396
318
|
|
|
397
|
-
// セクションが指定されている場合
|
|
398
319
|
if (currentSecIdx >= 0) {
|
|
399
320
|
return sectionIndex === currentSecIdx
|
|
400
321
|
}
|
|
401
322
|
|
|
402
|
-
// セクションが指定されていない場合は最初のセクションが現在位置
|
|
403
323
|
return sectionIndex === 0
|
|
404
324
|
}
|
|
405
325
|
|
|
406
326
|
// 章全体が完了しているかチェック
|
|
407
327
|
const isChapterCompleted = (chapterIndex) => {
|
|
408
|
-
// 参考文献ページの場合はすべて完了状態
|
|
409
328
|
if (isReferencePage.value) {
|
|
410
329
|
return true
|
|
411
330
|
}
|