Skip to content
This repository has been archived by the owner on Jun 22, 2024. It is now read-only.

Commit

Permalink
feat: updated devtools client to work with new render object
Browse files Browse the repository at this point in the history
  • Loading branch information
Flowko committed Dec 16, 2023
1 parent 0cd481e commit d1456a4
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 21 deletions.
13 changes: 4 additions & 9 deletions client/composables/useEmail.ts
Original file line number Diff line number Diff line change
@@ -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<Email[]>('emails')
Expand Down Expand Up @@ -33,20 +33,15 @@ export function useEmail() {
const renderEmail = async () => {
if (!email.value) return null

const { data } = await useFetch<string>(`/api/render/${email.value.filename}`, {
const { data } = await useFetch<Result>(`/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
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
4 changes: 3 additions & 1 deletion playground/server/api/test.get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
18 changes: 9 additions & 9 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit d1456a4

Please sign in to comment.