Skip to content

Commit

Permalink
chore: progress commit
Browse files Browse the repository at this point in the history
  • Loading branch information
harlan-zw committed Jan 19, 2023
1 parent 7b99d94 commit eeecc03
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 8 deletions.
3 changes: 2 additions & 1 deletion .playground/pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ definePageMeta({
</script>
<template>
<div class="px-5 my-10">
<h1 class="text-3xl mb-5">Nuxt Og Image Test</h1>
<OgImageStatic />
<h1 class="text-3xl mb-5">Nuxt OG Image Test</h1>
<div class="mb-10">
<h2 class="text-lg font-bold mb-3">Browser Screenshot</h2>
<div><NuxtLink to="/browser/custom">custom</NuxtLink></div>
Expand Down
4 changes: 2 additions & 2 deletions src/runtime/nitro/routes/__og_image__/html.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { parseURL, withoutTrailingSlash } from 'ufo'
import {parseURL, withBase, withoutTrailingSlash} from 'ufo'
import { renderSSRHead } from '@unhead/ssr'
import { createHeadCore } from '@unhead/vue'
import { defineEventHandler, sendRedirect } from 'h3'
Expand All @@ -17,7 +17,7 @@ export default defineEventHandler(async (e) => {

// for screenshots just return the base path
if (payload.provider === 'browser')
return sendRedirect(e, useHostname(e) + basePath)
return sendRedirect(e, withBase(basePath, useHostname(e)))

const component = payload.component || 'OgImageTemplate'
delete payload.component
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/nitro/routes/__og_image__/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ export default defineEventHandler(async (e) => {
height: 100%;
}
</style>
<title>Og Image Playground</title>
<title>OG Image Playground</title>
<iframe src="${useHostname(e)}/__nuxt_og_image__/client/?&path=${withoutTrailingSlash(path.replace('__og_image__', ''))}"></iframe>`
})
4 changes: 2 additions & 2 deletions src/runtime/nitro/routes/__og_image__/og.png.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { defineEventHandler, setHeader } from 'h3'
import { parseURL, withBase, withoutTrailingSlash } from 'ufo'
import {joinURL, parseURL, withBase, withoutTrailingSlash} from 'ufo'
import { fetchPayload, useHostname } from '../../utils'
import { useProvider } from '#nuxt-og-image/provider'

Expand Down Expand Up @@ -29,5 +29,5 @@ export default defineEventHandler(async (e) => {
}

const provider = await useProvider(providerName!)
return provider.createPng(withBase(`${basePath}/__og_image__/html`, useHostname(e)))
return provider.createPng(withBase(joinURL(basePath, '/__og_image__/html'), useHostname(e)))
})
4 changes: 2 additions & 2 deletions src/runtime/nitro/routes/__og_image__/svg.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { defineEventHandler, setHeader } from 'h3'
import { parseURL, withBase, withoutTrailingSlash } from 'ufo'
import { joinURL, parseURL, withBase, withoutTrailingSlash } from 'ufo'
import { fetchPayload, useHostname } from '../../utils'
import { useProvider } from '#nuxt-og-image/provider'

Expand All @@ -16,5 +16,5 @@ export default defineEventHandler(async (e) => {
const { provider: providerName } = await fetchPayload(basePath)
setHeader(e, 'Content-Type', 'image/svg+xml')
const provider = await useProvider(providerName!)
return provider.createSvg(withBase(`${basePath}/__og_image__/html`, useHostname(e)))
return provider.createSvg(withBase(joinURL(basePath, '/__og_image__/html'), useHostname(e)))
})

0 comments on commit eeecc03

Please sign in to comment.