Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding marketing banner to top of developer site #766

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
8 changes: 8 additions & 0 deletions banners.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
- active: true
bg_color: "#e2d1e6"
text_color: "#333"
emoji: 📣 📣 📣
content: | #markdown
Ditch the manual DNS configurations. Join our webinar to learn how to automate your DNS infrastructure with **DNSimple's Terraform Provider!**
link_text: 🎟️ Secure your spot today! 🎟️
link_url: https://live.zoho.com/6u3RkFDYbS
6 changes: 6 additions & 0 deletions content/assets/css/_template.scss
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,9 @@
background-repeat: repeat-x;
background-size: 900px 10px;
}

#marketing-banner {
p {
display: inline;
}
}
20 changes: 20 additions & 0 deletions layouts/banner.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@

<% banner = find_active_banner %>
<% if banner %>
<div
id="marketing-banner"
style="background-color:<%= banner[:bg_color] %>; color:<%= banner[:text_color] %>;"
>
<div class="pv4 tc mw8 center">
<%= banner[:emoji] %>
<%= as_markdown banner[:content] %>
<a
style="color:<%= banner[:text_color] %>;"
href="<%= banner[:link_url] %>" target="_blank"
>
<%= banner[:link_text] %>
</a>
</div>
</div>
<% end %>

2 changes: 2 additions & 0 deletions layouts/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
<%= render "analytics" %>
</head>
<body>
<%= render "banner" %>

<header>
<div class="mw8 center ph2">
<div class="flex flex-wrap justify-between pv3">
Expand Down
10 changes: 10 additions & 0 deletions lib/default.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
require 'net/http'
require 'json'
require 'kramdown'

include Nanoc::Helpers::Rendering
include Nanoc::Helpers::XMLSitemap
Expand Down Expand Up @@ -36,3 +37,12 @@ def blog_articles
secondary: secondary.take(2)
}
end

def find_active_banner
banners = YAML.load(File.read('banners.yml'), symbolize_names: true)
banners&.find { |banner| banner[:active] == true }
end

def as_markdown(str)
Kramdown::Document.new(str).to_html
end