Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added app/assets/images/apple-touch-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/favicon.ico
Binary file not shown.
9 changes: 9 additions & 0 deletions app/assets/images/icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/og-image.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
35 changes: 35 additions & 0 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,39 @@ def render_content_from(page)
erb_processed_content = render(inline: page.content, layout: false)
Kramdown::Document.new(erb_processed_content, input: "GFM", syntax_highlighter: :rouge).to_html.html_safe
end

def site_name
"Rails Static"
end

def title
[ @page.title.presence, site_name ].uniq.compact.join(" · ")
end

def description
@page.frontmatter&.dig(:description)
end

def author
"François Catuhe"
end

def canonical_url
url_for(only_path: false)
end

def robots_content
Rails.env.production? ? "index, follow" : "noindex, nofollow"
end

def og_meta_tag(key, content)
case key
when :title, :description, :image
tag(:meta, name: key, property: "og:#{key}", content: content)
when :author
tag(:meta, name: key, content: content)
else
tag(:meta, property: "og:#{key}", content: content)
end
end
end
3 changes: 3 additions & 0 deletions app/views/layouts/_og_meta_tags.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<%- tags.reject { |_key, content| content.blank? }.each do |key, content| %>
<%= og_meta_tag(key, content) %>
<%- end %>
24 changes: 19 additions & 5 deletions app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
@@ -1,22 +1,36 @@
<!DOCTYPE html>
<html>
<head>
<title><%= content_for(:title) || "Rails Static" %></title>
<title><%= title %></title>
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="mobile-web-app-capable" content="yes">
<%= csrf_meta_tags %>
<%= csp_meta_tag %>

<%= render 'layouts/og_meta_tags', tags: {
title: title,
description: description,
image: image_url('og-image.jpg'),
author: author,
type: "website",
site_name: site_name,
url: canonical_url,
} %>

<%= tag :link, rel: "canonical", href: canonical_url %>

<%= favicon_link_tag 'favicon.ico', sizes: '32x32' %>
<%= favicon_link_tag 'icon.svg', type: 'image/svg+xml' %>
<%= favicon_link_tag 'apple-touch-icon.png', rel: 'apple-touch-icon' %>

<%= tag :meta, name: "robots", content: robots_content %>

<%= yield :head %>

<%# Enable PWA manifest for installable apps (make sure to enable in config/routes.rb too!) %>
<%#= tag.link rel: "manifest", href: pwa_manifest_path(format: :json) %>

<link rel="icon" href="/icon.png" type="image/png">
<link rel="icon" href="/icon.svg" type="image/svg+xml">
<link rel="apple-touch-icon" href="/icon.png">

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/water.css@2/out/water.css">

<%# Includes all stylesheet files in app/assets/stylesheets %>
Expand Down
Binary file added public/favicon.ico
Binary file not shown.
Binary file removed public/icon.png
Binary file not shown.
3 changes: 0 additions & 3 deletions public/icon.svg

This file was deleted.