mirror of
https://0xacab.org/sutty/sutty
synced 2024-11-22 23:16:22 +00:00
poder crear un archivo nuevo sin traducciones
This commit is contained in:
parent
11bb3273aa
commit
adfe01e11f
3 changed files with 7 additions and 4 deletions
|
@ -17,13 +17,13 @@ class PostsController < ApplicationController
|
|||
def new
|
||||
@lang = find_lang
|
||||
@site = find_site
|
||||
@post = Post.new(site: @site, front_matter: { date: Time.now })
|
||||
@post = Post.new(site: @site, front_matter: { date: Time.now }, lang: @lang)
|
||||
end
|
||||
|
||||
def create
|
||||
@lang = find_lang
|
||||
@site = find_site
|
||||
@post = Post.new(site: @site, front_matter: post_params.to_hash)
|
||||
@post = Post.new(site: @site, front_matter: post_params.to_hash, lang: @lang)
|
||||
|
||||
if @post.save
|
||||
redirect_to site_posts_path(@site, lang: @lang)
|
||||
|
|
|
@ -81,7 +81,10 @@ class Post
|
|||
end
|
||||
|
||||
def find_translations
|
||||
get_front_matter('lang').map do |lang, id|
|
||||
slugs = get_front_matter('lang')
|
||||
return [] unless slugs.present?
|
||||
|
||||
slugs.map do |lang, id|
|
||||
next if lang == @lang
|
||||
@site.posts_for(lang).find do |p|
|
||||
p.id == id
|
||||
|
|
|
@ -121,7 +121,7 @@
|
|||
= label_tag 'post_lang', t("posts.lang.#{lang}")
|
||||
= select_tag "post[lang][#{lang}]",
|
||||
options_for_select(@site.posts_for(lang).map { |p| [p.title, p.id] },
|
||||
@post.get_front_matter(:lang).dig(lang)),
|
||||
@post.get_front_matter(:lang).try(:dig, lang)),
|
||||
{ class: 'form-control select2' }
|
||||
%small.text-muted.form-text= t('posts.lang_help')
|
||||
.form-group
|
||||
|
|
Loading…
Reference in a new issue