Update SSR rendering to use index.ejs as template. Enhanced jsdom setup for Server-Side Rendering by reading from the EJS template, improving the DOM environment configuration.
All checks were successful
platform/bro-js/bro.landing/pipeline/head This commit looks good
All checks were successful
platform/bro-js/bro.landing/pipeline/head This commit looks good
This commit is contained in:
parent
08ffd5a740
commit
13cd50acc8
@ -20,15 +20,17 @@ const { renderToString } = require('react-dom/server');
|
||||
const { JSDOM } = require('jsdom');
|
||||
const { createCanvas } = require('canvas');
|
||||
|
||||
// Настройка полноценного DOM окружения через jsdom
|
||||
const dom = new JSDOM('<!DOCTYPE html><html><body></body></html>', {
|
||||
// Читаем index.ejs как основу для SSR
|
||||
const ejsTemplatePath = path.resolve(__dirname, '../src/index.ejs');
|
||||
const ejsTemplate = fs.readFileSync(ejsTemplatePath, 'utf-8');
|
||||
|
||||
// Настройка полноценного DOM окружения через jsdom на основе index.ejs
|
||||
const dom = new JSDOM(ejsTemplate, {
|
||||
url: 'http://localhost',
|
||||
pretendToBeVisual: true,
|
||||
resources: 'usable'
|
||||
});
|
||||
|
||||
const canvas = createCanvas(200, 200);
|
||||
|
||||
// Расширяем jsdom canvas поддержкой
|
||||
dom.window.HTMLCanvasElement.prototype.getContext = function() {
|
||||
return createCanvas(200, 200).getContext('2d');
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user