문제

rake new_post["title"]를 사용하여 _post dir에서 새 마크 다운 파일을 생성하지만 완료하기 전에이 게시물을 게시하고 싶지는 않습니다.어떻게해야합니까?

도움이 되었습니까?

해결책

MarkDown 파일의 맨 위에있는 메타 데이터에 published: false를 추가합니다.

일부 이전 버전의 Octopress는 여전히 미리보기 모드에 게시물을 표시합니다.그러나 사이트를 생성하고 배포 할 때 published: false가있는 게시물이 게시되지 않습니다.

다른 팁

rake new_post는 페이지를 게시하지 않습니다.아래에는 동일한 소스 코드가 표시됩니다.

# usage rake new_post[my-new-post] or rake new_post['my new post'] or rake new_post (defaults to "new-post")
desc "Begin a new post in #{source_dir}/#{posts_dir}"
task :new_post, :title do |t, args|
  raise "### You haven't set anything up yet. First run `rake install` to set up an Octopress theme." unless File.directory?(source_dir)
  mkdir_p "#{source_dir}/#{posts_dir}"
  args.with_defaults(:title => 'new-post')
  title = args.title
  filename = "#{source_dir}/#{posts_dir}/#{Time.now.strftime('%Y-%m-%d')}-#{title.to_url}.#{new_post_ext}"
  if File.exist?(filename)
    abort("rake aborted!") if ask("#{filename} already exists. Do you want to overwrite?", ['y', 'n']) == 'n'
  end
  puts "Creating new post: #{filename}"
  open(filename, 'w') do |post|
    post.puts "---"
    post.puts "layout: post"
    post.puts "title: \"#{title.gsub(/&/,'&')}\""
    post.puts "date: #{Time.now.strftime('%Y-%m-%d %H:%M')}"
    post.puts "comments: true"
    post.puts "categories: "
    post.puts "---"
  end
end
.

파일을 변경 한 후에는 rake generate를 호출 할 수 있습니다 (게시물 및 페이지를 공용 디렉토리에 생성).

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top