Nhật ký công việc cho nhiệm vụ "Cấu hình thẻ meta"
12 июл. 2026 г., 22:17:37
Có rất nhiều liên kết hỏng, bao gồm cả những liên kết đáng lẽ ra là nội bộ nhưng lại dẫn đến các trang web rác đã chết từ lâu. Biết sao được, trang web này mua lại đồ cũ sang tay mà :-) Thế là đành phải viết thêm hàm lọc nội dung vào trình nhập liệu (importer) và tiến hành nhập lại toàn bộ nội dung.
export function cleanupImportingContent(
content: string | undefined,
): string | undefined {
if (!content) {
return content
}
content = content.replaceAll('http://vietnamguru.ru/', '/')
content = content.replaceAll('/city/hochiminh"', '/city/ho-chi-minh"')
// /city/phan-thiet
content = content.replaceAll(
'/place/ho-chi-minh-museum"',
'/place/ho-chi-minh-museum-phan-thiet"',
)
// /city/nha-trang
content = content.replaceAll(
'<a href="http://thaibase.ru/city/phatthaya">Паттайя</a>',
'Pattaya',
)
// /city/phu-quoc
content = content.replaceAll(
'<a href="http://thaibase.ru/city/phuket">Пхукет</a>',
'Phuket',
)
// /city/cam-ranh
content = content.replaceAll('/beach/bai-dai"', '/place/bai-dai"')
// /city/hai-phong
content = content.replaceAll(
'<a href="http://vietnow.ru/city/ha-noi">столицы</a>',
'<a href="/city/ha-noi">Hà Nội</a>',
)
// /city/hai-phong
content = content.replaceAll(
'<a href="http://vietnow.ru/city/ha-long">Халонг</a>',
'<a href="/city/ha-long">Hạ Long</a>',
)
// /city/bien-hoa
content = content.replaceAll(
'<a href="http://vietnow.ru/city/ho-chi-minh">Хошимин</a>',
'<a href="/city/ho-chi-minh">Hồ Chí Minh</a>',
)
// /city/bien-hoa
content = content.replaceAll(
'<a href="http://airportguru.ru/airport/SGN">Таншоннят</a>',
'Tân Sơn Nhất',
)
/**
* Thay thế tất cả các liên kết, hình như có rất nhiều
*/
content = content.replaceAll('http://vietnow.ru/', '/')
content = content.replaceAll(
'<iframe width="560" height="315" src="https://www.youtube.com/embed/TTTsp1_5-b4" frameborder="0" allowfullscreen></iframe>',
'',
)
content = content.replaceAll(
'Фото и видео произошедшего вы можете посмотреть пройдя по этой <a href="https://goo.gl/G5pk5P"target="_blank">ССЫЛКЕ</a>.',
'',
)
content = content.replaceAll(
'<iframe width="560" height="315" src="https://www.youtube.com/embed/ze0apK_iDnI" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>',
'',
)
content = content.replaceAll(
'Все подробности о проведении фестиваля можно узнать на <a href="http://www.huefestival.com/" target="_blank">официальном сайте мероприятия</a>.',
'',
)
content = content.replaceAll(
'Кафе находится по адресу <a href="https://goo.gl/maps/jrAuqWtUzrK2" target="_blank">23 Ngo Van So</a>.',
'',
)
content = content.replaceAll(
`Например, такой вариант:
http://www.ebay.com/itm/Bien-Hoa-Ceramics-Perfect-GuanYin-Statue-/382015625988`,
'',
)
content = content.replaceAll(
`Подробнее об апартаментах вы можете прочитать на странице
<a href="http://vietnamguru.ru/blog/questions-apartments-villas-mui-ne" target="_blank">Часто задаваемые вопросы по апартаментам (1, 2 или 3 спальни) и виллам (3 спальни) в Муйне</a>`,
'',
)
/**
* Ở một số chỗ, các liên kết thiếu khoảng trắng giữa các thuộc tính,
* khiến chúng bị hỏng. Do đó chúng ta thực hiện hai lần thay thế.
*/
content = content.replaceAll(' target="_blank"', '')
content = content.replaceAll('target="_blank"', '')
// /place/vinipearl-land-hon-tre-island
return content
}