middleman-blog 4.0.1 → 4.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.editorconfig +16 -0
- data/.gitignore +5 -1
- data/.travis.yml +33 -19
- data/.yardopts +2 -2
- data/CHANGELOG.md +51 -24
- data/CONTRIBUTING.md +5 -2
- data/Gemfile +23 -16
- data/ISSUE_TEMPLATE.md +14 -0
- data/LICENSE.md +15 -17
- data/README.md +52 -14
- data/Rakefile +10 -7
- data/features/article_dirs.feature +34 -0
- data/features/blog_sources.feature +35 -6
- data/features/filename_date.feature +4 -2
- data/features/language.feature +108 -77
- data/features/layouts.feature +3 -0
- data/features/multiblog.feature +1 -1
- data/features/next_previous.feature +10 -7
- data/features/permalink.feature +17 -0
- data/features/summary.feature +26 -2
- data/features/support/env.rb +7 -4
- data/features/support/time_steps.rb +7 -3
- data/features/tags.feature +68 -34
- data/fixtures/article-dirs-app/config-directory-indexes.rb +6 -0
- data/fixtures/article-dirs-app/config-permalink-with-dot.rb +6 -0
- data/fixtures/blog-sources-app/config.rb +6 -3
- data/fixtures/blog-sources-app/source/blog/2011-01-01-new-article.html.markdown +5 -3
- data/fixtures/blog-sources-app/source/blog/2013-08-08-slug-from-filename.html.markdown +5 -3
- data/fixtures/blog-sources-app/source/index.html.erb +12 -8
- data/fixtures/blog-sources-app/source/layout.erb +21 -10
- data/fixtures/blog-sources-no-date-app/config.rb +6 -0
- data/fixtures/blog-sources-no-date-app/source/blog/new-article.html.markdown +8 -0
- data/fixtures/blog-sources-no-date-app/source/index.html.erb +13 -0
- data/fixtures/blog-sources-no-date-app/source/layout.erb +24 -0
- data/fixtures/blog-sources-no-day-app/config.rb +6 -0
- data/fixtures/blog-sources-no-day-app/source/2012-08-testing.html.markdown +8 -0
- data/fixtures/blog-sources-no-day-app/source/layout.erb +24 -0
- data/fixtures/{no-title-app → blog-sources-no-title-app}/config.rb +3 -0
- data/fixtures/blog-sources-no-title-app/source/2013-08-07.html.markdown +8 -0
- data/fixtures/blog-sources-no-title-app/source/2013-08-08.html.markdown +9 -0
- data/fixtures/{no-date-app → blog-sources-no-title-app}/source/layout.erb +11 -0
- data/fixtures/blog-sources-subdirs-app/config.rb +6 -3
- data/fixtures/blog-sources-subdirs-app/source/blog.html.erb +6 -3
- data/fixtures/blog-sources-subdirs-app/source/blog/another-post.html.markdown +9 -0
- data/fixtures/blog-sources-subdirs-app/source/blog/subdir/yet-another-post.html.markdown +9 -0
- data/fixtures/blog-sources-subdirs-app/source/layout.erb +24 -1
- data/fixtures/calendar-app/config-directory-indexes.rb +6 -4
- data/fixtures/calendar-app/config-only-year.rb +8 -6
- data/fixtures/calendar-app/config.rb +6 -4
- data/fixtures/calendar-app/source/layout.erb +17 -12
- data/fixtures/language-app/locales/en.yml +5 -4
- data/fixtures/language-app/locales/ru.yml +5 -4
- data/fixtures/language-app/source/2013-09-05-previous-english-article.html.erb +9 -0
- data/fixtures/language-app/source/2013-09-06-previous-russian-article.html.erb +9 -0
- data/fixtures/language-app/source/2013-09-07-english-article-with-lang-in-frontmatter.html.erb +5 -2
- data/fixtures/language-app/source/2013-09-07-russian-article-with-lang-in-frontmatter.html.erb +5 -2
- data/fixtures/language-app/source/2013-09-08-next-russian-article.html.erb +9 -0
- data/fixtures/language-app/source/2013-09-09-next-english-article.html.erb +9 -0
- data/fixtures/language-app/source/layouts/layout.erb +12 -1
- data/fixtures/language-app/source/localizable/index.html.erb +3 -1
- data/fixtures/layouts-app/source/2011/01/01/fourth-article.html.markdown +7 -0
- data/fixtures/paginate-app/config-directory-indexes.rb +14 -12
- data/fixtures/paginate-app/config-paginate-off.rb +14 -12
- data/fixtures/paginate-app/config.rb +16 -13
- data/fixtures/permalink-app/config.rb +7 -0
- data/fixtures/permalink-app/source/index.html.erb +13 -0
- data/fixtures/permalink-app/source/layout.erb +26 -0
- data/fixtures/permalink-app/source/news/2011-01-01-new-article.html.markdown +9 -0
- data/fixtures/summary-app/source/2013-05-08-article-with-custom-separator.html.markdown +1 -1
- data/fixtures/summary-app/source/2016-05-21-article-with-comment-separator.html.markdown +7 -0
- data/fixtures/tags-app/config-directory-indexes.rb +2 -1
- data/fixtures/tags-app/config-filters.rb +8 -0
- data/fixtures/tags-app/config-no-tags.rb +5 -3
- data/fixtures/tags-app/config.rb +2 -1
- data/fixtures/tags-app/source/blog/2011-01-03-no-taga.html.markdown +6 -0
- data/lib/middleman-blog.rb +7 -4
- data/lib/middleman-blog/blog_article.rb +157 -34
- data/lib/middleman-blog/blog_data.rb +83 -29
- data/lib/middleman-blog/calendar_pages.rb +1 -1
- data/lib/middleman-blog/commands/article.rb +88 -30
- data/lib/middleman-blog/commands/article.tt +4 -1
- data/lib/middleman-blog/custom_pages.rb +1 -1
- data/lib/middleman-blog/helpers.rb +2 -2
- data/lib/middleman-blog/paginator.rb +5 -4
- data/lib/middleman-blog/tag_pages.rb +61 -24
- data/lib/middleman-blog/truncate_html.rb +4 -9
- data/lib/middleman-blog/uri_templates.rb +44 -30
- data/lib/middleman-blog/version.rb +3 -1
- data/middleman-blog.gemspec +19 -17
- data/spec/spec_helper.rb +1 -1
- data/spec/uri_templates_spec.rb +21 -6
- metadata +68 -52
- data/.gemtest +0 -0
- data/features/no_date.feature +0 -9
- data/features/permalink-data.feature +0 -12
- data/fixtures/blog-sources-app/source/_article_template.erb +0 -1
- data/fixtures/blog-sources-subdirs-app/source/blog/another-post.html.md.erb +0 -8
- data/fixtures/blog-sources-subdirs-app/source/blog/subdir/yet-another-post.html.md.erb +0 -8
- data/fixtures/no-date-app/config.rb +0 -3
- data/fixtures/no-date-app/source/_article_template.erb +0 -1
- data/fixtures/no-date-app/source/blog/new-article.html.markdown +0 -6
- data/fixtures/no-date-app/source/index.html.erb +0 -9
- data/fixtures/no-day-app/config.rb +0 -3
- data/fixtures/no-day-app/source/2012-08-testing.html.markdown +0 -6
- data/fixtures/no-day-app/source/layout.erb +0 -13
- data/fixtures/no-title-app/source/2013-08-07.html.markdown +0 -6
- data/fixtures/no-title-app/source/2013-08-08.html.markdown +0 -7
- data/fixtures/no-title-app/source/layout.erb +0 -13
- data/fixtures/permalink-data-app/config.rb +0 -5
- data/fixtures/permalink-data-app/source/index.html.erb +0 -3
- data/fixtures/permalink-data-app/source/layout.erb +0 -14
- data/fixtures/permalink-data-app/source/news/2011-01-01-new-article.html.markdown +0 -7
@@ -1,14 +1,18 @@
|
|
1
1
|
require 'middleman-blog/uri_templates'
|
2
2
|
|
3
3
|
module Middleman
|
4
|
+
|
4
5
|
module Blog
|
6
|
+
|
7
|
+
##
|
5
8
|
# A store of all the blog articles in the site, with accessors
|
6
9
|
# for the articles by various dimensions. Accessed via "blog" in
|
7
10
|
# templates.
|
11
|
+
##
|
8
12
|
class BlogData
|
9
|
-
include UriTemplates
|
10
13
|
|
11
|
-
|
14
|
+
include UriTemplates
|
15
|
+
extend Gem::Deprecate
|
12
16
|
|
13
17
|
# A URITemplate for the source file path relative to :source_dir
|
14
18
|
# @return [URITemplate]
|
@@ -20,10 +24,12 @@ module Middleman
|
|
20
24
|
|
21
25
|
attr_reader :controller
|
22
26
|
|
27
|
+
##
|
23
28
|
# @private
|
29
|
+
##
|
24
30
|
def initialize(app, controller, options)
|
25
|
-
@app
|
26
|
-
@options
|
31
|
+
@app = app
|
32
|
+
@options = options
|
27
33
|
@controller = controller
|
28
34
|
|
29
35
|
# A list of resources corresponding to blog articles
|
@@ -34,60 +40,94 @@ module Middleman
|
|
34
40
|
subdir: {}
|
35
41
|
}
|
36
42
|
|
37
|
-
@source_template
|
38
|
-
@permalink_template
|
39
|
-
@subdir_template
|
40
|
-
@subdir_permalink_template = uri_template options.permalink.sub(
|
43
|
+
@source_template = uri_template options.sources
|
44
|
+
@permalink_template = uri_template options.permalink
|
45
|
+
@subdir_template = uri_template options.sources.sub(/(\.[^.{}\/]+)?$/, "/{+path}" )
|
46
|
+
@subdir_permalink_template = uri_template options.permalink.sub(/(\.[^.{}\/]+)?$/, "/{+path}" )
|
41
47
|
end
|
42
48
|
|
49
|
+
##
|
43
50
|
# A list of all blog articles, sorted by descending date
|
51
|
+
#
|
44
52
|
# @return [Array<Middleman::Sitemap::Resource>]
|
53
|
+
##
|
45
54
|
def articles
|
46
|
-
@_articles.select(&(options.filter ||
|
55
|
+
@_articles.select( &( options.filter || proc { | a | a } ) ).sort_by( &:date ).reverse
|
47
56
|
end
|
48
57
|
|
49
|
-
|
50
|
-
# sorted by
|
58
|
+
##
|
59
|
+
# A list of all blog articles with the given language, sorted by
|
60
|
+
# descending date
|
61
|
+
#
|
62
|
+
# @deprecated Use {#articles_by_locale} instead.
|
51
63
|
#
|
52
|
-
# @param
|
64
|
+
# @param [Symbol] locale Language to match (optional, defaults to I18n.locale).
|
53
65
|
# @return [Array<Middleman::Sitemap::Resource>]
|
54
|
-
|
66
|
+
##
|
67
|
+
def local_articles( locale = ::I18n.locale )
|
68
|
+
articles_by_locale( locale )
|
69
|
+
end
|
70
|
+
deprecate :local_articles, :articles_by_locale, 2017, 5
|
71
|
+
|
72
|
+
##
|
73
|
+
# A list of all blog articles with the given language, sorted by
|
74
|
+
# descending date
|
75
|
+
#
|
76
|
+
# @param [Symbol] locale Language to match (optional, defaults to I18n.locale).
|
77
|
+
# @return [Array<Middleman::Sitemap::Resource>]
|
78
|
+
#
|
79
|
+
# @todo should use the @_articles if represented in this method.
|
80
|
+
##
|
81
|
+
def articles_by_locale( locale = ::I18n.locale )
|
55
82
|
locale = locale.to_sym if locale.kind_of? String
|
56
|
-
articles.select {|article| article.locale == locale }
|
83
|
+
articles.select { | article | article.locale == locale }
|
57
84
|
end
|
58
85
|
|
59
|
-
|
60
|
-
# of BlogArticles associated with
|
86
|
+
##
|
87
|
+
# Returns a map from tag name to an array of BlogArticles associated with
|
88
|
+
# that tag and assigns the tag array back into it.
|
89
|
+
#
|
61
90
|
# @return [Hash<String, Array<Middleman::Sitemap::Resource>>]
|
91
|
+
##
|
62
92
|
def tags
|
93
|
+
|
63
94
|
tags = {}
|
64
95
|
|
65
|
-
|
96
|
+
# Reference the filtered articles
|
97
|
+
articles.each do |article|
|
98
|
+
|
99
|
+
# Reference the tags assigned to an article
|
66
100
|
article.tags.each do |tag|
|
101
|
+
# tag = safe_parameterize(tag)
|
67
102
|
tags[tag] ||= []
|
68
103
|
tags[tag] << article
|
69
104
|
end
|
70
|
-
end
|
71
105
|
|
72
|
-
# Sort each tag's list of articles
|
73
|
-
tags.each do |tag, articles|
|
74
|
-
tags[tag] = articles.sort_by(&:date).reverse
|
75
106
|
end
|
76
107
|
|
108
|
+
# Return tags
|
77
109
|
tags
|
78
110
|
end
|
79
111
|
|
112
|
+
##
|
113
|
+
#
|
114
|
+
##
|
80
115
|
def extract_source_params(path)
|
81
116
|
@_parsed_url_cache[:source][path] ||= extract_params(@source_template, path)
|
82
117
|
end
|
83
118
|
|
119
|
+
##
|
120
|
+
#
|
121
|
+
##
|
84
122
|
def extract_subdir_params(path)
|
85
123
|
@_parsed_url_cache[:subdir][path] ||= extract_params(@subdir_template, path)
|
86
124
|
end
|
87
125
|
|
88
|
-
|
89
|
-
# permalink.
|
126
|
+
##
|
127
|
+
# Updates' blog articles destination paths to be the permalink.
|
128
|
+
#
|
90
129
|
# @return [void]
|
130
|
+
##
|
91
131
|
def manipulate_resource_list(resources)
|
92
132
|
@_articles = []
|
93
133
|
used_resources = []
|
@@ -107,17 +147,15 @@ module Middleman
|
|
107
147
|
extra_data = params.except *%w(year month day title lang locale)
|
108
148
|
article.add_metadata page: extra_data unless extra_data.empty?
|
109
149
|
|
110
|
-
# compute output path:
|
111
|
-
# substitute date parts to path pattern
|
150
|
+
# compute output path: substitute date parts to path pattern
|
112
151
|
article.destination_path = template_path @permalink_template, article, extra_data
|
113
152
|
|
114
153
|
@_articles << article
|
115
154
|
|
116
155
|
elsif (params = extract_subdir_params(resource.path))
|
117
|
-
# It's not an article, but it's
|
156
|
+
# It's not an article, but it's the companion files for an article
|
118
157
|
# (in a subdirectory named after the article)
|
119
158
|
# figure out the matching article for this subdirectory file
|
120
|
-
|
121
159
|
article_path = @source_template.expand(params).to_s
|
122
160
|
|
123
161
|
if article = @app.sitemap.find_resource_by_path(article_path)
|
@@ -143,24 +181,33 @@ module Middleman
|
|
143
181
|
used_resources
|
144
182
|
end
|
145
183
|
|
184
|
+
##
|
185
|
+
#
|
186
|
+
##
|
146
187
|
def inspect
|
147
188
|
"#<Middleman::Blog::BlogData: #{articles.inspect}>"
|
148
189
|
end
|
149
190
|
|
191
|
+
##
|
150
192
|
# Whether or not a given article should be included in the sitemap.
|
151
193
|
# Skip articles that are not published unless the environment is +:development+.
|
194
|
+
#
|
152
195
|
# @param [BlogArticle] article A blog article
|
153
196
|
# @return [Boolean] whether it should be published
|
197
|
+
##
|
154
198
|
def publishable?(article)
|
155
199
|
@app.environment == :development || article.published?
|
156
200
|
end
|
157
201
|
|
158
202
|
private
|
159
203
|
|
204
|
+
##
|
160
205
|
# Generate a hash of options for substituting into the permalink URL template.
|
206
|
+
#
|
161
207
|
# @param [Sitemap::Resource] resource The resource to generate options for.
|
162
208
|
# @param [Hash] extra More options to be merged in on top.
|
163
209
|
# @return [Hash] options
|
210
|
+
##
|
164
211
|
def permalink_options(resource, extra={})
|
165
212
|
# Allow any frontmatter data to be substituted into the permalink URL
|
166
213
|
params = resource.metadata[:page].slice *@permalink_template.variables.map(&:to_sym)
|
@@ -175,8 +222,11 @@ module Middleman
|
|
175
222
|
merge(extra)
|
176
223
|
end
|
177
224
|
|
178
|
-
|
179
|
-
|
225
|
+
##
|
226
|
+
#
|
227
|
+
##
|
228
|
+
def convert_to_article( resource )
|
229
|
+
return resource if resource.is_a?( BlogArticle )
|
180
230
|
|
181
231
|
resource.extend BlogArticle
|
182
232
|
resource.blog_controller = controller
|
@@ -188,9 +238,13 @@ module Middleman
|
|
188
238
|
resource
|
189
239
|
end
|
190
240
|
|
241
|
+
##
|
242
|
+
#
|
243
|
+
##
|
191
244
|
def template_path(template, article, extras={})
|
192
245
|
apply_uri_template template, permalink_options(article, extras)
|
193
246
|
end
|
247
|
+
|
194
248
|
end
|
195
249
|
end
|
196
250
|
end
|
@@ -1,11 +1,24 @@
|
|
1
|
-
|
1
|
+
require 'middleman-core/cli'
|
2
2
|
require 'date'
|
3
3
|
require 'middleman-blog/uri_templates'
|
4
4
|
|
5
5
|
module Middleman
|
6
|
+
|
6
7
|
module Cli
|
8
|
+
|
9
|
+
##
|
7
10
|
# This class provides an "article" command for the middleman CLI.
|
11
|
+
#
|
12
|
+
# @usage bundle exec middleman article --help
|
13
|
+
# @usage bundle exec middleman article "Article Title"
|
14
|
+
# @usage bundle exec middleman article "Article Title" -t "test,test1" -c "<b>String</b>" -d 2017-03-25 -l fr-be -b blog_fr-be -s -e
|
15
|
+
#
|
16
|
+
# @see https://middlemanapp.com/basics/blogging/#generating-articles
|
17
|
+
#
|
18
|
+
# @todo Tags should be removed from the template if they are not required
|
19
|
+
##
|
8
20
|
class Article < ::Thor::Group
|
21
|
+
|
9
22
|
include Thor::Actions
|
10
23
|
include Blog::UriTemplates
|
11
24
|
|
@@ -14,65 +27,110 @@ module Middleman
|
|
14
27
|
# Template files are relative to this file
|
15
28
|
# @return [String]
|
16
29
|
def self.source_root
|
17
|
-
File.dirname(__FILE__)
|
30
|
+
File.dirname( __FILE__ )
|
18
31
|
end
|
19
32
|
|
20
33
|
argument :title, type: :string
|
21
34
|
|
35
|
+
class_option "blog",
|
36
|
+
aliases: "-b",
|
37
|
+
desc: "The name of the blog to create the post inside (for multi-blog apps, defaults to the only blog in single-blog apps)"
|
38
|
+
|
39
|
+
class_option "content",
|
40
|
+
aliases: "-c",
|
41
|
+
desc: "Content of the post"
|
42
|
+
|
22
43
|
class_option "date",
|
23
44
|
aliases: "-d",
|
24
|
-
desc:
|
25
|
-
|
26
|
-
desc: "Deprecated, use locale"
|
45
|
+
desc: "The date to create the post with (defaults to now)"
|
46
|
+
|
27
47
|
class_option "locale",
|
28
48
|
aliases: "-l",
|
29
|
-
desc:
|
30
|
-
|
31
|
-
|
32
|
-
|
49
|
+
desc: "The locale to create the post with (defaults to I18n.default_locale if available)"
|
50
|
+
|
51
|
+
class_option "edit",
|
52
|
+
aliases: "-e",
|
53
|
+
desc: "Edit the newly created blog post",
|
54
|
+
default: false,
|
55
|
+
type: :boolean
|
56
|
+
|
57
|
+
class_option "subdirectory",
|
58
|
+
aliases: "-s",
|
59
|
+
desc: "Generate an article subdirectory (for directory indexes, defaults to false)",
|
60
|
+
default: false,
|
61
|
+
type: :boolean
|
62
|
+
|
63
|
+
class_option "tags",
|
64
|
+
aliases: "-t",
|
65
|
+
desc: "A list of comma-separated tags for the post"
|
66
|
+
|
33
67
|
def article
|
34
|
-
config = ::Middleman::Cli.config
|
35
68
|
|
36
|
-
@
|
37
|
-
@
|
38
|
-
@
|
39
|
-
@
|
69
|
+
@content = options[:content] || ""
|
70
|
+
@date = options[ :date ] ? ::Time.zone.parse( options[ :date ] ) : Time.zone.now
|
71
|
+
@locale = options[ :locale ] || ( ::I18n.default_locale if defined? ::I18n )
|
72
|
+
@slug = safe_parameterize( title )
|
73
|
+
@tags = options[:tags] && options[:tags].split(/\s*,\s*/) || []
|
74
|
+
@title = title
|
40
75
|
|
41
76
|
app = ::Middleman::Application.new do
|
42
|
-
config[:mode]
|
43
|
-
config[:disable_sitemap]
|
44
|
-
config[:watcher_disable]
|
45
|
-
config[:exit_before_ready] = true
|
77
|
+
config[ :mode ] = :config
|
78
|
+
config[ :disable_sitemap ] = true
|
79
|
+
config[ :watcher_disable ] = true
|
80
|
+
config[ :exit_before_ready ] = true
|
46
81
|
end
|
47
82
|
|
48
|
-
blog_inst = if options[:blog]
|
49
|
-
app.extensions[:blog][options[:blog]]
|
83
|
+
blog_inst = if options[ :blog ]
|
84
|
+
app.extensions[ :blog ].find { | key, instance | instance.options[ :name ] == options[ :blog ] }[ 1 ]
|
50
85
|
else
|
51
|
-
app.extensions[:blog].values.first
|
86
|
+
app.extensions[ :blog ].values.first
|
52
87
|
end
|
53
88
|
|
54
89
|
unless blog_inst
|
55
90
|
msg = "Could not find an active blog instance"
|
56
|
-
msg << " named #{options[:blog]}" if options[:blog]
|
91
|
+
msg << " named #{ options[ :blog ] }" if options[ :blog ]
|
57
92
|
throw msg
|
58
93
|
end
|
59
94
|
|
60
|
-
path_template
|
61
|
-
params
|
62
|
-
article_path
|
95
|
+
path_template = blog_inst.data.source_template
|
96
|
+
params = date_to_params( @date ).merge( locale: @locale.to_s, title: @slug )
|
97
|
+
article_path = apply_uri_template path_template, params
|
98
|
+
absolute_article_path = File.join( app.source_dir, article_path + blog_inst.options.default_extension )
|
99
|
+
|
100
|
+
template blog_inst.options.new_article_template, absolute_article_path
|
101
|
+
|
102
|
+
# Edit option process
|
103
|
+
if options[ :edit ]
|
104
|
+
|
105
|
+
editor = ENV.fetch( 'MM_EDITOR', ENV.fetch( 'EDITOR', nil ) )
|
106
|
+
|
107
|
+
if editor
|
108
|
+
system( "#{ editor } #{ absolute_article_path }" )
|
109
|
+
else
|
110
|
+
throw "Could not find a suitable editor. Try setting the environment variable MM_EDITOR."
|
111
|
+
end
|
112
|
+
|
113
|
+
end
|
114
|
+
|
115
|
+
# Subdirectory option process
|
116
|
+
if options[ :subdirectory ]
|
117
|
+
empty_directory extract_directory_path( File.join( app.source_dir, article_path ) )
|
118
|
+
end
|
63
119
|
|
64
|
-
template blog_inst.options.new_article_template, File.join(app.source_dir, article_path + blog_inst.options.default_extension)
|
65
120
|
end
|
66
121
|
|
67
122
|
protected
|
68
123
|
|
69
|
-
def blog_instance(key)
|
70
|
-
return nil unless app.extensions[:blog]
|
71
|
-
return app.extensions[:blog][key]
|
124
|
+
def blog_instance( key )
|
125
|
+
return nil unless app.extensions[ :blog ]
|
126
|
+
return app.extensions[ :blog ][ key ]
|
72
127
|
end
|
73
128
|
|
74
129
|
# Add to CLI
|
75
|
-
Base.register(self, 'article', 'article TITLE [options]', 'Create a new blog article')
|
130
|
+
Base.register( self, 'article', 'article TITLE [options]', 'Create a new blog article' )
|
131
|
+
|
76
132
|
end
|
133
|
+
|
77
134
|
end
|
135
|
+
|
78
136
|
end
|
@@ -130,7 +130,7 @@ module Middleman
|
|
130
130
|
# "articles" local variable is populated by Calendar and Tag page generators
|
131
131
|
# If it's not set then use the complete list of articles
|
132
132
|
articles = meta[:locals]["articles"] || blog(blog_name).articles
|
133
|
-
|
133
|
+
|
134
134
|
limit ? articles.first(limit) : articles
|
135
135
|
end
|
136
136
|
|
@@ -159,4 +159,4 @@ module Middleman
|
|
159
159
|
end
|
160
160
|
end
|
161
161
|
end
|
162
|
-
end
|
162
|
+
end
|
@@ -7,11 +7,11 @@ module Middleman
|
|
7
7
|
class Paginator
|
8
8
|
include UriTemplates
|
9
9
|
|
10
|
-
def initialize(app, blog_controller)
|
11
|
-
@app
|
10
|
+
def initialize( app, blog_controller )
|
11
|
+
@app = app
|
12
12
|
@blog_controller = blog_controller
|
13
|
-
@per_page
|
14
|
-
@page_link
|
13
|
+
@per_page = blog_controller.options.per_page
|
14
|
+
@page_link = blog_controller.options.page_link
|
15
15
|
end
|
16
16
|
|
17
17
|
# Update the main sitemap resource list
|
@@ -34,6 +34,7 @@ module Middleman
|
|
34
34
|
# If it's not set then use the complete list of articles
|
35
35
|
# TODO: Some way to allow the frontmatter to specify the article filter?
|
36
36
|
articles = md[:locals]["articles"] || @blog_controller.data.articles
|
37
|
+
articles.select!{|article| article.lang == md[:options][:locale]} if md.fetch(:options, false) and md[:options].fetch(:locale, false)
|
37
38
|
|
38
39
|
# Allow blog.per_page and blog.page_link to be overridden in the frontmatter
|
39
40
|
per_page = md[:page][:per_page] || @per_page
|