-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Page Builder > Full Width Media (#25)
* Merge branch 'types/schema-1.0' into nuxt/pageblocks * update fields and types * delete sample block * page and block base components * catch all route * Add types to Directus SDK * base css * file url utility composable * media full width * Remove reset * Move file url helper to util function * Create shared block types * Render first real block * Update schema to include block type * Don't require title prop in Video * Remove empty dummy component * Fetch block content in block itself * Render block by type --------- Co-authored-by: rijkvanzanten <[email protected]>
- Loading branch information
1 parent
d8032b8
commit e40089e
Showing
10 changed files
with
67 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<script setup lang="ts"> | ||
import { readItem } from '@directus/sdk'; | ||
import type { BlockProps } from './types'; | ||
const { $directus } = useNuxtApp(); | ||
const props = defineProps<BlockProps>(); | ||
const { data: block } = useAsyncData(() => | ||
$directus.request( | ||
readItem('block_media_fullwidth', props.uuid, { | ||
fields: ['type', 'embed', { video: ['url'] }, { image: ['id', 'title'] }], | ||
}) | ||
) | ||
); | ||
const imgSrc = computed(() => { | ||
if (unref(block)?.type !== 'image') return null; | ||
return getFileUrl(unref(block)!.image.id); | ||
}); | ||
</script> | ||
|
||
<template> | ||
<BaseFrame v-if="block" aspect="16-9" variant="frosted" color="white"> | ||
<BaseVideo v-if="block.type === 'video' && block.video" :url="block.video.url!" /> | ||
<img v-else-if="block.type === 'image' && block.image" :src="imgSrc!" :alt="block.image.title" /> | ||
<div v-else-if="block.type === 'embed' && block.embed" v-html="block.embed" /> | ||
</BaseFrame> | ||
</template> | ||
|
||
<style scoped></style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export interface BlockProps { | ||
uuid: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { File } from '~/types/schema'; | ||
|
||
export const getFileUrl = (fileId: string | File | null | undefined) => { | ||
const config = useRuntimeConfig(); | ||
|
||
if (typeof fileId === 'object') { | ||
fileId = fileId?.id; | ||
} | ||
|
||
return `${config.public.directusUrl}/assets/${fileId}?token=${config.public.directusToken}`; /* TODO Drop the token when we make assets public. */ | ||
}; |