Comments (1)
I've played with it a little more. It's still not fully functional, but here's what I've learned so far...
If I want a slug to work, I have to use the actual page path. The way I've done it, at least for 1 site, is to edit next.config.js
to add rewrites
. This seems to work, but only for unique paths. IE: if I have a /blog
directory in both website1
and website2
, it won't work. I have to have something like /blog1
and /blog2
. This is because SSG doesn't seem to handle the paths correctly. Well, here's what I've done:
Files
- website1
- index.js
- blog
- [slug].js
// website1/index.js
<Link href={`/blog/post-1`}>
{`Link: docs/docs`}
</Link>
// next.config.js
const nextConfig = {
...
async rewrites() {
return [
{
source:'/blog/:slug',
destination:'/website1/blog/:slug'
}
]
}
}
It looks like I'll need to do this for every single tenant... In nextConfig, source has to always be unique.
Any ideas on resolving this?
I can think of 2 solutions which are not ideal.
-
Create my own system of generating blog post
.js
files and exporting them the correct directory before build. The problem with this is that I won't be able to use shared layouts. Each time I click a link, it will rerender the whole page. Each post will be wrapped in the same layout unfortunately. This is the reason I want slugs mainly. -
Have unique directories for ones with slugs in them. So if I have 10 tenants who run a blog, the url cannot be
{website}/blog
. Instead it'll have to be something like
{website}/myBlog
,{website}/jays-blog
,{website}/blogging
,{website}/blog
,{website}/blogger
,{website}/blogtastic
,
This solution is ugly, and though I haven't thought through the implications of it, I'm willing to bet each tenant will have to have some sort of unique config file with certain keys, like the blogKey, or whatever. This is possible if I run all tenants. But if I have other people using them, I'll have to run certain checks to make sure keys aren't taken, or modify keys at build time when there are duplicate keys. Ugly ugly stuff.
from krabs.
Related Issues (20)
- Fix GitHub CI workflow HOT 1
- Error trying to set up kraber HOT 3
- Tenant url does not work locally HOT 2
- Router push takes subdomain name? HOT 2
- How to add a CMS like Strapi HOT 1
- Guide of how to deloy this HOT 2
- NextJs's Link components do a full refresh HOT 4
- Next.js internationalized routing support
- public folder items not accessible HOT 1
- rewrites dont work HOT 4
- How to use Krabs in Production HOT 1
- Custom response for unlisted tenent HOT 1
- 'Common pages' functionality HOT 3
- Trying to add _middleware at pages directory doesn't work.
- API Routes HOT 1
- Example project does not work HOT 3
- problem start server.js
- How to tenants for subdomains or custom domain in the production?
- nextjs 12.3.0 - Error: Cannot find module 'colors' HOT 1
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 krabs.