mirror of
https://github.com/samsonjs/samhuri.net.git
synced 2026-03-25 09:05:47 +00:00
fix post preview
This commit is contained in:
parent
e544fe90b2
commit
a136608ede
1 changed files with 5 additions and 5 deletions
|
|
@ -308,14 +308,14 @@ get '/posts/:year/:month/:id' do |year, month, id|
|
|||
end
|
||||
|
||||
if post
|
||||
if request.accept?('application/json')
|
||||
status 200
|
||||
headers 'Content-Type' => 'application/json'
|
||||
JSON.generate(post: post.fields)
|
||||
elsif request.accept?('text/html')
|
||||
if request.accept?('text/html')
|
||||
status 302
|
||||
headers 'Location'=> "#{$config[:preview_url]}/posts/#{year}/#{month}/#{id}"
|
||||
nil
|
||||
elsif request.accept?('application/json')
|
||||
status 200
|
||||
headers 'Content-Type' => 'application/json'
|
||||
JSON.generate(post: post.fields)
|
||||
else
|
||||
status 400
|
||||
"content not available in an acceptable format: #{request.accept.join(', ')}"
|
||||
|
|
|
|||
Loading…
Reference in a new issue