File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -155,6 +155,27 @@ export default function(eleventyConfig) {
155155 return content ;
156156 } ) ;
157157
158+ // открытие ссылок в новой вкладке внутри страниц эпизодов
159+ eleventyConfig . addTransform ( 'podcast-content' , async function ( content ) {
160+ if ( ! this . page ?. outputPath ?. endsWith ?. ( 'html' ) ) {
161+ return content ;
162+ }
163+
164+ // игнорируем страницы, не попадающие под url вида `/podcast/<номер эпизода>/`
165+ if ( ! ( / \po d c a s t \/ \d + \/ / . test ( this . page ?. url ) ) ) {
166+ return content ;
167+ }
168+
169+ const { document } = parseHTML ( content ) ;
170+
171+ for ( const link of document . querySelectorAll ( '.podcast__content a[href^="http"]' ) ) {
172+ link . setAttribute ( 'target' , '_blank' ) ;
173+ link . setAttribute ( 'rel' , 'noopener' ) ;
174+ }
175+
176+ return document . toString ( ) ;
177+ } ) ;
178+
158179 // добавление id на заголовки и кнопок для копирования ссылок
159180 eleventyConfig . addTransform ( 'content-headings' , async function ( content ) {
160181 if ( ! this . page ?. outputPath ?. endsWith ?. ( 'html' ) ) {
You can’t perform that action at this time.
0 commit comments