Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redirecting to latest version #31

Open
ScottPenhall98 opened this issue Jun 14, 2022 · 1 comment
Open

Redirecting to latest version #31

ScottPenhall98 opened this issue Jun 14, 2022 · 1 comment
Labels
issue: enhancement Issue suggesting an enhancement to an existing feature Issue: help wanted Looking for someone to tackle this issue severity: low If the issue only affects a very niche base of users and an easily implemented workaround can solve

Comments

@ScottPenhall98
Copy link

Description

Hey guys, really love your package. Still a bit of a ways to got but getting there. I was trying to implement my own redirects, as currently, the shown version displays the Published page, I was trying to set it so when a versioned type is clicked in Content Manager. it would display the most recent version by forcing a redirect, which is how most of our CMS's work.

Is there any way you could recommend how I approach this?

Code snippets

So, I made some middleware that does almost exactly what I want. Only problem is when you redirect within selecting a react link it doesn't do a proper redirect. It will just replace the content of what is in the text fields, which works.... until you select publish. here's the middleware code.

module.exports = (config, {strapi}) => {
  return async (ctx, next) => {
    if (ctx.url.includes('/content-manager/single-types')) {
      const dataVersions = ctx.response.body.versions;
      if (dataVersions && dataVersions.length > 1) {
        let newestVersion;
        dataVersions.forEach(version => {
          if (!newestVersion || newestVersion.versionNumber < version.versionNumber) {
            newestVersion = version;
          }
        });
        ctx.redirect('/admin/content-manager/collectionType/api::about-content.about-content/' + newestVersion.id);
      }
    }
  }
};

Any other suggestions or recommendations are welcome

@martincapek martincapek added the Issue: help wanted Looking for someone to tackle this issue label Jul 25, 2022
@omikulcik omikulcik added issue: enhancement Issue suggesting an enhancement to an existing feature severity: low If the issue only affects a very niche base of users and an easily implemented workaround can solve labels Jun 23, 2023
@omikulcik
Copy link
Collaborator

Hey @ScottPenhall98, it would certainly be more convenient to have the most recent version displayed and thank you for proposing it. However, we will consider implementing this later as we currently have more important issues to solve.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
issue: enhancement Issue suggesting an enhancement to an existing feature Issue: help wanted Looking for someone to tackle this issue severity: low If the issue only affects a very niche base of users and an easily implemented workaround can solve
Projects
None yet
Development

No branches or pull requests

3 participants