From 41dac8cadd17a52b6766cd0c10ebcb3628100332 Mon Sep 17 00:00:00 2001
From: Arnaud Levy <contact@arnaudlevy.com>
Date: Mon, 10 Jan 2022 17:46:31 +0100
Subject: [PATCH] exports

---
 app/models/research/journal/article.rb            |  4 ----
 app/models/research/journal/volume.rb             |  4 ++++
 .../research/journal/articles/static.html.erb     | 15 ++++++++++-----
 .../research/journal/volumes/static.html.erb      | 10 ++++------
 4 files changed, 18 insertions(+), 15 deletions(-)

diff --git a/app/models/research/journal/article.rb b/app/models/research/journal/article.rb
index ab701cc02..c44091558 100644
--- a/app/models/research/journal/article.rb
+++ b/app/models/research/journal/article.rb
@@ -51,10 +51,6 @@ class Research::Journal::Article < ApplicationRecord
 
   scope :ordered, -> { order(:published_at, :created_at) }
 
-  def pdf_path
-    "/assets/articles/#{id}/#{pdf.filename}"
-  end
-
   def git_path(website)
     "content/articles/#{published_at.year}/#{published_at.strftime "%Y-%m-%d"}-#{slug}.html" if published_at
   end
diff --git a/app/models/research/journal/volume.rb b/app/models/research/journal/volume.rb
index a3b7dec6a..c6f1973d3 100644
--- a/app/models/research/journal/volume.rb
+++ b/app/models/research/journal/volume.rb
@@ -55,6 +55,10 @@ class Research::Journal::Volume < ApplicationRecord
     [self] + active_storage_blobs
   end
 
+  def path
+    "#{published_at&.year}/#{slug}" if published_at
+  end
+
   def to_s
     "##{ number } #{ title }"
   end
diff --git a/app/views/admin/research/journal/articles/static.html.erb b/app/views/admin/research/journal/articles/static.html.erb
index a096e62f3..1f6f16844 100644
--- a/app/views/admin/research/journal/articles/static.html.erb
+++ b/app/views/admin/research/journal/articles/static.html.erb
@@ -1,10 +1,15 @@
 ---
 title: "<%= @article.title %>"
-description: "<%= @article.abstract %>"
-volume: "<%= @article.volume.id %>"
-publication: "<%= @article.published_at %>"
-pdf: "<%= @article.pdf_path %>/"
-keywords: "<%= @article.keywords %>"
+description: >
+  <%= @article.abstract %>
+<% if @article.volume && @article.volume.path %>
+volumes:
+  - "<%= @article.volume.path %>"
+<% end %>
+weight: 1
+date: <%= @article.published_at %> UTC
+keywords: >
+  <%= @article.keywords %>
 researchers:
 <% @article.researchers.each do |researcher| %>
 - "<%= researcher.id %>"
diff --git a/app/views/admin/research/journal/volumes/static.html.erb b/app/views/admin/research/journal/volumes/static.html.erb
index 11d064ae2..8839171b4 100644
--- a/app/views/admin/research/journal/volumes/static.html.erb
+++ b/app/views/admin/research/journal/volumes/static.html.erb
@@ -1,16 +1,14 @@
 ---
 title: "<%= @volume.title %>"
+slug: "<%= @volume.slug %>"
 number: <%= @volume.number %>
 issn: "<%= @volume.journal.issn %>"
-keywords: "<%= @volume.keywords %>"
-date: "<%= @volume.published_at %>"
+keywords: >
+  <%= @volume.keywords %>
+date: <%= @volume.published_at %> UTC
 <% if @volume.featured_image.attached? %>
 image: "<%= @volume.featured_image.blob.id %>"
 image_alt: "<%= @volume.featured_image_alt %>"
 <% end %>
-articles:
-<% @volume.articles.each do |article| %>
-- <%= article.path %>
-<% end %>
 ---
 <%= @volume.description %>
-- 
GitLab