diff --git a/client/bun.lockb b/client/bun.lockb index eef750b..09c7ce2 100755 Binary files a/client/bun.lockb and b/client/bun.lockb differ diff --git a/client/package.json b/client/package.json index 04207e4..0f0a4cf 100644 --- a/client/package.json +++ b/client/package.json @@ -18,6 +18,7 @@ "dependencies": { "@primevue/themes": "^4.2.5", "@tanstack/vue-query": "^5.62.16", + "@traptitech/traq-markdown-it": "^6.3.0", "openapi-fetch": "^0.13.4", "primevue": "^4.2.5", "uuidv7": "^1.0.2", diff --git a/client/src/lib/renderMarkdown.ts b/client/src/lib/renderMarkdown.ts new file mode 100644 index 0000000..49d3fe0 --- /dev/null +++ b/client/src/lib/renderMarkdown.ts @@ -0,0 +1,18 @@ +import { traQMarkdownIt, type Store } from '@traptitech/traq-markdown-it' + +const store: Store = { + getUser: () => undefined, + getChannel: () => undefined, + getUserGroup: () => undefined, + getMe: () => undefined, + getStampByName: () => undefined, + getUserByName: () => undefined, + generateUserHref: () => '', + generateUserGroupHref: () => '', + generateChannelHref: () => '', +} +const it = new traQMarkdownIt(store, undefined, 'https://q.trap.jp') + +export const renderMarkdown = (markdown: string) => { + return it.render(markdown) +} diff --git a/client/src/lib/useServerData.ts b/client/src/lib/useServerData.ts index e5e23e7..f6eb312 100644 --- a/client/src/lib/useServerData.ts +++ b/client/src/lib/useServerData.ts @@ -149,3 +149,9 @@ export const useEnqueueBenchmark = (options?: { redirect?: boolean }) => { }, }) } + +export const useDocs = () => + useQuery({ + queryKey: ['docs'], + queryFn: () => api.GET('/docs').then((r) => r.data), + }) diff --git a/client/src/mock/handlers.ts b/client/src/mock/handlers.ts index 51b5bd1..149ccb4 100644 --- a/client/src/mock/handlers.ts +++ b/client/src/mock/handlers.ts @@ -180,6 +180,41 @@ const benchmarks: components['schemas']['BenchmarkAdminResult'][] = [ }, ] +const docs = `# ドキュメント + +## はじめに + +これはドキュメントです。 +同じ段落 + +違う段落 + +ここに説明が入る + +## 使い方 + +1. これを使ってください。 +2. あれを使ってください。 +3. これを使ってください。 + +## 注意事項 + +- \`inline code\` +- **bold** +- *italic* +- [link](https://example.com) +- ==emphasized== +- ~deleted~ + +> 引用 + +## その他 + +\`\`\`js +const code = 'Hello, world!'; +\`\`\` +` + export const handlers = [ http.get(`${apiBaseUrl}/oauth2/code`, () => { // TODO @@ -390,7 +425,7 @@ export const handlers = [ }), http.get(`${apiBaseUrl}/docs`, () => { const res: paths['/docs']['get']['responses']['200']['content']['application/json'] = { - body: 'This is a document.', + body: docs, } return HttpResponse.json(res) diff --git a/client/src/views/DocsView.vue b/client/src/views/DocsView.vue index e4b9de6..7fffb05 100644 --- a/client/src/views/DocsView.vue +++ b/client/src/views/DocsView.vue @@ -1,7 +1,80 @@ - + + + + +