Skip to content

Commit 2236b8f

Browse files
committed
feat: add vue-renderer-markdown for markdown rendering
1 parent 03ff627 commit 2236b8f

File tree

8 files changed

+1247
-984
lines changed

8 files changed

+1247
-984
lines changed

package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,22 @@
1212
"db:migrate": "drizzle-kit migrate"
1313
},
1414
"dependencies": {
15+
"@iconify/vue": "^5.0.0",
1516
"@nuxt/ui": "^4.0.0",
16-
"@nuxtjs/mdc": "^0.17.4",
1717
"ai": "^5.0.59",
1818
"date-fns": "^4.1.0",
1919
"drizzle-orm": "^0.44.5",
2020
"h3": "beta",
21+
"katex": "^0.16.23",
22+
"mermaid": "^11.12.0",
2123
"nitro": "npm:nitro-nightly",
2224
"ofetch": "^1.4.1",
2325
"pg": "^8.16.3",
2426
"shiki-stream": "^0.1.2",
2527
"vue": "^3.5.22",
28+
"vue-renderer-markdown": "0.0.55-beta.2",
2629
"vue-router": "^4.5.1",
30+
"vue-use-monaco": "^0.0.33",
2731
"zod": "^4.1.11"
2832
},
2933
"devDependencies": {

pnpm-lock.yaml

Lines changed: 1232 additions & 954 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

routes/api/chats/[id].get.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { defineEventHandler, getValidatedRouterParams } from 'h3'
22
import { useUserSession } from '../../../utils/session'
3-
import { useDrizzle, tables, eq, and } from '../../../utils/drizzle'
3+
import { useDrizzle, and } from '../../../utils/drizzle'
44
import { z } from 'zod'
55

66

src/components/Logo.vue

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
fill="none"
77
xmlns="http://www.w3.org/2000/svg"
88
>
9-
<path d="M146.496 211.2H234.822C237.627 211.2 240.383 210.468 242.813 209.078C245.242 207.688 247.259 205.688 248.662 203.279C250.064 200.871 250.801 198.139 250.8 195.359C250.799 192.579 250.059 189.847 248.655 187.44L189.337 85.612C187.935 83.2043 185.918 81.2049 183.489 79.8147C181.06 78.4246 178.305 77.6927 175.5 77.6927C172.695 77.6927 169.94 78.4246 167.511 79.8147C165.082 81.2049 163.065 83.2043 161.663 85.612L146.496 111.666L116.841 60.7179C115.438 58.3104 113.42 56.3113 110.991 54.9214C108.561 53.5315 105.805 52.7998 103 52.7998C100.195 52.7998 97.4386 53.5315 95.0089 54.9214C92.5793 56.3113 90.5615 58.3104 89.1583 60.7179L15.3453 187.44C13.9411 189.847 13.2012 192.579 13.2 195.359C13.1987 198.139 13.9363 200.871 15.3384 203.279C16.7405 205.688 18.7578 207.688 21.1873 209.078C23.6168 210.468 26.3728 211.2 29.1783 211.2H84.6219C106.589 211.2 122.789 201.636 133.937 182.979L161 136.526L175.496 111.666L219 186.34H161L146.496 211.2ZM83.7181 186.314L45.0255 186.306L103.026 86.7466L131.966 136.526L112.589 169.798C105.186 181.904 96.7763 186.314 83.7181 186.314Z" fill="var(--ui-primary)" />
9+
<path
10+
d="M146.496 211.2H234.822C237.627 211.2 240.383 210.468 242.813 209.078C245.242 207.688 247.259 205.688 248.662 203.279C250.064 200.871 250.801 198.139 250.8 195.359C250.799 192.579 250.059 189.847 248.655 187.44L189.337 85.612C187.935 83.2043 185.918 81.2049 183.489 79.8147C181.06 78.4246 178.305 77.6927 175.5 77.6927C172.695 77.6927 169.94 78.4246 167.511 79.8147C165.082 81.2049 163.065 83.2043 161.663 85.612L146.496 111.666L116.841 60.7179C115.438 58.3104 113.42 56.3113 110.991 54.9214C108.561 53.5315 105.805 52.7998 103 52.7998C100.195 52.7998 97.4386 53.5315 95.0089 54.9214C92.5793 56.3113 90.5615 58.3104 89.1583 60.7179L15.3453 187.44C13.9411 189.847 13.2012 192.579 13.2 195.359C13.1987 198.139 13.9363 200.871 15.3384 203.279C16.7405 205.688 18.7578 207.688 21.1873 209.078C23.6168 210.468 26.3728 211.2 29.1783 211.2H84.6219C106.589 211.2 122.789 201.636 133.937 182.979L161 136.526L175.496 111.666L219 186.34H161L146.496 211.2ZM83.7181 186.314L45.0255 186.306L103.026 86.7466L131.966 136.526L112.589 169.798C105.186 181.904 96.7763 186.314 83.7181 186.314Z"
11+
fill="var(--ui-primary)"
12+
/>
1013
</svg>
1114
</template>

src/composables/useChats.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export const useChats = createSharedComposable(() => {
1414
const chats = ref<Chat[]>([])
1515

1616
const fetchChats = async () => {
17-
chats.value = await $fetch('/api/chats').then(data => data.map((chat: any) => ({
17+
chats.value = await $fetch('/api/chats').then(data => data.map((chat: never) => ({
1818
id: chat.id,
1919
label: chat.title || 'Untitled',
2020
to: `/chat/${chat.id}`,

src/pages/chat/[id].vue

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,15 @@
11
<script setup lang="ts">
2-
import type { DefineComponent } from 'vue'
32
import { ref, onMounted } from 'vue'
43
import { $fetch } from 'ofetch'
54
import { Chat } from '@ai-sdk/vue'
65
import { DefaultChatTransport } from 'ai'
76
import type { UIMessage } from 'ai'
87
import { useClipboard } from '@vueuse/core'
98
import { getTextFromMessage } from '@nuxt/ui/utils/ai'
10-
import ProseStreamPre from '../../components/prose/PreStream.vue'
119
import { useModels } from '../../composables/useModels'
1210
import { useChats } from '../../composables/useChats'
13-
import MDCRenderer from '@nuxtjs/mdc/runtime/components/MDCRenderer.vue'
1411
import { useRoute } from 'vue-router'
15-
import { parseMarkdown } from '@nuxtjs/mdc/runtime'
16-
17-
const components = {
18-
pre: ProseStreamPre as unknown as DefineComponent
19-
}
12+
import MarkdownRender from 'vue-renderer-markdown'
2013
2114
const route = useRoute()
2215
const toast = useToast()
@@ -44,8 +37,6 @@ const chat = new Chat({
4437
onData: (dataPart) => {
4538
if (dataPart.type === 'data-chat-title') {
4639
fetchChats()
47-
} else {
48-
console.log(dataPart)
4940
}
5041
},
5142
onError(error) {
@@ -123,11 +114,8 @@ onMounted(() => {
123114
loading
124115
/>
125116
</template>
126-
<MDCRenderer
127-
:body="getTextFromMessage(message)"
128-
unwrap="p"
129-
:components="components"
130-
:parser-options="{ highlight: false }"
117+
<MarkdownRender
118+
:content="getTextFromMessage(message)"
131119
/>
132120
</div>
133121
</template>

stub-mdc-imports.js

Lines changed: 0 additions & 2 deletions
This file was deleted.

vite.config.ts

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { defineConfig } from 'vite'
2-
import path from 'path'
32
import { nitro } from 'nitro/vite'
43
import vue from '@vitejs/plugin-vue'
54
import vueRouter from 'unplugin-vue-router/vite'
@@ -28,12 +27,5 @@ export default defineConfig({
2827
}
2928
}),
3029
vueDevtools()
31-
],
32-
// https://github.com/nuxt-content/mdc#stub-nuxt-module-imports
33-
resolve: {
34-
alias: {
35-
'#mdc-imports': path.resolve(__dirname, './stub-mdc-imports.js'),
36-
'#mdc-configs': path.resolve(__dirname, './stub-mdc-imports.js'),
37-
}
38-
}
30+
]
3931
})

0 commit comments

Comments
 (0)