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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use date_format if set in configuration #70

Merged
merged 3 commits into from
Apr 7, 2017
Merged

Use date_format if set in configuration #70

merged 3 commits into from
Apr 7, 2017

Conversation

ward
Copy link
Contributor

@ward ward commented Oct 28, 2016

If it is not set, fall back to the previous default.

If it is not set, fall back to the previous default.
@ward ward mentioned this pull request Oct 28, 2016
@ward
Copy link
Contributor Author

ward commented Oct 28, 2016

See issue #69

@DirtyF
Copy link
Member

DirtyF commented Oct 28, 2016

/cc @jekyll/minima What do you think? Should we name this differently?

Copy link
Member

@DirtyF DirtyF left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, but lacks documentation.

@parkr
Copy link
Member

parkr commented Oct 28, 2016

I might do site.minima.date_format. Starting to get more concerned about overlapping parameters.

@ashmaroli
Copy link
Member

ashmaroli commented Oct 29, 2016

I might do site.minima.date_format. Starting to get more concerned about overlapping parameters.

I have written a plugin jekyll-data that reads data files in theme gems and also provides a theme liquid-drop as an alias for site.data.[theme-name].
If @jekyll/minima is fine with require-ing that plugin, then we can ship a minima.yml inside
<minima-root>/_data that contains minima-specific configurations.

<!-- 'theme.date_format' is an alias for 'site.data.minima.date_format' -->
{% assign date_format = theme.date_format %}
{% if theme.date_format %}
  <span class="post-meta">{{ post.date | date: date_format }}</span>
{% else %}
  <span class="post-meta">{{ post.date | date: "%b %-d, %Y" }}</span>
{% endif %}

@oncleben31
Copy link
Contributor

Don't know if there is any performance impact. I though that using the default liquid filter is better than the if ... else ... endif

Something like

{% assign date_format = theme.date_format | default:  "%b %-d, %Y" %}
<span class="post-meta">{{ post.date | date: date_format }}

Is there any pros and cons?

@ward
Copy link
Contributor Author

ward commented Oct 30, 2016

  • Documentation: Adding a line in customization seems like it should be enough, correct?
  • Naming: I tried a quick search before deciding date_format to see if there was some jekyll default for this, but did not find anything. Found that quite surprising actually, I imagine plenty of people would want to change this, regardless of what theme they use. (Though I admit on older jekyll versions I did it by editing the theme files directly)
  • default vs if: I did (and do) not know enough about liquid. If default is more performant, then it is the preferred choice indeed.

@DirtyF
Copy link
Member

DirtyF commented Oct 30, 2016

@ward

yeah, based on what Parkr recommends, I was thinking of something like:

Change default date format

You can do so by specifying site.minima.date_format in _config.yml:

# Minima date format
# refer to http://shopify.github.io/liquid/filters/date/ if you want to customize this
site:
  minima:
    date_format: "%b %-d, %Y"

I would even add the above snippet by default in the _config.yml and use it right away in the theme, if you ask me, so you can simplify the layout.

@benbalter
Copy link
Contributor

If it's a site configuration flag, I don't understand why it'd be in a data file (content), rather than _config.yml (site configuration)

@ashmaroli
Copy link
Member

If it's a site configuration flag, I don't understand why it'd be in a data file (content), rather than _config.yml (site configuration)

because to me, site.minima.myvariable is not site-configuration, but rather, a theme-configuration; and jekyll-data plugin expects to find theme configuration in /_data dir.

I may be wrong in thinking that data files can blur the lines between content and configuration, but its worth a shot. 😃

* Configuration as `site.minima.date_format` instead of top level.
* Update README with information about it
* Add example in `_config.yml` file
* Use assign-default instead of if-then-else
@DirtyF
Copy link
Member

DirtyF commented Nov 1, 2016

@ward Thanks!

@ward
Copy link
Contributor Author

ward commented Dec 23, 2016

Any update on when this will be merged in?

@benbalter
Copy link
Contributor

@jekyllbot: merge +minor.

Thanks @ward! Sorry for the delay in getting this merged.

@jekyllbot jekyllbot merged commit b4b005e into jekyll:master Apr 7, 2017
jekyllbot added a commit that referenced this pull request Apr 7, 2017
@NicolasWebDev
Copy link

Would it be possible to have a release that includes this change?

Thanks.

@DirtyF
Copy link
Member

DirtyF commented Apr 9, 2017

@ward @Sathors FYI if you want to benefit from the latest changes on the theme you can always point to the masterbranch of this repo meanwhile.

gem "minima", :git => "https://github.com/jekyll/minima.git", :branch => "master"

@NicolasWebDev
Copy link

Thanks for the tips, I knew about it, but it is more maintenance burden.

More than anything, it is because the Readme does indicate this option, so one is expecting it to be present in the release.

Thank you nonetheless.

domingohui pushed a commit to domingohui/minima that referenced this pull request Apr 14, 2017
domingohui pushed a commit to domingohui/minima that referenced this pull request Apr 14, 2017
@jekyll jekyll locked and limited conversation to collaborators Apr 28, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants