Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Исправляет проблему с генерацией og-картинок для материалов с иллюстрациями #1276

Merged
merged 2 commits into from
Jul 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ exports.dropContent = () => del(['content', ...contentRepFolders.map((folder) =>
// Social cards

const socialCards = async () => {
const browser = await puppeteer.launch({ headless: true })
const browser = await puppeteer.launch({ headless: 'new' })
const page = await browser.newPage()

return pipeline(
Expand All @@ -135,10 +135,19 @@ const socialCards = async () => {
objectMode: true,
async transform(file, encoding, done) {
const imagePath = file.path.replace('index.sc.html', 'images/covers/')
await fsp.mkdir(imagePath, { recursive: true })
if (!fs.existsSync(imagePath)) {
await fsp.mkdir(imagePath, { recursive: true })
}

await page.goto('file://' + file.path)

await page.evaluate(() => {
const image = document.querySelector('.social-card__image')
if (image) {
image.setAttribute('src', image.src.replace(/.*images\//, 'images/'))
}
})

await page.setViewport({
width: 503,
height: 273,
Expand Down
Loading