Skip to content

Commit

Permalink
doc: video entry recipe
Browse files Browse the repository at this point in the history
  • Loading branch information
harlan-zw committed Sep 23, 2024
1 parent 4b04d2a commit 0aee998
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions docs/content/5.nitro-api/nitro-hooks.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,28 @@ export default defineNitroPlugin((nitroApp) => {
})
})
```

### Modify Video Entries For Host

Sometimes you'll want to include the videos from your markup automatically but exclude some of them based on the host.

```ts
import { defineNitroPlugin } from 'nitropack/runtime'

export default defineNitroPlugin((nitroApp) => {
nitroApp.hooks.hook('sitemap:resolved', (ctx) => {
ctx.urls.map((url) => {
if (url.videos?.length) {
url.videos = url.videos.filter((video) => {
if (video.content_loc) {
const url = new URL(video.content_loc)
return url.host.startsWith('www.youtube.com')
}
return false
})
}
return url
})
})
})
```

0 comments on commit 0aee998

Please sign in to comment.