Add target config setting and front matter variables so one could create multiple outputs from a single site codebase with various target site included files
This commit is contained in:
parent
40ac06ed3e
commit
7c2825b25d
|
@ -43,6 +43,7 @@ show_drafts : null
|
||||||
limit_posts : 0
|
limit_posts : 0
|
||||||
future : false
|
future : false
|
||||||
unpublished : false
|
unpublished : false
|
||||||
|
target : "default"
|
||||||
|
|
||||||
# Plugins
|
# Plugins
|
||||||
whitelist : []
|
whitelist : []
|
||||||
|
|
|
@ -9,3 +9,4 @@ Sites built using Jekyll can be deployed in a large number of ways due to the st
|
||||||
* [Manually]({{ '/docs/deployment/manual/' | relative_url }})
|
* [Manually]({{ '/docs/deployment/manual/' | relative_url }})
|
||||||
* [Automated]({{ '/docs/deployment/automated/' | relative_url }})
|
* [Automated]({{ '/docs/deployment/automated/' | relative_url }})
|
||||||
* [Third Party]({{ '/docs/deployment/third-party/' | relative_url }})
|
* [Third Party]({{ '/docs/deployment/third-party/' | relative_url }})
|
||||||
|
* [Multiple Sites and Target]({{ '/docs/deployment/multiple-sites' | relative_url }})
|
||||||
|
|
|
@ -183,9 +183,12 @@ module Jekyll
|
||||||
# Whether the collection's documents ought to be written as individual
|
# Whether the collection's documents ought to be written as individual
|
||||||
# files in the output.
|
# files in the output.
|
||||||
#
|
#
|
||||||
# Returns true if the 'write' metadata is true, false otherwise.
|
# Returns true if the 'write' metadata is true and
|
||||||
|
# if the collection's target matches the site's target,
|
||||||
|
# false otherwise.
|
||||||
def write?
|
def write?
|
||||||
!!metadata.fetch("output", false)
|
!!metadata.fetch("output", false) &&
|
||||||
|
(site.target == metadata.fetch("target", site.target))
|
||||||
end
|
end
|
||||||
|
|
||||||
# The URL template to render collection's documents at.
|
# The URL template to render collection's documents at.
|
||||||
|
@ -217,7 +220,7 @@ module Jekyll
|
||||||
def read_document(full_path)
|
def read_document(full_path)
|
||||||
doc = Document.new(full_path, :site => site, :collection => self)
|
doc = Document.new(full_path, :site => site, :collection => self)
|
||||||
doc.read
|
doc.read
|
||||||
docs << doc if site.unpublished || doc.published?
|
docs << doc if (site.unpublished || doc.published?) && (site.target == doc.data.fetch("target", site.target))
|
||||||
end
|
end
|
||||||
|
|
||||||
def sort_docs!
|
def sort_docs!
|
||||||
|
|
|
@ -30,6 +30,7 @@ module Jekyll
|
||||||
"limit_posts" => 0,
|
"limit_posts" => 0,
|
||||||
"future" => false,
|
"future" => false,
|
||||||
"unpublished" => false,
|
"unpublished" => false,
|
||||||
|
"target" => "default",
|
||||||
|
|
||||||
# Plugins
|
# Plugins
|
||||||
"whitelist" => [],
|
"whitelist" => [],
|
||||||
|
|
|
@ -348,17 +348,20 @@ module Jekyll
|
||||||
end
|
end
|
||||||
|
|
||||||
# Determine whether this document should be written.
|
# Determine whether this document should be written.
|
||||||
# Based on the Collection to which it belongs.
|
# Based on the Collection to which it belongs
|
||||||
|
# and site and document target.
|
||||||
#
|
#
|
||||||
# True if the document has a collection and if that collection's #write?
|
# True if the document has a collection and if that collection's #write?
|
||||||
# method returns true, and if the site's Publisher will publish the document.
|
# method returns true, and if the site's Publisher will publish the document,
|
||||||
|
# and if the document's target matches the site target or is undefined.
|
||||||
# False otherwise.
|
# False otherwise.
|
||||||
#
|
#
|
||||||
# rubocop:disable Naming/MemoizedInstanceVariableName
|
# rubocop:disable Naming/MemoizedInstanceVariableName
|
||||||
def write?
|
def write?
|
||||||
return @write_p if defined?(@write_p)
|
return @write_p if defined?(@write_p)
|
||||||
|
|
||||||
@write_p = collection&.write? && site.publisher.publish?(self)
|
@write_p = collection&.write? && site.publisher.publish?(self) &&
|
||||||
|
(site.target == data.fetch("target", site.target))
|
||||||
end
|
end
|
||||||
# rubocop:enable Naming/MemoizedInstanceVariableName
|
# rubocop:enable Naming/MemoizedInstanceVariableName
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@ module Jekyll
|
||||||
private delegate_method_as :data, :fallback_data
|
private delegate_method_as :data, :fallback_data
|
||||||
|
|
||||||
delegate_methods :id, :output, :content, :to_s, :relative_path, :url, :date
|
delegate_methods :id, :output, :content, :to_s, :relative_path, :url, :date
|
||||||
data_delegators "title", "categories", "tags"
|
data_delegators "title", "categories", "tags", :target
|
||||||
|
|
||||||
def collection
|
def collection
|
||||||
@obj.collection.label
|
@obj.collection.label
|
||||||
|
|
|
@ -180,7 +180,7 @@ module Jekyll
|
||||||
end
|
end
|
||||||
|
|
||||||
def write?
|
def write?
|
||||||
true
|
site.config["target"] == data.fetch("target", site.config["target"])
|
||||||
end
|
end
|
||||||
|
|
||||||
def excerpt_separator
|
def excerpt_separator
|
||||||
|
|
|
@ -69,6 +69,9 @@ module Jekyll
|
||||||
elsif !doc.content.valid_encoding?
|
elsif !doc.content.valid_encoding?
|
||||||
Jekyll.logger.debug "Skipping:", "#{doc.relative_path} is not valid UTF-8"
|
Jekyll.logger.debug "Skipping:", "#{doc.relative_path} is not valid UTF-8"
|
||||||
false
|
false
|
||||||
|
elsif site.target != doc.data.fetch("target", site.target)
|
||||||
|
Jekyll.logger.debug "Skipping:", "#{doc.relative_path} does not belong to this site target"
|
||||||
|
false
|
||||||
else
|
else
|
||||||
publishable?(doc)
|
publishable?(doc)
|
||||||
end
|
end
|
||||||
|
|
|
@ -6,7 +6,7 @@ module Jekyll
|
||||||
:file_read_opts, :future, :gems, :generators, :highlighter,
|
:file_read_opts, :future, :gems, :generators, :highlighter,
|
||||||
:include, :inclusions, :keep_files, :layouts, :limit_posts,
|
:include, :inclusions, :keep_files, :layouts, :limit_posts,
|
||||||
:lsi, :pages, :permalink_style, :plugin_manager, :plugins,
|
:lsi, :pages, :permalink_style, :plugin_manager, :plugins,
|
||||||
:reader, :safe, :show_drafts, :static_files, :theme, :time,
|
:reader, :safe, :target, :show_drafts, :static_files, :theme, :time,
|
||||||
:unpublished
|
:unpublished
|
||||||
|
|
||||||
attr_reader :cache_dir, :config, :dest, :filter_cache, :includes_load_paths,
|
attr_reader :cache_dir, :config, :dest, :filter_cache, :includes_load_paths,
|
||||||
|
@ -47,7 +47,7 @@ module Jekyll
|
||||||
def config=(config)
|
def config=(config)
|
||||||
@config = config.clone
|
@config = config.clone
|
||||||
|
|
||||||
%w(safe lsi highlighter baseurl exclude include future unpublished
|
%w(safe lsi highlighter baseurl exclude include future unpublished target
|
||||||
show_drafts limit_posts keep_files).each do |opt|
|
show_drafts limit_posts keep_files).each do |opt|
|
||||||
send(:"#{opt}=", config[opt])
|
send(:"#{opt}=", config[opt])
|
||||||
end
|
end
|
||||||
|
@ -360,7 +360,7 @@ module Jekyll
|
||||||
end
|
end
|
||||||
|
|
||||||
def each_site_file
|
def each_site_file
|
||||||
pages.each { |page| yield page }
|
pages.each { |page| yield (page) if page.write? }
|
||||||
static_files.each { |file| yield(file) if file.write? }
|
static_files.each { |file| yield(file) if file.write? }
|
||||||
collections.each_value { |coll| coll.docs.each { |doc| yield(doc) if doc.write? } }
|
collections.each_value { |coll| coll.docs.each { |doc| yield(doc) if doc.write? } }
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue