diff --git a/frontend_nuxt/utils/vditorPostCitation.js b/frontend_nuxt/utils/vditorPostCitation.js index 37b80ecac..d3fbcad61 100644 --- a/frontend_nuxt/utils/vditorPostCitation.js +++ b/frontend_nuxt/utils/vditorPostCitation.js @@ -1,17 +1,7 @@ import { authState, getToken } from '~/utils/auth' -async function getPost(apiBaseUrl, id) { - return await fetch(`${apiBaseUrl}/api/posts/${id}`, { - method: 'GET', - headers: { - 'Content-Type': 'application/json', - Authorization: `Bearer ${getToken()}`, - }, - }) -} - async function searchPost(apiBaseUrl, keyword) { - return await fetch(`${apiBaseUrl}/api/search/global?keyword=${keyword}`, { + return await fetch(`${apiBaseUrl}/api/search/posts/title?keyword=${keyword}`, { method: 'GET', headers: { 'Content-Type': 'application/json', @@ -31,15 +21,10 @@ export default (apiBaseUrl) => { const body = await response.json() let value = '' return ( - body - ?.filter((item) => item.type === 'comment' || item.type === 'post') - .map((item) => ({ - value: - item.type === 'comment' - ? `[${item.text}](posts/${item.postId}#comment-${item.id})` - : `[${item.text}](posts/${item.id})`, - html: `
${item.text}
`, - })) ?? [] + body.map((item) => ({ + value: `[${item.title}](/posts/${item.id})`, + html: `
${item.title}
`, + })) ?? [] ) } else { return []