Giter VIP home page Giter VIP logo

Comments (5)

madrilene avatar madrilene commented on May 29, 2024 3

I'm planning to optimize quite a lot in the coming weeks and will try and include that. I'll let you know!

from eleventy-excellent.

flamedfury avatar flamedfury commented on May 29, 2024 1

Thanks looking into this. I admit that I hadn’t put aside time to look into this myself so I appreciate it.

I do like the idea of drafts that are previewed during development but not published when built

from eleventy-excellent.

httpsterio avatar httpsterio commented on May 29, 2024

@flamedfury
I solved this by editing the getAllPosts const in /config/collections/index.js like this

const getAllPosts = collection => {
  const now = new Date();
  const publishedPost = post => post.date <= now && !post.data.draft;
  const projects = collection.getFilteredByGlob('./src/posts/*.md').filter(publishedPost);
  return projects.reverse();
};

This also stops building posts that have a date set in the future, ie. it schedules their publish date.

from eleventy-excellent.

madrilene avatar madrilene commented on May 29, 2024

The question is, do we want a draft system that still allows a preview of the article in development mode, or is it enough not to build the draft article at all, as is the case here?

from eleventy-excellent.

httpsterio avatar httpsterio commented on May 29, 2024

this was just an example how I made it for my usecase so that Flamed can decide how they want to possibly implement it on their end :)

for a more general solution for the starter, I think it makes sense to build draft posts during development.

Perhaps by setting an environment variable in the dotenv file or directly into the package.json dev script would make sense.

Another option would be to check if eleventy is running using --serve and then show/hide based on that. Personally I'd prefer some option that is easy to turn on/off for development so that I can confirm that drafts are indeed excluded before pushing the site for build.

from eleventy-excellent.

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.