Giter Club home page Giter Club logo

Comments (6)

jandudulski avatar jandudulski commented on June 2, 2024 1

My general idea was that the script would:

  • load draft file
  • split file into a front matter object and content
  • check if there is a date field already and prompt to verify if user wants to overwrite it
  • add date field to front matter object
  • create a new file with updated front matter and the content

But unfortunately, I haven't had time yet to take a look at how complicated it might be to implement.

from jekyll-compose.

alzeih avatar alzeih commented on June 2, 2024

I had a go at implementing this but I can't see a good way to solve this without introducing code that could destructively alter source files and cause unexpected behaviour with posting dates.

The easiest nearly fix would be to add a date to a draft when it is created, but this then causes problems publishing with the --date option as the two dates may disagree. Even having a unique sentinel like value to find and replace with the publish date wouldn't work if a post was published then unpublished.

Parsing source files and altering their contents seems like a recipe for breaking or losing posts. Maybe publishing could try to set the published date in the front matter and not remove the draft so the original isn't lost, but it could still cause lost or corrupted posts so would need to try to explain this to the user every time they published... yuck.

Do you have a better idea I've missed?

from jekyll-compose.

pathawks avatar pathawks commented on June 2, 2024

My general idea was that the script would

I think this is the right approach

from jekyll-compose.

alzeih avatar alzeih commented on June 2, 2024

If you like, take a look at #63.

from jekyll-compose.

alzeih avatar alzeih commented on June 2, 2024

Hmm, instead of altering the file contents as well with publish and unpublish, what about a separate jekyll touch command?

It can alter any post, draft or not. Jekyll seems to prefer the yaml front matter over the filename for posts, so jekyll touch doesn't need to move the file for the new date to apply (and jekyll unpublish then jekyll publish would move the file to the current date).

All the logic for prompting the user and/or making backups before editing files would be handled by that command, and not mixed with publish and unpublish.

Downside: in some cases, more than one command is needed to publish a draft. Also, published posts with dates that are unpublished with a date must be touched to be correct.

Upside: simplifies publish and unpublish. Editing file front matter (or even contents) can then be used by another command and the prompting/backup behaviour can be shared. e.g: renaming posts, additional front matter, a edit command to open EDITOR?

from jekyll-compose.

pathawks avatar pathawks commented on June 2, 2024

Has PR #63

from jekyll-compose.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.