Skip to content

Commit

Permalink
Merge pull request #189 from MakairaIO/MAKAIRA-4748_update-nextjs
Browse files Browse the repository at this point in the history
MAKAIRA-4748: update nextjs to 15
  • Loading branch information
phongnguyenhh1996 authored Dec 11, 2024
2 parents 1ce96a7 + 02e0cb9 commit 37898fb
Show file tree
Hide file tree
Showing 21 changed files with 1,435 additions and 2,011 deletions.
2 changes: 1 addition & 1 deletion frontend/core/ListingPage/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ function getPageTitle({ type, page }) {
}

function getRobotsContent({ aggregations = {}, queryParams = {} }) {
const count = queryParams.count ?? process.env.PRODUCTS_PER_PAGE
const count = queryParams.count ?? process.env.NEXT_PUBLIC_PRODUCTS_PER_PAGE
const offset = queryParams.offset ?? 0

const currentPageNr = offset / count + 1
Expand Down
23 changes: 23 additions & 0 deletions middleware.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { NextRequest, NextResponse } from 'next/server'

export function middleware(req) {
const pathname = req.nextUrl.pathname

const pattern = /^(.*)$/

if (pattern.test(pathname)) {
const url = req.nextUrl.clone()

const seoUrl = url.pathname

url.searchParams.set('seoUrl', seoUrl)

req.nextUrl.searchParams.forEach((value, key) => {
url.searchParams.set(key, value)
})

return NextResponse.rewrite(url)
}

return NextResponse.next()
}
2 changes: 1 addition & 1 deletion next-env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
/// <reference types="next/image-types/global" />

// NOTE: This file should not be edited
// see https://nextjs.org/docs/basic-features/typescript for more information.
// see https://nextjs.org/docs/pages/building-your-application/configuring/typescript for more information.
45 changes: 28 additions & 17 deletions next.config.js
Original file line number Diff line number Diff line change
@@ -1,33 +1,44 @@
require('dotenv').config()

const path = require('path')
const Dotenv = require('dotenv-webpack')

const withBundleAnalyzer = require('@next/bundle-analyzer')({
enabled: process.env.ANALYZE === 'true',
})

module.exports = withBundleAnalyzer({
trailingSlash: true,

webpack: (config) => {
config.plugins = config.plugins || []

config.plugins = [
...config.plugins,

// Read the .env file
new Dotenv({
path: path.join(__dirname, '.env'),
systemvars: true,
}),
]

return config
},
eslint: {
// Warning: This allows production builds to successfully complete even if
// your project has ESLint errors.
ignoreDuringBuilds: true,
},
async rewrites() {
return [
{
source: '/suche',
destination: '/frontend/search',
},
{
source: '/search',
destination: '/frontend/search',
},
{
source: '/preview',
destination: '/frontend/preview',
},
{
source: '/pali/variants/:id',
destination: '/library/entry',
},
{
source: '/pali',
destination: '/library/entry',
},
{
source: '/:path*',
destination: '/frontend/entry',
},
]
},
})
Loading

0 comments on commit 37898fb

Please sign in to comment.