Skip to content

Commit

Permalink
[SDPA-3087] Provide fallback images for social media. (#520)
Browse files Browse the repository at this point in the history
* [SDPA-3087] Provide fallback images for social media.
* Featured Image > Section Default > Primary Default > None.

* [SDPA-3087] Hard-coded fallback image.
* Provide fallback image in /img/ folder.
* Fix issue with og:url not displaying a proper url.
  • Loading branch information
alan-cole authored Sep 6, 2019
1 parent e170516 commit 7afa853
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions packages/ripple-nuxt-tide/lib/config/tide.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ const tideConfig = {
sdpPageBase: [
'field_node_site',
'field_node_site.field_site_main_menu',
'field_node_site.field_site_og_image',
'field_node_site.field_site_og_image.field_media_image',
'field_featured_image',
'field_featured_image.field_media_image',
'field_tags',
Expand Down
12 changes: 8 additions & 4 deletions packages/ripple-nuxt-tide/lib/core/middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -326,12 +326,16 @@ export default async function (context, pageData) {
// Set details.
const title = pageData.tidePage.appMetatag.title || pageData.tidePage.appPageTitle || 'Page not found'
const description = pageData.tidePage.appMetatag.description || pageData.tidePage.field_news_intro_text || pageData.tidePage.field_landing_page_intro_text || pageData.tidePage.field_page_intro_text || pageData.tidePage.field_landing_page_summary || ''
const url = context.store.state.absoluteUrl || ''
const url = context.store.state.tide.currentUrl || ''
const siteSection = pageData.tidePage.section && pageData.tidePage.field_node_site && pageData.tidePage.field_node_site.find(site => site.drupal_internal__tid === parseInt(pageData.tidePage.section, 10))

// Set image.
const mediaImage = pageData.tidePage.field_featured_image ? pageData.tidePage.field_featured_image.field_media_image : null
const image = mediaImage ? mediaImage.url : ''
const featuredImage = pageData.tidePage.field_featured_image ? pageData.tidePage.field_featured_image.field_media_image : null
const sectionImage = siteSection.field_site_og_image ? siteSection.field_site_og_image.field_media_image : null
const primaryImage = pageData.tidePage.field_node_primary_site.field_site_og_image ? pageData.tidePage.field_node_primary_site.field_site_og_image.field_media_image : null
const mediaImage = (featuredImage || sectionImage || primaryImage || null)
const image = mediaImage ? mediaImage.url : `${context.store.state.tide.protocol + '//' + context.store.state.tide.host}/img/social-media-image.jpg`
const imageAlt = mediaImage ? mediaImage.meta.alt : ''
const siteSection = pageData.tidePage.field_node_site && pageData.tidePage.field_node_site.find(site => site.drupal_internal__tid === parseInt(pageData.tidePage.section, 10))

pageData.tidePage.head = {
htmlAttrs: {
Expand Down

0 comments on commit 7afa853

Please sign in to comment.