-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ThemeAssetsReader which reads assets from a theme
If the theme includes the 'assets' directory, it will be walked and items will be added to the site based on the normal rules of Jekyll: if there is YAML front matter, it will be added as a (convertible) Page, otherwise it will be added as a StaticFile.
- Loading branch information
Showing
5 changed files
with
46 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
module Jekyll | ||
class ThemeAssetsReader | ||
attr_reader :site | ||
def initialize(site) | ||
@site = site | ||
end | ||
|
||
def read | ||
return unless site.theme && site.theme.assets_path | ||
|
||
Find.find(site.theme.assets_path) do |path| | ||
next if File.directory?(path) | ||
if File.symlink?(path) | ||
Jekyll.logger.warn "Theme reader:", "Ignored symlinked asset: #{path}" | ||
else | ||
base = site.theme.root | ||
dir = File.dirname(path.sub("#{site.theme.root}/", "")) | ||
name = File.basename(path) | ||
relative_path = File.join(*[dir, name].compact) | ||
if Utils.has_yaml_header?(path) | ||
next if site.pages.any? { |file| file.relative_path == relative_path } | ||
site.pages << Jekyll::Page.new(site, base, dir, name) | ||
else | ||
next if site.static_files.any? { |file| file.relative_path == relative_path } | ||
site.static_files << Jekyll::StaticFile.new(site, base, dir, name) | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters