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

Add option to make "cobalt publish" add date prefix to filename #562

Closed
Geobert opened this issue Nov 28, 2018 · 28 comments
Closed

Add option to make "cobalt publish" add date prefix to filename #562

Geobert opened this issue Nov 28, 2018 · 28 comments
Labels
enhancement Improve the expected

Comments

@Geobert
Copy link
Contributor

Geobert commented Nov 28, 2018

To keep files in order by chronology, it would be cool to add the YYYY-MM-DD- prefix to the filename on cobalt publish

Proposal

Activation by a configuration field in _cobalt.yml:

posts:
  publish_date_in_filename: true

Default:

  • publish_date_in_filename true for posts
  • publish_date_in_filename false for pages

cobalt publish behavior:

  • Add or update date prefix on file name
  • Set or update published_date in frontmatter

Impact on inferring published_date from filename

For now, we will unconditionally still infer the date from the filename.

An open question for later is whether we should make the inferring of the date exclusive to this flag being enabled. That question is irrelevant until we have Collections support.

@epage epage added the enhancement Improve the expected label Nov 28, 2018
@epage

This comment has been minimized.

@Geobert

This comment has been minimized.

@epage

This comment has been minimized.

@Geobert

This comment has been minimized.

@epage

This comment has been minimized.

@Geobert

This comment has been minimized.

@Geobert

This comment has been minimized.

@Geobert Geobert changed the title Add option to make "cobalt publish" add prefix to filename Add option to make "cobalt publish" add date prefix to filename Dec 5, 2018
@epage
Copy link
Member

epage commented Dec 6, 2018

posts:
  add_date_prefix: true

We need to consider what name makes the intent clear. This name doesn't help us know it is scoped to cobalt publish or that it is the published_date.

We can also look at re-framing the problem. We could instead consider a flag to enable extracting the published_date from the filename and if it is enabled, then cobalt publish also prepends it.

@Geobert

This comment has been minimized.

@Geobert

This comment has been minimized.

@epage

This comment has been minimized.

@Geobert

This comment has been minimized.

@Geobert

This comment has been minimized.

@epage

This comment has been minimized.

@epage

This comment has been minimized.

@Geobert

This comment has been minimized.

@epage

This comment has been minimized.

@Geobert

This comment has been minimized.

@epage

This comment has been minimized.

@Geobert

This comment has been minimized.

@epage
Copy link
Member

epage commented Dec 8, 2018

I tweaked it some to try to make it more explicit. Feel free to update it if I misunderstood

if date present in filename, put it in published_date, adding time only

What happens if the existing date is not the current date?

If cobalt publish is setting published_date, do we still maintain the date extraction logic or just detect it and strip it?

@Geobert

This comment has been minimized.

@epage

This comment has been minimized.

@epage
Copy link
Member

epage commented Jan 12, 2019

I've updated the RFC with my proposal on inferring published_date from filename. It is based on my recent experience of putting my meetup talks on my site. The ideal is that I have a talks collection that parallels my blog collection. Since we can't do that ideal yet, I'm part-way doing things by having dates on regular pages.

See https://github.com/epage/epage.github.io/tree/source/blog/talks

@epage epage closed this as completed in 95839ac Jan 12, 2019
@Geobert
Copy link
Contributor Author

Geobert commented Jan 13, 2019

Just to be sure, the flag to activate is still publish_date_in_filename and not add-date-prefix as stated in the commit message? I've checked master, and it seems to be publish_date_in_filename.

@Geobert
Copy link
Contributor Author

Geobert commented Jan 13, 2019

Tried to use it, for some reason my file is not considered in the posts collection. So it does not trigger the prefixing.

My blog is like this:

blog
  |
  -- src
        |
        -- posts
              |
              -- my_post.md

I'm in blog and call cobalt publish ./src/posts/my_post.md
The file get the published status and the published_date set, but no renaming. Adding some traces shows that my_post.md is not inside the collection :-/

What am I missing?

EDIT:
added more traces, it seems that includes_file got an absolute path in self.subtree whereas I have a relative path for file.

I don't know how I missed this, the only think I can see is that I didn't test after adding checking the collection… so dumb me…

file: ".\\src\\posts\\my_post.md"
subtree: "I:\\Dev\\blog\\src\\posts"

EDIT2: fixed with #587

@epage
Copy link
Member

epage commented Jan 14, 2019

Just to be sure, the flag to activate is still publish_date_in_filename and not add-date-prefix as stated in the commit message? I've checked master, and it seems to be publish_date_in_filename.

I didn't pay attention when rewriting the commit message, I just took from the existing commit message.

@epage
Copy link
Member

epage commented Jan 14, 2019

EDIT2: fixed with #587

Thanks! Will go and look at it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improve the expected
Projects
None yet
Development

No branches or pull requests

2 participants