mirror of
https://github.com/samsonjs/samhuri.net.git
synced 2026-04-27 14:57:40 +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
|
end
|
||||||
|
|
||||||
if post
|
if post
|
||||||
if request.accept?('application/json')
|
if request.accept?('text/html')
|
||||||
status 200
|
|
||||||
headers 'Content-Type' => 'application/json'
|
|
||||||
JSON.generate(post: post.fields)
|
|
||||||
elsif request.accept?('text/html')
|
|
||||||
status 302
|
status 302
|
||||||
headers 'Location'=> "#{$config[:preview_url]}/posts/#{year}/#{month}/#{id}"
|
headers 'Location'=> "#{$config[:preview_url]}/posts/#{year}/#{month}/#{id}"
|
||||||
nil
|
nil
|
||||||
|
elsif request.accept?('application/json')
|
||||||
|
status 200
|
||||||
|
headers 'Content-Type' => 'application/json'
|
||||||
|
JSON.generate(post: post.fields)
|
||||||
else
|
else
|
||||||
status 400
|
status 400
|
||||||
"content not available in an acceptable format: #{request.accept.join(', ')}"
|
"content not available in an acceptable format: #{request.accept.join(', ')}"
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue