empress / empress-blog

Fully-functional, SEO friendly static site implementation of a blog system built on Ember
https://empress-blog.netlify.app/
MIT License
180 stars 30 forks source link

How do I add content at arbitrary paths? #39

Open ghost opened 5 years ago

ghost commented 5 years ago

Creating a new post adds it to the root path. I have guessed at a few ways this might work, but failed.

I would like to structure my content so that /blog/post-slug-here/ would work for blog posts. Ideally, whatever folder structure I use would be reflected in the build.

I would like pages to appear without the /page/ prefix. I think it makes sense to keep pages separate from /content/ that would be used for post listings. Is there a way to configure this?

jelhan commented 3 years ago

I have a similar requirement. But it seems as this is not supported yet.

The paths are hard-coded at at least two places:

  1. In an instance initializer, which registers them in Ember at run-time: https://github.com/empress/empress-blog/blob/f8f58a6352aee05db59dbc8c07640cc91cf2d475/app/initializers/routes.js#L4-L9
  2. In the prember configuration, which ensures that they are prerendered: https://github.com/empress/empress-blog/blob/07839af162cc6c9b00c798d8bca12c27162457d0/index.js#L230-L265

I think it would be great if the paths could be configured. But it might not be that easy. So far empress-blog seems to only use run-time configuration (config/environment.js). But this seems to be better fitted with build-time configuration. The pages are rendered at build-time and in the instance initializer @embroider/macros could be used to resolve the configured path.

Maybe like this?

// config/empress-blog.js

module.exports = function(environment) {
  return {
    paths: {
      author: '/a/:id',
      page: '/:id',
      post: '/p/:id',
      tag: '/t/:id',
    }
  };
};
jelhan commented 3 years ago

@mansona Are you open for a pull request implementing this feature? Maybe first in config/environment.js, which could also be consumed at build-time, and discuss moving the configuration to its own file separately?