Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[permalink] Ensure that the permalink is correctly set #199 #200

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

hacketiwack
Copy link

It ensures that the permalink_lang attribute is set correctly and can be used when a permalink attribute is set at the site level. It is, indeed, not enough to check if the permalink is undefined. The permalink might be set to empty. Moreover, we should check that the page has a lang attribute isn't empty as well.

馃敜 Polyglot PR

In cases where no permalink is set in the post or page, but there is a permalink set at the site level, this fix ensures that the permalink_lang attribute is set correctly.

Then, a language switch can be simply implemented, example below:

<div class="language">
  {% for language in site.languages %}
    {% if language != site.default_lang %}
      {% assign url = language | append: page.permalink_lang[language] %}
    {% else %}
      {% assign url = page.permalink_lang[language] %}
    {% endif %}
    <a class="nav-link" {% static_href %} href="{{url | relative_url}}" {% endstatic_href %}>
      {{ site.data.translations.languages[language] }}
    </a>
  {% endfor %}
</div>

Note: I didn't create a test case, because I'm not familiar with Ruby and the testing mechanism. 馃槩

Type of change

  • Docs update (changes to the readme or a site page, no code changes)
  • Ops wrangling (automation or test improvements)
  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Sweet release (needs a lot of work and effort)
  • Something else (explain please)

Checklists

  • If modifying code, at least one test has been added to the suite

It ensures that the permalink_lang attribute is set correctly and can be used when a permalink attribute is set at the site level.
It is, indeed, not enough to check if the permalink is undefined. The permalink might be set to empty. Moreover, we should check that the page has a lang attribute isn't empty as well.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant