Prior to this commit, our fallback HREF was using only the URL's domain (e.g. `guides.rubyonrails.org/routing.html`) instead of the provided URL (e.g. `https://guides.rubyonrails.org/routing.html`). This resulted in the link resolving to `<url-of-article>/guides.rubyonrails.org/routing.html`) With this commit, we're using the given URL for the HREF. An interesting side note, the Ruby on Rails guides includes an `og:title` but not an `og:url` so we hit the fallback condition. Could we use the given URL if `og:url` does not exist? Fixes forem/forem#17679
37 lines
1.2 KiB
Text
37 lines
1.2 KiB
Text
<div class="crayons-card c-embed text-styles text-styles--secondary">
|
|
<% if page.main_properties_present? %>
|
|
<% if page.image %>
|
|
<div class="c-embed__cover">
|
|
<a href="<%= page.url %>" class="c-link s:max-w-50 align-middle" target="_blank" rel="noopener noreferrer">
|
|
<img alt="" src="<%= page.image %>" height="auto" loading="lazy" class="m-0">
|
|
</a>
|
|
</div>
|
|
<% end %>
|
|
<div class="c-embed__body">
|
|
<h2 class="fs-xl lh-tight">
|
|
<a href="<%= page.url %>" target="_blank" rel="noopener noreferrer" class="c-link">
|
|
<%= page.title %>
|
|
</a>
|
|
</h2>
|
|
<% if page.description %>
|
|
<p class="truncate-at-3">
|
|
<%= page.preferred_desc %>
|
|
</p>
|
|
<% end %>
|
|
<div class="color-secondary fs-s flex items-center">
|
|
<% if page.images.favicon %>
|
|
<img
|
|
alt="favicon"
|
|
class="c-embed__favicon m-0 mr-2 radius-0"
|
|
src="<%= page.images.favicon %>"
|
|
loading="lazy" />
|
|
<% end %>
|
|
<%= url_domain %>
|
|
</div>
|
|
</div>
|
|
<% else %>
|
|
<a href="<%= url %>" target="_blank" rel="noopener noreferrer">
|
|
<%= url_domain %>
|
|
</a>
|
|
<% end %>
|
|
</div>
|