-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fa0b255
commit 247839d
Showing
10 changed files
with
189 additions
and
56 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 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 |
---|---|---|
@@ -1,29 +1,21 @@ | ||
@php | ||
$ytData = new \BenBjurstrom\Prezet\Data\YoutubeData($attributes->all()); | ||
@endphp | ||
|
||
<div class="aspect-video" {{ $attributes }}> | ||
<iframe | ||
class="h-full w-full" | ||
src="https://www.youtube-nocookie.com/embed/{{ $attributes['videoid'] }}" | ||
width="100%" | ||
<lite-youtube | ||
videoid="{{ $attributes['videoid'] }}" | ||
style="background-image: url('https://i.ytimg.com/vi/{{ $attributes['videoid'] }}/hqdefault.jpg');" | ||
title="{{ $attributes['title'] }}" | ||
frameborder="0" | ||
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" | ||
referrerpolicy="strict-origin-when-cross-origin" | ||
allowfullscreen | ||
></iframe> | ||
> | ||
<a href="https://youtube.com/watch?v={{ $attributes['videoid'] }}" class="lty-playbtn" title="Play Video"> | ||
<span class="lyt-visually-hidden">Play Video: {{ $attributes['title'] }}</span> | ||
</a> | ||
</lite-youtube> | ||
|
||
<script | ||
type="application/ld+json" | ||
> | ||
{!! json_encode([ | ||
'@context' => 'https://schema.org', | ||
'@type' => 'VideoObject', | ||
'url' => 'https://www.youtube.com/watch?v=' . $attributes['title'], | ||
'name' => $attributes['title'], | ||
'identifier' => $attributes['videoid'], | ||
'description' => $attributes['description'], | ||
'thumbnailUrl' => 'https://i.ytimg.com/vi/' . $attributes['videoid'] . '/maxresdefault.jpg', | ||
'uploadDate' => $attributes['date'], | ||
'duration' => $attributes['duration'], | ||
'embedUrl' => 'https://www.youtube.com/embed/' . $attributes['videoid'], | ||
], JSON_UNESCAPED_SLASHES) !!} | ||
{!! json_encode($ytData->toArray(), JSON_UNESCAPED_SLASHES) !!} | ||
</script> | ||
</div> |
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
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,61 @@ | ||
<?php | ||
|
||
namespace BenBjurstrom\Prezet\Data; | ||
|
||
use Carbon\Carbon; | ||
use WendellAdriel\ValidatedDTO\Attributes\Rules; | ||
use WendellAdriel\ValidatedDTO\Casting\CarbonCast; | ||
use WendellAdriel\ValidatedDTO\Concerns\EmptyRules; | ||
use WendellAdriel\ValidatedDTO\ValidatedDTO; | ||
|
||
class YoutubeData extends ValidatedDTO | ||
{ | ||
// https://developers.google.com/search/docs/appearance/structured-data/video | ||
|
||
use EmptyRules; | ||
|
||
// The title of the video | ||
#[Rules(['required', 'string'])] | ||
public string $name; | ||
|
||
#[Rules(['required', 'string'])] | ||
public string $identifier; | ||
|
||
// The date and time the video was first published, in ISO 8601 format. | ||
#[Rules(['required', 'string'])] | ||
public Carbon $uploadDate; | ||
|
||
// The description of the video. | ||
#[Rules(['nullable', 'string'])] | ||
public ?string $description; | ||
|
||
// The duration of the video in ISO 8601 format. For example, PT00H30M5S | ||
#[Rules(['nullable', 'string'])] | ||
public ?string $duration; | ||
|
||
protected function defaults(): array | ||
{ | ||
return [ | ||
'@context' => 'https://schema.org', | ||
'@type' => 'VideoObject', | ||
'thumbnailUrl' => 'https://i.ytimg.com/vi/'.$this->identifier.'/maxresdefault.jpg', | ||
'embedUrl' => 'https://www.youtube.com/embed/'.$this->identifier, | ||
]; | ||
} | ||
|
||
protected function mapData(): array | ||
{ | ||
return [ | ||
'videoid' => 'identifier', | ||
'title' => 'name', | ||
'date' => 'uploadDate', | ||
]; | ||
} | ||
|
||
protected function casts(): array | ||
{ | ||
return [ | ||
'uploadDate' => new CarbonCast(), | ||
]; | ||
} | ||
} |
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