Skip to content

Commit 9a97437

Browse files
committed
fix: minemap error.
1 parent aae1699 commit 9a97437

4 files changed

Lines changed: 49 additions & 13 deletions

File tree

frontend/src/pages/PublicPageView.jsx

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { Link, useLocation, useParams } from 'react-router-dom'
33
import { useTranslation } from 'react-i18next'
44
import publicApi from '../api/publicClient'
55
import MarkdownViewer from '../components/Viewer/MarkdownViewer'
6+
import MindmapView from '../components/MindmapView'
67
import ThemeSwitcher from '../components/ThemeSwitcher'
78
import useSettings from '../store/useSettings'
89

@@ -107,11 +108,15 @@ export default function PublicPageView({ notFound }) {
107108
{t('publicView.updated', { date: new Date(page.updated_at).toLocaleString() })}
108109
</div>
109110
<article className="bg-surface rounded-xl shadow-sm border border-border p-6 sm:p-8">
110-
<MarkdownViewer
111-
content={page.content_md}
112-
publicMode
113-
diagrams={page.diagrams || {}}
114-
/>
111+
{page.page_type === 'mindmap' ? (
112+
<MindmapView content={page.content_md} title={page.title} />
113+
) : (
114+
<MarkdownViewer
115+
content={page.content_md}
116+
publicMode
117+
diagrams={page.diagrams || {}}
118+
/>
119+
)}
115120
</article>
116121
</main>
117122
{footerText && (

frontend/src/pages/PublicPageView.test.jsx

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,16 @@ vi.mock('../components/Viewer/MarkdownViewer', () => ({
3434
),
3535
}))
3636

37+
vi.mock('../components/MindmapView', () => ({
38+
default: ({ content, title }) =>
39+
React.createElement(
40+
'div',
41+
{ 'data-testid': 'mindmap-viewer' },
42+
React.createElement('span', { 'data-testid': 'mindmap-title' }, title),
43+
React.createElement('span', { 'data-testid': 'mindmap-content' }, content),
44+
),
45+
}))
46+
3747
import publicApi from '../api/publicClient'
3848
import PublicPageView from './PublicPageView'
3949

@@ -148,4 +158,25 @@ describe('PublicPageView', () => {
148158
expect(screen.getByTestId('md-diagrams').textContent).toContain('42')
149159
expect(screen.getByTestId('md-diagrams').textContent).toContain('svg')
150160
})
161+
162+
it('renders MindmapView when page_type is mindmap', async () => {
163+
publicApi.get.mockResolvedValueOnce({
164+
data: {
165+
slug: 'mm',
166+
title: 'The Mindmap',
167+
content_md: '# Node',
168+
page_type: 'mindmap',
169+
updated_at: '2026-04-01T00:00:00Z',
170+
author_name: null,
171+
},
172+
})
173+
174+
renderAt('mm')
175+
await screen.findByRole('heading', { name: 'The Mindmap' })
176+
177+
expect(screen.getByTestId('mindmap-viewer')).toBeInTheDocument()
178+
expect(screen.getByTestId('mindmap-title').textContent).toBe('The Mindmap')
179+
expect(screen.getByTestId('mindmap-content').textContent).toBe('# Node')
180+
expect(screen.queryByTestId('md-viewer')).toBeNull()
181+
})
151182
})

frontend/src/store/useTheme.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export const themes = {
4949
}
5050

5151
function applyTheme(themeId) {
52-
const theme = themes[themeId] || themes.light
52+
const theme = themes[themeId] || themes.sand
5353
const root = document.documentElement
5454
root.setAttribute('data-theme', themeId)
5555
root.classList.toggle('dark', theme.dark)
@@ -76,7 +76,7 @@ function safeSet(key, value) {
7676
}
7777

7878
const useTheme = create((set) => ({
79-
theme: safeGet('theme') || 'light',
79+
theme: safeGet('theme') || 'sand',
8080
dark: false,
8181

8282
setTheme: (themeId) => {
@@ -87,7 +87,7 @@ const useTheme = create((set) => ({
8787

8888
init: () => {
8989
const saved = safeGet('theme')
90-
const themeId = saved && themes[saved] ? saved : 'light'
90+
const themeId = saved && themes[saved] ? saved : 'sand'
9191
applyTheme(themeId)
9292
set({ theme: themeId, dark: themes[themeId]?.dark ?? false })
9393
},

frontend/src/store/useTheme.test.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ describe('useTheme Store', () => {
1212
document.documentElement.classList.remove('dark')
1313
})
1414

15-
it('should initialize with light theme by default', () => {
15+
it('should initialize with sand theme by default', () => {
1616
const { result } = renderHook(() => useTheme())
17-
expect(result.current.theme).toBe('light')
17+
expect(result.current.theme).toBe('sand')
1818
})
1919

2020
it('should initialize with saved theme from localStorage', () => {
@@ -57,15 +57,15 @@ describe('useTheme Store', () => {
5757
expect(document.documentElement.classList.contains('dark')).toBe(false)
5858
})
5959

60-
it('should fallback to light theme on init if saved theme is invalid', () => {
60+
it('should fallback to sand theme on init if saved theme is invalid', () => {
6161
localStorage.setItem('theme', 'invalid-theme')
6262
const { result } = renderHook(() => useTheme())
6363

6464
act(() => {
6565
result.current.init()
6666
})
6767

68-
expect(result.current.theme).toBe('light')
69-
expect(document.documentElement.getAttribute('data-theme')).toBe('light')
68+
expect(result.current.theme).toBe('sand')
69+
expect(document.documentElement.getAttribute('data-theme')).toBe('sand')
7070
})
7171
})

0 commit comments

Comments
 (0)