Changeset bf61be7 in Klonkt


Ignore:
Timestamp:
06/14/2026 02:59:41 PM (3 months ago)
Author:
roboburr <roboburr@…>
Branches:
main
Children:
4d7443b
Parents:
52215bc
Message:

hub: company overview on / (latest posts from all users) + /user/ routing

In hub mode '/' is no longer the primary PrutFolio but an overview:
hero (company site title) + "Latest posts" across ALL sites + "PrutFolio's"
list. Solo keeps '/' as the single PrutFolio.

  • routes/hub.js: GET / -> hub overview in hub, otherwise next() (solo -> posts.js).
  • views/pages/hub-home.ejs: overview layout (cards + user list).
  • middleware/site.js: PrutFolio's now accessible via /user/:slug (canonical) and /sites/:slug (legacy); siteUrlBase follows the used prefix.
  • server.js: hubRoutes mounted before postsRoutes.

Co-Authored-By: Claude <noreply@…>

Location:
src
Files:
2 added
2 edited

Legend:

Unmodified
Added
Removed
  • src/middleware/site.js

    r52215bc rbf61be7  
    2121  // pinnen altijd op de primaire site.
    2222  if (tenancy === 'hub') {
    23     const m = req.path.match(/^\/sites\/([a-zA-Z0-9_-]+)(\/.*)?$/);
     23    // Een PrutFolio is bereikbaar via /user/:slug (canoniek) én /sites/:slug (legacy).
     24    const m = req.path.match(/^\/(sites|user)\/([a-zA-Z0-9_-]+)(\/.*)?$/);
    2425    if (m) {
    25       const site = db.prepare('SELECT * FROM sites WHERE slug = ?').get(m[1]);
     26      const site = db.prepare('SELECT * FROM sites WHERE slug = ?').get(m[2]);
    2627      if (site) {
    2728        res.locals.site = site;
    28         req.url = (m[2] || '/'); // strip /sites/:slug zodat downstream de rest ziet
    29         res.locals.siteUrlBase = `/sites/${m[1]}`;
     29        req.url = (m[3] || '/'); // strip /<prefix>/:slug zodat downstream de rest ziet
     30        res.locals.siteUrlBase = `/${m[1]}/${m[2]}`;
    3031        return next();
    3132      }
  • src/server.js

    r52215bc rbf61be7  
    3838import usersRoutes from './routes/users.js';
    3939import feedRoutes from './routes/feed.js';
     40import hubRoutes from './routes/hub.js';
    4041import postsRoutes from './routes/posts.js';
    4142
     
    181182// Feed/sitemap routes are mounted at root because they're at well-known paths
    182183app.use('/', feedRoutes);
     184app.use('/', hubRoutes); // hub-overview op '/' (solo: next() -> postsRoutes)
    183185app.use('/', postsRoutes);
    184186
Note: See TracChangeset for help on using the changeset viewer.