MoOx / phenomic

DEPRECATED. Please use Next.js instead.
https://nextjs.org
MIT License
3.21k stars 249 forks source link

[plugin-rss-feed] Permalinks don't match posts' routes. #1257

Open jcayzac opened 6 years ago

jcayzac commented 6 years ago

My permalinks don't match the routes I've defined (the rest works fine, only the RSS feed is affected).

phenomic.config.js

module.exports = {
  content: {
    pages: { root: 'content', globs: ['*.md'] },
    posts: { root: 'content/posts', globs: ['**/*.md'] },
  },
  plugins: [
    ['@phenomic/plugin-rss-feed', { feeds: { query: { path: 'posts', limit: 20 } } }
  ]
}

Routes

Link to a blog post is e.g. /first-post (without any trailing slash or any other path component).

<Router history={browserHistory}>
  <Route path="/about" component={Page} />
  <Route path="/" component={Page} />
  <Route path="/404.html" component={PageError} />

  <Route path="/p:after" component={PageBlog} />
  <Route path="/*" component={PageBlogPost} />
</Router>

Permalinks in the generated feed

The generated RSS link for the blog post mentioned above is /posts/first-post/ (instead of /first-post).

<item>
  <title>
    <![CDATA[ This is a first post ]]>
  </title>
  <link>http://localhost:5000/posts/first-post/</link>
  <guid isPermaLink="true">http://localhost:5000/posts/first-post/</guid>
  <pubDate>Sun, 01 Jan 2017 00:00:00 GMT</pubDate>
</item>

I think it mistakenly uses the query domain instead of the route 🤔

jcayzac commented 6 years ago

It looks like the /<query.path>/<id>/ route is hard-coded at https://github.com/phenomic/phenomic/blob/master/packages/plugin-rss-feed/src/index.js#L63-L67

jcayzac commented 6 years ago

I tried specifying the feeds.<my feed url>.map option, which would allow me to override this behavior, but neither a function nor a copy of defaultMap works ーI get an unhandled rejected promise error 😢

EDIT: feeds fail only on development server. If I build the static site, they're generated correctly (and my custom map works). I had to fork the rss plugin just to get rid of the hardcoded routes, tho… https://github.com/jcayzac/b/blob/master/phenomic.config.js#L44 https://github.com/jcayzac/b/blob/master/Rss.js#L39-L43

MoOx commented 6 years ago

We should definitely work on that. Contribution welcome. Maybe I fixed the situation on master branch already for dev server...

MoOx commented 5 years ago

rr3 won't be supported in phenomic revamp. A new solution will show up. This problem will have to be handled differently.

MoOx commented 5 years ago

Reopening as it's still a good reminder