Skip to content

Commit

Permalink
Fix dates and empty tags, add CV
Browse files Browse the repository at this point in the history
  • Loading branch information
MateuszKubuszok committed May 17, 2023
1 parent 37f6fba commit 7911082
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 17 deletions.
5 changes: 5 additions & 0 deletions src/_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ jekyll-diagrams:
jekyll-minifier:
exclude: 'robots.txt'

liquid:
error_mode: warn
#strict_variables: true
strict_filters: true

# If you add plugins make sure you check that section _config.dev.yml as well.
# We use _config.dev.yml to remove jekyll-minifier from dev flow.
plugins: ['jekyll-diagrams', 'jekyll-minifier', 'jekyll-sitemap', 'jekyll-toc']
Expand Down
4 changes: 2 additions & 2 deletions src/_includes/article.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
{%- endif -%}
<div class="post-meta">
<time datetime="{{ post.date | date: "%-d %b %Y" }}" class="date"><i class="far fa-calendar-alt"></i>&nbsp;{{ post.date | translated_date: page.lang, "%-d %b %Y" }}</time>
{%- if post.categories != blank -%}
{%- if post.categories.size > 0 -%}
&#8226; <span class="series">{{ site.data.locales[page.lang].series }}: {% for category in post.categories %}<a href="{{ site.baseurl }}series/#{{ category }}"><i class="fas fa-signature"></i>&nbsp;{{ category }}</a> {%- endfor -%}</span>
{% endif %}
{%- if post.tags.size != blank -%}
{%- if post.tags.size > 0 -%}
&#8226; <span class="tags">{{ site.data.locales[page.lang].tags }}: {% for tag in post.tags %}<a href="{{ site.baseurl }}tags/#{{ tag }}"><i class="fas fa-tag"></i>&nbsp;{{ tag }}</a> {% endfor %}</span>
{%- endif -%}
</div>
Expand Down
29 changes: 14 additions & 15 deletions src/_plugins/TranslatedDate.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,38 +6,37 @@ module TranslatedDate
@@lang = nil
@@default_format = nil

def translate_date(date_value, lang, format)
def translated_date(parsed_date, lang, format)
unless @@lang
@@lang ||= @context.registers[:site]['lang']
@@lang ||= @context.registers[:site].config['lang']
@@lang ||= 'en'
end
lang ||= @@lang

unless @@default_format
@@default_format ||= @context.registers[:site]['date_format']
@@default_format ||= @context.registers[:site].config['date_format']
@@default_format ||= '%b %-d, %Y'
end
format ||= @default_format
format ||= @@default_format

@locales ||= @context.registers[:site]['locales']

parsed_date = DateTime.strptime(date_value)
@locales ||= @context.registers[:site].data['locales']
locale = @locales[lang]

num_day = parsed_date.strftime('%w').to_i
num_month = parsed_date.strftime('%-m').to_i - 1

translated_date_format = format
if locales[lang]&.abbreviated_weekday[num_day]
translated_date_format = translated_date_format.replace('%a', locales[lang].abbreviated_weekday[num_day])
if locale['abbreviated_weekday'] && locale['abbreviated_weekday'][num_day]
translated_date_format.gsub! '%a', locale['abbreviated_weekday'][num_day]
end
if locales[lang]&.full_weekday[num_day]
translated_date_format = translated_date_format.replace('%A', locales[lang].full_weekday[num_day])
if locale['full_weekday'] && locale['full_weekday'][num_day]
translated_date_format.gsub! '%A', locale['full_weekday'][num_day]
end
if locales[lang]&.abbreviated_month[num_month]
translated_date_format = translated_date_format.replace('%b', locales[lang].abbreviated_month[num_month])
if locale['abbreviated_month'] && locale['abbreviated_month'][num_month]
translated_date_format.gsub! '%b', locale['abbreviated_month'][num_month]
end
if locales[lang]&.full_month[num_month]
translated_date_format = translated_date_format.replace('%B', locales[lang].full_month[num_month])
if locale['full_month'] && locale['full_month'][num_month]
translated_date_format.gsub! '%B', locale['full_month'][num_month]
end

parsed_date.strftime(translated_date_format)
Expand Down

0 comments on commit 7911082

Please sign in to comment.