-
Notifications
You must be signed in to change notification settings - Fork 0
Update EmbedBlock to support additional providers and improve rendering logic #98
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Deploying dda-website with
|
Latest commit: |
2019c8a
|
Status: | ✅ Deploy successful! |
Preview URL: | https://6cb5a325.dda-website.pages.dev |
Branch Preview URL: | https://embeds.dda-website.pages.dev |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR extends EmbedBlock
to support Twitter, YouTube, and Vimeo embeds, refactors rendering logic for better readability, and integrates the new fragment into TextBlock
.
- Imports and includes the
EmbedBlock
fragment inTextBlock.fragment.graphql
- Refactors
Default.astro
conditional rendering and styling - Adds tests for Twitter, YouTube, and Vimeo embeds
- Updates destructuring in
EmbedBlock.astro
and temporarily switches the environment indatocms-environment.ts
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
File | Description |
---|---|
src/blocks/TextBlock/TextBlock.fragment.graphql | Imported and added the EmbedBlock fragment to the TextBlock query |
src/blocks/EmbedBlock/embeds/Default.astro | Reformatted imports, updated conditional <template> logic, adjusted CSS |
src/blocks/EmbedBlock/EmbedBlock.test.ts | Added tests for Twitter, YouTube, and Vimeo embed rendering |
src/blocks/EmbedBlock/EmbedBlock.astro | Introduced explicit type cast on block destructuring |
datocms-environment.ts | Changed datocmsEnvironment to embed-test (likely unintended) |
Comments suppressed due to low confidence (3)
src/blocks/EmbedBlock/embeds/Default.astro:44
- The
<template>
tag no longer usesset:html
, so the HTML snippet may not be injected as intended. Consider restoring the original<template set:html={html}></template>
syntax or ensure the inner<div set:html={html}/>
within<template>
is supported.
<template>
datocms-environment.ts:6
- Committing a test environment value (
embed-test
) here may override production settings unexpectedly. Revert to the default environment or make this conditional to avoid configuration leaks.
export const datocmsEnvironment = 'embed-test';
src/blocks/EmbedBlock/EmbedBlock.test.ts:127
- The Twitter test checks
data-provider="Twitter"
(capital T) but this YouTube test expects lowercaseyoutube
. Verify that the attribute value casing is consistent or adjust the selector to match the actual output.
expect(fragment.querySelector('[data-provider="youtube"]')).toBeTruthy();
const { data, url }: { data: OEmbedAny; url: string } = block as { | ||
data: OEmbedAny; | ||
url: string; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] The explicit type cast on block
is redundant if EmbedBlockFragment
already defines data
and url
. Consider simplifying to const { data, url } = block;
for clarity.
const { data, url }: { data: OEmbedAny; url: string } = block as { | |
data: OEmbedAny; | |
url: string; | |
}; | |
const { data, url } = block; |
Copilot uses AI. Check for mistakes.
…ng logic - Change datocmsEnvironment to 'embed-test'. - Enhance EmbedBlock to correctly render Twitter, YouTube, and Vimeo embeds with appropriate tests. - Refactor EmbedBlock.astro for improved readability and structure. - Update TextBlock fragment to include EmbedBlock support.
Description
EmbedBlock
to correctly render Twitter, YouTube, and Vimeo embeds.EmbedBlock.astro
andembeds/Default.astro
for improved readability and structure.EmbedBlock
inTextBlock.fragment.graphql
.Changes
EmbedBlock.astro
to handle provider-specific data safely.iframe
logic with fallback options.EmbedBlock
fragment toTextBlock.fragment.graphql
.Associated issue
https://trello.com/c/jSFaAg3D/105-iframe-spotify
How to test
datocmsEnvironment
set toembed-test
.TextBlock
).iframe
with correct styling and dimensions.vitest
or relevant command to confirm all newEmbedBlock
tests pass.Checklist