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

Dynamically loading the "whats new" #553

Merged
merged 5 commits into from
Feb 21, 2024
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
30 changes: 15 additions & 15 deletions content/index.html → content/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -91,30 +91,31 @@ <h2 class="pa0 pb1">Popular articles</h2>
</div>
</div>

<% featured = blog_articles %>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you alias blog_articles with featured instead of using blog_articles directly? Maybe blog_articles is not a good name? ;)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didnt want it to make the network request to the blog more than once. Not sure if that really matters since this is at compile time and not run time, but yeah...


<div class="pv4">
<h2 class="ma0 pb2 mb2 bb bw1 divider">New Features</h2>
<a href="https://blog.dnsimple.com/2023/12/introducing-domain-control-plane/?utm_source=support&utm_medium=web&utm_content=dcp" class="link dim" target="_blank">

<a href="<%= featured[:main][:url] %>?utm_source=support&utm_medium=web" class="link dim" target="_blank">
<div class="flex flex-wrap justify-between items-top">
<div class="w-100 w-50-ns">
<img src="/assets/images/features/dcp.png" alt="Domain Control Plane" class="br3">
<img src="<%= featured[:main][:illustration] %>" alt="<%= featured[:main][:title] %>" class="br3">
</div>
<div class="w-100 w-50-ns pa3-ns">
<h3>Introducing DNSimple's Domain Control Plane.</h3>
<p>Take control of all your domains, DNS, and SSL certificates across registrars and providers &mdash; including those outside DNSimple's infrastructure &mdash; from a single pane of glass.</p>
<h3><%= featured[:main][:title] %></h3>
<p><%= featured[:main][:summary] %></p>
</div>
</div>
</a>

<div class="flex flex-wrap justify-between pv3 bb bt bw1 divider">
<div class="w-100 w-50-ns pr3-ns">
<a href="https://blog.dnsimple.com/2023/07/july-feature-focus/?utm_source=support&utm_medium=web&utm_content=new-features" class="link dim" target="_blank">
<h3>What's New at DNSimple &mdash; Summer 2023</h3>
</a>
</div>
<div class="w-100 w-50-ns pr3-ns">
<a href="https://blog.dnsimple.com/2023/06/manage-aws-routes-in-dnsimple/?utm_source=support&utm_medium=web&utm_content=new-features" class="link dim" target="_blank">
<h3>Manage Your AWS Route 53 DNS from DNSimple</h3>
</a>
</div>
<% featured[:secondary].each do |article| %>
<div class="w-100 w-50-ns pr3-ns">
<a href="<%= article[:url] %>?utm_source=support&utm_medium=web&utm_content=new-features" class="link dim" target="_blank">
<h3><%= article[:title] %></h3>
</a>
</div>
<% end %>
</div>
</div>

Expand All @@ -129,4 +130,3 @@ <h3>Manage Your AWS Route 53 DNS from DNSimple</h3>
</div>
</div>
</div>

15 changes: 15 additions & 0 deletions lib/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,18 @@ def pretty_print_fixture(filename)
body = response.read_body
body ? JSON.pretty_generate(JSON.parse(body)) : nil
end

def blog_articles
uri = URI('https://blog.dnsimple.com/feed.json')
res = Net::HTTP.get(uri)
feed = JSON.parse(res, { symbolize_names: true })
features = feed[:items].select { |item| item[:tags].downcase.include? "feature" }

main = features.find { |item| item[:illustration] }
secondary = features.select { |item| item[:title] != main[:title] }

{
main: main,
secondary: secondary.take(2)
}
end