Skip to content
This repository has been archived by the owner on Jan 15, 2024. It is now read-only.

Added a new "localized_posts_dir" parameter #107

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions README.md
Expand Up @@ -129,6 +129,13 @@ To avoid redundancy, it is possible to exclude files and folders from being copi
```yaml
exclude_from_localizations: ["javascript", "images", "css"]
```

Instead of adding all your posts under the `i18n` directory (with subfolders like: `_i18n/{sv,en,de,fr}/_posts`), you can define a custom parameter to add your posts into or keep the `_posts` directory so you will have a structure like `_posts/{sv,en,de,fr}/`, just add the following parameter:

```
localized_posts_dir: _posts
```

In code, these specific files should be referenced via `baseurl_root`. E.g.

```
Expand Down
12 changes: 10 additions & 2 deletions lib/jekyll-multiple-languages-plugin.rb
Expand Up @@ -144,7 +144,11 @@ def read_posts(dir)
translate_posts = !self.config['exclude_from_localizations'].include?("_posts")

if dir == '' && translate_posts
read_posts("_i18n/#{self.config['lang']}/")
if site.config['localized_posts_dir']
read_publishable(site.config['localized_posts_dir'], site.config['lang'], Document::DATE_FILENAME_MATCHER)
else
read_posts("_i18n/#{self.config['lang']}/")
end
else
read_posts_org(dir)
end
Expand All @@ -170,7 +174,11 @@ class PostReader
def read_posts(dir)
translate_posts = !site.config['exclude_from_localizations'].include?("_posts")
if dir == '' && translate_posts
read_posts("_i18n/#{site.config['lang']}/")
if site.config['localized_posts_dir']
read_publishable(site.config['localized_posts_dir'], site.config['lang'], Document::DATE_FILENAME_MATCHER)
else
read_posts("_i18n/#{self.config['lang']}/")
end
else
read_posts_org(dir)
end
Expand Down