From 76acaf441208279355fb913afff06618c7d5dfbd Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Sat, 21 Oct 2023 13:31:37 -0400 Subject: Added OpenGraph link preview tags for quotes --- app/controllers/quotes_controller.rb | 11 +++++++++++ app/views/layouts/quotes.html.haml | 1 + 2 files changed, 12 insertions(+) diff --git a/app/controllers/quotes_controller.rb b/app/controllers/quotes_controller.rb index cad7dfd..be931a0 100644 --- a/app/controllers/quotes_controller.rb +++ b/app/controllers/quotes_controller.rb @@ -50,6 +50,17 @@ class QuotesController < ApplicationController def show @quote = Quote.published.find(params[:id]) + set_meta_tags(og: { + title: "Quote \##{@quote.id}", + type: "article", + description: (@quote.content.length <= 300 ? @quote.content : @quote.content[0..299]), + url: quote_url(@quote, host: "www.fourisland.com"), + article: { + published_time: @quote.created_at.iso8601, + modified_time: @quote.updated_at.iso8601 + } + }) + respond_to do |format| format.html format.json { render :json => @quote } diff --git a/app/views/layouts/quotes.html.haml b/app/views/layouts/quotes.html.haml index 5555248..68607f6 100644 --- a/app/views/layouts/quotes.html.haml +++ b/app/views/layouts/quotes.html.haml @@ -7,6 +7,7 @@ = javascript_include_tag "application" = csrf_meta_tag = auto_discovery_link_tag :atom, latest_quotes_url(:atom) + = display_meta_tags og: { site_name: "Four Island" } %body #wrap %header#banner -- cgit 1.4.1