diff --git a/client/composables/useEmail.ts b/client/composables/useEmail.ts index ad8243a..72ffd53 100644 --- a/client/composables/useEmail.ts +++ b/client/composables/useEmail.ts @@ -1,6 +1,6 @@ import pretty from 'pretty' -import { convert } from 'html-to-text' import type { Email } from '@/types/email' +import type { Result } from '@vue-email/compiler' export function useEmail() { const emails = useState('emails') @@ -33,20 +33,15 @@ export function useEmail() { const renderEmail = async () => { if (!email.value) return null - const { data } = await useFetch(`/api/render/${email.value.filename}`, { + const { data } = await useFetch(`/api/render/${email.value.filename}`, { baseURL: host.value, }) if (data.value) return { vue: email.value.content, - html: pretty(data.value), - txt: convert(data.value, { - selectors: [ - { selector: 'img', format: 'skip' }, - { selector: '#__vue-email-preview', format: 'skip' }, - ], - }), + html: pretty(data.value.html), + txt: data.value.text, } return null diff --git a/package.json b/package.json index 0b285a4..dddc00f 100644 --- a/package.json +++ b/package.json @@ -50,8 +50,8 @@ "dependencies": { "@nuxt/kit": "^3.8.2", "defu": "^6.1.3", - "vue-email": "0.8.1", - "@vue-email/compiler": "0.8.1", + "vue-email": "0.8.2", + "@vue-email/compiler": "0.8.2", "sirv": "^2.0.3" }, "devDependencies": { diff --git a/playground/server/api/test.get.ts b/playground/server/api/test.get.ts index d1be8a6..e86a44f 100644 --- a/playground/server/api/test.get.ts +++ b/playground/server/api/test.get.ts @@ -10,7 +10,9 @@ export default defineEventHandler(async () => { console.error(error); }) - return template + if(!template) return null + + return template.html } catch (error) { console.error(error); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index fa5d782..daeeb4d 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -12,8 +12,8 @@ importers: specifier: ^3.8.2 version: 3.8.2(rollup@3.29.4) '@vue-email/compiler': - specifier: 0.8.1 - version: 0.8.1(typescript@5.3.3)(vue@3.3.11) + specifier: 0.8.2 + version: 0.8.2(typescript@5.3.3)(vue@3.3.11) defu: specifier: ^6.1.3 version: 6.1.3 @@ -21,8 +21,8 @@ importers: specifier: ^2.0.3 version: 2.0.3 vue-email: - specifier: 0.8.1 - version: 0.8.1(vue@3.3.11) + specifier: 0.8.2 + version: 0.8.2(vue@3.3.11) devDependencies: '@nuxt/devtools': specifier: latest @@ -2738,8 +2738,8 @@ packages: pretty-format: 29.7.0 dev: true - /@vue-email/compiler@0.8.1(typescript@5.3.3)(vue@3.3.11): - resolution: {integrity: sha512-R22S/KgxTKukX0oeCP/KUactU0yXNZj/SpumzqBXHG2qcNOHExafoKqAPOW9G6nfxjZTRjAdpQ8ChYmwUo6ieA==} + /@vue-email/compiler@0.8.2(typescript@5.3.3)(vue@3.3.11): + resolution: {integrity: sha512-OZlHK2NcuPsWw1DXILpRdt3P3wrugol3Ly39lU986t7QHB+UfGvJzJsBUiOleKjinQlgTCx7FqrBXAFjct9DCA==} peerDependencies: vue: ^3.3.8 dependencies: @@ -2747,7 +2747,7 @@ packages: kolorist: 1.8.0 scule: 1.1.1 vue: 3.3.11(typescript@5.3.3) - vue-email: 0.8.1(vue@3.3.11) + vue-email: 0.8.2(vue@3.3.11) transitivePeerDependencies: - bufferutil - canvas @@ -9014,8 +9014,8 @@ packages: resolution: {integrity: sha512-RutnB7X8c5hjq39NceArgXg28WZtZpGc3+J16ljMiYnFhKvd8hITxSWQSQ5bvldxMDU6gG5mkxl1MTQLXckVSQ==} dev: true - /vue-email@0.8.1(vue@3.3.11): - resolution: {integrity: sha512-Zen3dxiremgqLHgEmnSlZlypSUls7RW6raRG0ug7TBKCTPKGR+EdDmExkoTl4W9BdqyrPmskN0wFQRMI5XFvtg==} + /vue-email@0.8.2(vue@3.3.11): + resolution: {integrity: sha512-9F4F069Pz30UXDMbWC0uCmJUFsBnqtdkoGq21sfAqsxRWABNzY0yvZwIsHRcKMwgOr1I4g4KhLL7C8vGoIxwzA==} peerDependencies: vue: ^3.3.8 dependencies: