Comments (10)
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.
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.
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.
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.
@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.
@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.
@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.
Yes, the list is in JSON, I hadn't considered symlinks that works just fine in this case.
from punch.
@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.
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)
- TypeError: Cannot call method 'getTime' of null HOT 5
- Ability to add self-contained widgets (css, js, template) HOT 2
- Issues displaying {{date}} HOT 2
- style failed to compile HOT 2
- Cannot start server Connect has no method 'logger' HOT 1
- Can't get this working in a docker container
- Pulling bundle assets from outside local directory
- Punch Plugin: How to find the file path to the "templates" directory? HOT 2
- S3 gzip support
- Failed to read the configurations. HOT 1
- Copy command fails with paths that contain spaces HOT 1
- Failing basic setup HOT 2
- Trouble Implementing Autoprefixer compiler/minifier
- is this still happening? HOT 1
- Themes?
- What is the best practice for i18n?
- Creating intro.markdown in contents/_index during tutorial doesn't render the HTML HOT 1
- Custom compiler works only on generate HOT 4
- Javascript does not bundle HOT 1
- Mime.extension and Mime.lookup is not a function HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from punch.