Skip to content

Commit

Permalink
Updates accelerator.
Browse files Browse the repository at this point in the history
This resolves the issue with YT videos that aren't on their own line being expanded.
  • Loading branch information
steve-fenton-octopus committed Oct 31, 2023
1 parent 552b394 commit 077ff17
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
"dependencies": {
"@astrojs/mdx": "^1.0.0",
"astro": "^3.0.3",
"cspell": "^7.3.7",
"astro-accelerator": "^0.3.12",
"astro-accelerator": "^0.3.13",
"astro-accelerator-utils": "^0.3.2",
"cspell": "^7.3.7",
"hast-util-from-selector": "^3.0.0",
"remark-directive": "^2.0.1",
"remark-heading-id": "^1.0.1"
Expand Down
8 changes: 4 additions & 4 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions public/docs/js/modules/youtube.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ function enhanceYoutubeLinks() {
const videos = qsa('a[href^="https://www.youtube.com/watch?v="]');

for (var video of videos) {
if (video.parentNode.childNodes.length > 1) {
// Don't turn video into embed if it's part of a longer paragraph, for example.
continue;
}

const id = new URL(video.href).searchParams.get('v');
video.setAttribute('data-youtube', id);
video.classList.add('init');
Expand Down

0 comments on commit 077ff17

Please sign in to comment.