Giter VIP home page Giter VIP logo

Comments (10)

laktek avatar laktek commented on August 17, 2024

You can create an extended directory for each blog post and include the markdown file inside it. It will look like this:

  • content/blog/_2012-9-1-first-post/content.markdown
  • content/blog/_2012-9-4-second-post/content.markdown

This way it will the render following pages:

  • /blog/2012-9-1-first-post.html
  • /blog/2012-9-4-second-post.html

Then, when generating the site, you can use a generator hook to create the blog index. Generator hooks aren't currently documented. But basically, they are callbacks that will run after generating each page (check this basic console output hook). Its first argument would be the path of the file that was generated (eg. /blog/2012-9-1-first-post). You can use the path to build the link and title of the post and append to a custom blog index page.

Also, we can follow your approach and introduce a special content handler for blogs, which would fetch the posts inside a single directory and create the pages. (Again, content handlers is a cool feature that I need to document. For now you can check the spec of the default content handler and also this example with a custom content handler, if you plan to write a custom content handler)

Anyway, I will be starting to port my own blog to Punch during this weekend. It would allow me to review the process more closely and introduce a more idiomatic way to handle blogs in Punch.

from punch.

superplussed avatar superplussed commented on August 17, 2024

Ah cool, thanks for that explanation. The thing I left out of my description is that I'd ideally like to have all of the blog posts displayed on a single page with pagination, and then have a permalink that looks like what you described above.

I think I might actually solve this using firebase, I think a Punch+BAAS option would be pretty cool.

from punch.

laktek avatar laktek commented on August 17, 2024

Yep, Content Handler for Firebase would be really interesting. Feel free to
share your code when done. Also, ping me if you need any help along the way.

On Tue, Sep 4, 2012 at 9:52 PM, Jeremy Smith [email protected]:

Ah cool, thanks for that explanation. The thing I left out of my
description is that I'd ideally like to have all of the blog posts
displayed on a single page with pagination, and then have a permalink that
looks like what you described above.

I think I might actually solve this using firebase, I think a Punch+BAAS
option would be pretty cool.


Reply to this email directly or view it on GitHubhttps://github.com//issues/23#issuecomment-8269249.

from punch.

pdlug avatar pdlug commented on August 17, 2024

I'm wondering if you had any followup thoughts on this use case. I'm looking at the same sort of set up and the content handler approach is interesting but I would like to be able to mix it with the default content handler. The use case I'm thinking of is where there are pages and other assets with the regular content setup in the filesystem and blog posts or some other dynamic content in a database or other JSON filestore. Is there a way to delegate the content handlers to a path like /blog or /posts? I didn't see anything obvious in the docs or source.

from punch.

laktek avatar laktek commented on August 17, 2024

@pdlug I'm currently working on a similar setup for my personal blog based on Punch. I will provide a detailed example when it's done (probably within next 2 weeks).

from punch.

pdlug avatar pdlug commented on August 17, 2024

@laktek wondering if you had any further thoughts on this? This use case keeps coming up in my use of punch. I'm especially finding the need for shared data scoped to a section of the site, for example content/events needs a list of events shared with all subpages but I don't really want to add this to the toplevel shared.json

from punch.

laktek avatar laktek commented on August 17, 2024

@pdlug I'm actually working on this task at this very moment :) I just finished porting my blog to Punch and now extracting the blog handler to its own plugin. Hoping to release it this week.

BTW, is that event list contained in a JSON file? If so, you can add a symlink to it from the extended directory of each subpage. Then you should be able to use the event data as you'd normally do with other page specific data. Not a perfect solution but it should work.

Actually the better way to go about it would be to write a custom content handler. The blog content handler I'm working could be used as an example on how to write a custom content handler for specific sections, while delegating the handling of other content to default handler.

I'll update this thread as soon as I push the changes to GitHub.

from punch.

pdlug avatar pdlug commented on August 17, 2024

Yes, the list is in JSON, I hadn't considered symlinks that works just fine in this case.

from punch.

paddykontschak avatar paddykontschak commented on August 17, 2024

@laktek How about RSS/Atom feeds for a "punched" blog? Are normal feeds even possible with the way punch works? Or will we have to use an extra tool (Jekyll for example needs jsrss for feeds)?

from punch.

laktek avatar laktek commented on August 17, 2024

If you want to run a blog with Punch, checkout the Punch Blog Boilerplate.

For more details about the implementation, check this post - http://www.laktek.com/2012/11/26/a-fast-intuitive-blogging-tool-based-on-punch

from punch.

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.