Use a better combined datasource: optional header, no crufty yaml files everywhere.
This commit is contained in:
parent
a9440b12c9
commit
7d1d4d49e0
@ -1,19 +1 @@
|
|||||||
require 'nanoc3/tasks'
|
require 'nanoc3/tasks'
|
||||||
|
|
||||||
desc "Make files into items."
|
|
||||||
task :itemize do
|
|
||||||
Dir.glob("content/**/*").each do |filename|
|
|
||||||
yaml_file = File.join(File.dirname(filename), File.basename(filename)[0..-(File.extname(filename).size)]) + "yaml"
|
|
||||||
if File.extname(filename) == ".yaml"
|
|
||||||
# skip
|
|
||||||
elsif File.exists?(yaml_file)
|
|
||||||
# skip
|
|
||||||
elsif File.directory?(filename)
|
|
||||||
else
|
|
||||||
puts "Itemizing #{filename}"
|
|
||||||
File.open(yaml_file,"w") do |f|
|
|
||||||
f.write("---\nextension: #{File.extname(filename)[1..-1]}")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
data_sources:
|
data_sources:
|
||||||
- items_root: /
|
- items_root: /
|
||||||
layouts_root: /
|
layouts_root: /
|
||||||
type: filesystem_compact
|
type: better_combined
|
||||||
- items_root: /assets
|
- items_root: /assets
|
||||||
layouts_root: /assets
|
layouts_root: /assets
|
||||||
type: filesystem_assets
|
type: filesystem_assets
|
||||||
|
@ -1 +1,9 @@
|
|||||||
|
---
|
||||||
|
title: Blueprint Pull Example
|
||||||
|
description: Uses pull to change the display order of columns.
|
||||||
|
framework: blueprint
|
||||||
|
stylesheet: blueprint/_grid.sass
|
||||||
|
mixin: pull
|
||||||
|
example: true
|
||||||
|
---
|
||||||
= render "partials/example"
|
= render "partials/example"
|
||||||
|
@ -1,7 +0,0 @@
|
|||||||
---
|
|
||||||
title: Blueprint Pull Example
|
|
||||||
description: Uses pull to change the display order of columns.
|
|
||||||
framework: blueprint
|
|
||||||
stylesheet: blueprint/_grid.sass
|
|
||||||
mixin: pull
|
|
||||||
example: true
|
|
@ -1,3 +1,5 @@
|
|||||||
|
---
|
||||||
|
---
|
||||||
!blueprint_grid_columns = 3
|
!blueprint_grid_columns = 3
|
||||||
|
|
||||||
@import blueprint/grid.sass
|
@import blueprint/grid.sass
|
||||||
|
@ -1,2 +0,0 @@
|
|||||||
---
|
|
||||||
title: A New Item
|
|
@ -1,3 +1,6 @@
|
|||||||
|
---
|
||||||
|
title: Home
|
||||||
|
---
|
||||||
%h1 Compass Documentation
|
%h1 Compass Documentation
|
||||||
|
|
||||||
%p
|
%p
|
||||||
|
@ -1,2 +0,0 @@
|
|||||||
---
|
|
||||||
title: Home
|
|
@ -1,3 +1,11 @@
|
|||||||
|
---
|
||||||
|
title: Blueprint Module
|
||||||
|
crumb: Blueprint
|
||||||
|
framework: blueprint
|
||||||
|
stylesheet: _blueprint.sass
|
||||||
|
classnames:
|
||||||
|
- reference
|
||||||
|
---
|
||||||
%h1= item[:title]
|
%h1= item[:title]
|
||||||
|
|
||||||
= render "partials/breadcrumbs"
|
= render "partials/breadcrumbs"
|
||||||
|
@ -1,7 +0,0 @@
|
|||||||
---
|
|
||||||
title: Blueprint Module
|
|
||||||
crumb: Blueprint
|
|
||||||
framework: blueprint
|
|
||||||
stylesheet: _blueprint.sass
|
|
||||||
classnames:
|
|
||||||
- reference
|
|
@ -1,3 +1,11 @@
|
|||||||
|
---
|
||||||
|
title: Blueprint Color Module
|
||||||
|
crumb: Colors
|
||||||
|
framework: blueprint
|
||||||
|
stylesheet: blueprint/_colors.sass
|
||||||
|
classnames:
|
||||||
|
- reference
|
||||||
|
---
|
||||||
%h1= item[:title]
|
%h1= item[:title]
|
||||||
|
|
||||||
= render "partials/breadcrumbs"
|
= render "partials/breadcrumbs"
|
||||||
|
@ -1,7 +0,0 @@
|
|||||||
---
|
|
||||||
title: Blueprint Color Module
|
|
||||||
crumb: Colors
|
|
||||||
framework: blueprint
|
|
||||||
stylesheet: blueprint/_colors.sass
|
|
||||||
classnames:
|
|
||||||
- reference
|
|
@ -1,3 +1,11 @@
|
|||||||
|
---
|
||||||
|
title: Blueprint Grid Module
|
||||||
|
crumb: Grid
|
||||||
|
framework: blueprint
|
||||||
|
stylesheet: blueprint/_grid.sass
|
||||||
|
classnames:
|
||||||
|
- reference
|
||||||
|
---
|
||||||
%h1= item[:title]
|
%h1= item[:title]
|
||||||
|
|
||||||
= render "partials/breadcrumbs"
|
= render "partials/breadcrumbs"
|
||||||
|
@ -1,7 +0,0 @@
|
|||||||
---
|
|
||||||
title: Blueprint Grid Module
|
|
||||||
crumb: Grid
|
|
||||||
framework: blueprint
|
|
||||||
stylesheet: blueprint/_grid.sass
|
|
||||||
classnames:
|
|
||||||
- reference
|
|
@ -1 +0,0 @@
|
|||||||
--- {}
|
|
@ -1 +0,0 @@
|
|||||||
--- {}
|
|
@ -1,3 +1,8 @@
|
|||||||
|
---
|
||||||
|
title: Blueprint Framework
|
||||||
|
classnames:
|
||||||
|
- tutorial
|
||||||
|
---
|
||||||
%h1= item[:title]
|
%h1= item[:title]
|
||||||
|
|
||||||
%h2#semantic-blueprint Semantic Blueprint Template
|
%h2#semantic-blueprint Semantic Blueprint Template
|
||||||
|
@ -1,4 +0,0 @@
|
|||||||
---
|
|
||||||
title: Blueprint Framework
|
|
||||||
classnames:
|
|
||||||
- tutorial
|
|
@ -1,2 +0,0 @@
|
|||||||
--- {}
|
|
||||||
|
|
@ -1 +0,0 @@
|
|||||||
--- {}
|
|
@ -1 +0,0 @@
|
|||||||
--- {}
|
|
@ -1 +0,0 @@
|
|||||||
--- {}
|
|
@ -1 +0,0 @@
|
|||||||
--- {}
|
|
@ -1 +0,0 @@
|
|||||||
--- {}
|
|
@ -1 +0,0 @@
|
|||||||
--- {}
|
|
@ -1 +0,0 @@
|
|||||||
--- {}
|
|
28
doc-src/lib/data_sources/better_combined_datasource.rb
Normal file
28
doc-src/lib/data_sources/better_combined_datasource.rb
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
# This is basically the default filesystem_combined datasource
|
||||||
|
# But items without a metadata header don't get an error.
|
||||||
|
class BetterFilesystemCombined < Nanoc3::DataSources::FilesystemCombined
|
||||||
|
identifier :better_combined
|
||||||
|
|
||||||
|
def parse_file(filename, kind)
|
||||||
|
contents = File.read(filename)
|
||||||
|
if contents =~ /^(-{5}|-{3})/
|
||||||
|
# Split file
|
||||||
|
pieces = contents.split(/^(-{5}|-{3})/).compact
|
||||||
|
if pieces.size < 4
|
||||||
|
raise RuntimeError.new(
|
||||||
|
"The file '#{filename}' does not seem to be a nanoc #{kind}"
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
# Parse
|
||||||
|
meta = YAML.load(pieces[2]) || {}
|
||||||
|
content = pieces[4..-1].join.strip
|
||||||
|
|
||||||
|
[ meta, content ]
|
||||||
|
else
|
||||||
|
[{}, contents]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
Loading…
Reference in New Issue
Block a user