Comments (4)
I like this idea, but I am not sure how to add it to our current routing setup in server.js.
from franciscan-react.
This is how I would tackle it over the top of my head.
Take for example pages/job.js
, perhaps if possible move the graphql query inside getInitialProps()
like below:
static async getInitialProps ({ query: { id, type } }) {
<Query
query={JobQuery(type)}
variables={{ name: id }}
>
{result => {
if (result.error) // Here you either redirect the user to the new post url or to a custom 404 page
/* Either way, have a look at https://github.com/zeit/next.js/wiki/Redirecting-in-%60getInitialProps%60 AND https://stackoverflow.com/questions/45099395/conditional-redirection-in-next-js */
}}
</Query>
return { result }
}
On the backend side - take a look at wp_old_slug_redirect()
in https://core.trac.wordpress.org/browser/tags/4.9.7/src//wp-includes/query.php#L0
Btw, last year I opened issue #289 on wp-graphql
Fixing this issue will also fix #93 and #108
I hope this helps at all.
from franciscan-react.
@cr101 Hi, i was trying to figure out how to handle redirects. You think that redirecting inside the query result is just fine? You know if there's a particular error message that i have to look for?
Thank you very much for your time :)
from franciscan-react.
@Emiliano-Bucci I haven't implemented this functionality so I'm not sure. If you figure it out please post your solution here
from franciscan-react.
Related Issues (20)
- Add title attributes to iframes
- Make all fonts at least 16px HOT 3
- Grid and Subtitle in Hero are too close together.
- Use imgRegex pattern on all page components HOT 2
- Add materialUI grid components to FacultyListItem.js HOT 2
- Update server.js routing function to handle routes with three params and same id
- Replace HTML encoded characters with actual characters
- Style Residence Halls Page
- Update faculty.js to work with new image sourceUrl values HOT 1
- Make all ACF data available with GraphQL HOT 1
- Change how post types display on search page HOT 2
- Fix changing types on the scroll in search.js HOT 1
- Stop modifying iframe src values HOT 1
- Refactor AppBar.js component
- Serverless Docker Deployments HOT 1
- An in-range update of react is breaking the build 🚨 HOT 6
- Add Google Analytics Outbound link tracking
- An in-range update of next-offline is breaking the build 🚨 HOT 8
- An in-range update of nodemon is breaking the build 🚨 HOT 1
- Hosted link is not working
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 franciscan-react.