File tree Expand file tree Collapse file tree 1 file changed +12
-25
lines changed Expand file tree Collapse file tree 1 file changed +12
-25
lines changed Original file line number Diff line number Diff line change @@ -6,35 +6,22 @@ class MetaTag < Liquid::Tag
66 include Jekyll ::Filters ::URLFilters
77
88 def render ( context )
9+ # Jekyll::Filters::URLFilters requires `@context` to be set in the environment.
910 @context = context
10- attrs = attributes . map do |k , v |
11- v = v . to_s unless v . respond_to? ( :encode )
12- %(#{ k } =#{ v . encode ( :xml => :attr ) } )
13- end
14- "<link #{ attrs . join ( " " ) } />"
15- end
16-
17- private
18-
19- def config
20- @config ||= @context . registers [ :site ] . config
21- end
2211
23- def attributes
24- {
25- :type => "application/atom+xml" ,
26- :rel => "alternate" ,
27- :href => absolute_url ( path ) ,
28- :title => title ,
29- } . keep_if { |_ , v | v }
30- end
12+ config = context . registers [ :site ] . config
13+ path = config . dig ( "feed" , "path" ) || "feed.xml"
14+ title = config [ "title" ] || config [ "name" ]
3115
32- def path
33- config . dig ( "feed" , "path" ) || "feed.xml"
34- end
16+ attributes = {
17+ :type => "application/atom+xml" ,
18+ :rel => "alternate" ,
19+ :href => absolute_url ( path ) ,
20+ }
21+ attributes [ :title ] = title if title
3522
36- def title
37- config [ "title" ] || config [ "name" ]
23+ attrs = attributes . map { | k , v | " #{ k } = #{ v . to_s . encode ( :xml => :attr ) } " } . join ( " " )
24+ "<link #{ attrs } />"
3825 end
3926 end
4027end
You can’t perform that action at this time.
0 commit comments