Files
ridebus-website/next.config.js
Zakhar Timoshenko 142ec97959 feat: add Open Graph image generation and SEO metadata
- Introduced `PageSeo` component for managing page metadata for social sharing.
- Created Open Graph image templates using SVG and static fonts for better visual representation.
- Implemented service alert management with functions to check active alerts and format route numbers.
- Added utility functions for generating and watching alert validity.
- Developed a script to generate Open Graph images dynamically based on page content.
- Included tests for service alert functionalities to ensure correctness and reliability.
2026-10-05 13:02:06 +03:00

78 lines
1.8 KiB
JavaScript

const plugins = [];
/** @type {import('next').NextConfig} */
const nextConfig = plugins.reduce((acc, next) => next(acc), {
reactStrictMode: true,
output: 'standalone',
i18n: {
locales: ['en', 'ru'],
defaultLocale: 'en',
},
async redirects() {
return [
{ source: '/privacy.htm', destination: '/privacy', permanent: true },
];
},
webpack: (config, options) => {
const fileLoaderRule = config.module.rules.find((rule) =>
rule.test?.test?.('.svg')
);
config.module.rules.push({
use: 'raw-loader',
resourceQuery: /raw/, // *.svg?url
});
config.module.rules.push({
...fileLoaderRule,
test: /\.svg$/i,
resourceQuery: /url/, // *.svg?url
});
config.module.rules.push({
test: /\.svg$/i,
issuer: fileLoaderRule.issuer,
resourceQuery: { not: [...fileLoaderRule.resourceQuery.not, /url/] }, // exclude if *.svg?url
use: [
options.defaultLoaders.babel,
({ resource }) => ({
loader: '@svgr/webpack',
options: {
babel: false,
svgoConfig: {
plugins: [
{
name: 'preset-default',
params: {
overrides: {
removeViewBox: false,
},
},
},
{
name: 'prefixIds',
params: {
prefix: `${hashCode(resource)}`,
},
},
],
},
},
}),
],
});
return config;
},
});
module.exports = nextConfig;
const hashCode = function (s) {
var h = 0,
l = s.length,
i = 0;
if (l > 0) while (i < l) h = ((h << 5) - h + s.charCodeAt(i++)) | 0;
return h;
};