Ensure lang is always set on default sections
This commit is contained in:
		
							parent
							
								
									fb6cbe008f
								
							
						
					
					
						commit
						b2eb00a374
					
				| @ -458,13 +458,13 @@ impl Site { | |||||||
|                     let filename = format!("_index.{}.md", l); |                     let filename = format!("_index.{}.md", l); | ||||||
|                     index_section.file.path = self.content_path.join(&filename); |                     index_section.file.path = self.content_path.join(&filename); | ||||||
|                     index_section.file.relative = filename; |                     index_section.file.relative = filename; | ||||||
|                     index_section.lang = index_section.file.find_language(&self.config)?; |  | ||||||
|                 } else { |                 } else { | ||||||
|                     index_section.file.name = "_index".to_string(); |                     index_section.file.name = "_index".to_string(); | ||||||
|                     index_section.permalink = self.config.make_permalink(""); |                     index_section.permalink = self.config.make_permalink(""); | ||||||
|                     index_section.file.path = self.content_path.join("_index.md"); |                     index_section.file.path = self.content_path.join("_index.md"); | ||||||
|                     index_section.file.relative = "_index.md".to_string(); |                     index_section.file.relative = "_index.md".to_string(); | ||||||
|                 } |                 } | ||||||
|  |                 index_section.lang = index_section.file.find_language(&self.config)?; | ||||||
|                 library.insert_section(index_section); |                 library.insert_section(index_section); | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|  | |||||||
| @ -18,7 +18,7 @@ A few variables are available on all templates except RSS and the sitemap: | |||||||
| - `config`: the [configuration](@/documentation/getting-started/configuration.md) without any modifications | - `config`: the [configuration](@/documentation/getting-started/configuration.md) without any modifications | ||||||
| - `current_path`: the path (full URL without `base_url`) of the current page, never starting with a `/` | - `current_path`: the path (full URL without `base_url`) of the current page, never starting with a `/` | ||||||
| - `current_url`: the full URL for the current page | - `current_url`: the full URL for the current page | ||||||
| - `lang`: the language for the current page; `null` if the page/section doesn't have a language set | - `lang`: the language for the current page | ||||||
| 
 | 
 | ||||||
| Config variables can be accessed like `config.variable`, in HTML for example with `{{ config.base_url }}`. | Config variables can be accessed like `config.variable`, in HTML for example with `{{ config.base_url }}`. | ||||||
| The 404 template does not get `current_path` and `current_url` (this information cannot be determined). | The 404 template does not get `current_path` and `current_url` (this information cannot be determined). | ||||||
|  | |||||||
| @ -1,3 +1,4 @@ | |||||||
| {% for author in terms %} | {% for author in terms %} | ||||||
|     {{ author.name }} {{ author.slug }} {{ author.pages | length }} |     {{ author.name }} {{ author.slug }} {{ author.pages | length }} | ||||||
| {% endfor %} | {% endfor %} | ||||||
|  | {{lang}} | ||||||
| @ -19,3 +19,4 @@ | |||||||
|     {% if paginator.previous %}has_prev{% endif%} |     {% if paginator.previous %}has_prev{% endif%} | ||||||
|     {% if paginator.next %}has_next{% endif%} |     {% if paginator.next %}has_next{% endif%} | ||||||
| {% endif %} | {% endif %} | ||||||
|  | {{lang}} | ||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user