File tree Expand file tree Collapse file tree 2 files changed +11
-1
lines changed Expand file tree Collapse file tree 2 files changed +11
-1
lines changed Original file line number Diff line number Diff line change 200
200
201
201
desc "Default deploy task"
202
202
task :deploy do
203
+ # Check if preview posts exist, which should not be published
204
+ if File . exists? ( ".preview-mode" )
205
+ puts "## Found posts in preview mode, regenerating files ..."
206
+ File . delete ( ".preview-mode" )
207
+ Rake ::Task [ :generate ] . execute
208
+ end
209
+
203
210
Rake ::Task [ :copydot ] . invoke ( source_dir , public_dir )
204
211
Rake ::Task [ "#{ deploy_default } " ] . execute
205
212
end
Original file line number Diff line number Diff line change @@ -24,8 +24,11 @@ def read_posts(dir)
24
24
25
25
# Monkeypatch:
26
26
# On preview environment (localhost), publish all posts
27
- if ENV . has_key? ( 'OCTOPRESS_ENV' ) && ENV [ 'OCTOPRESS_ENV' ] == 'preview'
27
+ if ENV . has_key? ( 'OCTOPRESS_ENV' ) && ENV [ 'OCTOPRESS_ENV' ] == 'preview' && post . data . has_key? ( 'published' ) && post . data [ 'published' ] == false
28
28
post . published = true
29
+ # Set preview mode flag (if necessary), `rake generate` will check for it
30
+ # to prevent pushing preview posts to productive environment
31
+ File . open ( ".preview-mode" , "w" ) { }
29
32
end
30
33
31
34
if post . published && ( self . future || post . date <= self . time )
You can’t perform that action at this time.
0 commit comments