Skip to content

Commit

Permalink
fix: remove tweet oEmbed previews
Browse files Browse the repository at this point in the history
  • Loading branch information
CamKem committed Nov 3, 2024
1 parent 8c701bb commit 8d5b4cb
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 46 deletions.
17 changes: 0 additions & 17 deletions app/Services/MetaData.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,23 +130,6 @@ private function parse(string $content): Collection
}
}

if ($data->has('site_name') && $data->get('site_name') === 'X (formerly Twitter)') {
$x = $this->fetchOEmbed(
service: 'https://publish.twitter.com/oembed',
options: [
'dnt' => 'true',
'omit_script' => 'true',
'hide_thread' => 'true',
'maxwidth' => '446',
'maxheight' => '251',
]);
if ($x->isNotEmpty()) {
foreach ($x as $key => $value) {
$data->put($key, $value);
}
}
}

if ($data->has('site_name') && $data->get('site_name') === 'Vimeo') {
$vimeo = $this->fetchOEmbed(
service: 'https://vimeo.com/api/oembed.json',
Expand Down
17 changes: 0 additions & 17 deletions resources/js/theme-switch.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,23 +36,6 @@ const themeSwitch = () => ({

if (this.currentTheme !== newTheme) {
this.currentTheme = newTheme;
this.renderTweets(newTheme);
}
},

renderTweets(theme) {
const tweetContainers = document.querySelectorAll('div[data-tweet-id]');

if (tweetContainers.length > 0) {
tweetContainers.forEach(container => {
container.innerHTML = '';

window.twttr.widgets.createTweet(container.dataset.tweetId, container, {
theme: theme,
conversation: 'none',
align: 'center',
});
});
}
},
});
Expand Down
13 changes: 3 additions & 10 deletions resources/views/components/link-preview-card.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,9 @@
class="mx-auto mt-2 min-w-full group/preview" data-navigate-ignore="true"
>
@if ($data->has('html'))
@if ($data->get('site_name') === 'X (formerly Twitter)')
@php($tweetId = explode('/', $url))
<div data-tweet-id="{{ end($tweetId) }}" class="w-full overflow-hidden">
{!! $data->get('html') !!}
</div>
@else
<div class="w-full overflow-hidden rounded-lg border border-slate-300 dark:border-0">
{!! $data->get('html') !!}
</div>
@endif
<div class="w-full overflow-hidden rounded-lg border border-slate-300 dark:border-0">
{!! $data->get('html') !!}
</div>
@elseif($data->has('image'))
@php($shortUrl = parse_url($url)['host'])
<a href="{{ $url }}" target="_blank" rel="noopener noreferrer">
Expand Down
2 changes: 0 additions & 2 deletions resources/views/layouts/components/head.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,6 @@
}
</style>

<script id="twitter-widget" async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>

<script>
function isDarkTheme() {
return localStorage.theme === 'dark' || (!('theme' in localStorage) && window.matchMedia('(prefers-color-scheme: dark)').matches)
Expand Down

0 comments on commit 8d5b4cb

Please sign in to comment.