Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

113
Vistas
Pure Js character limit

How can I limit the post title to 70 characters with the last post's script I use on blogger?

The post title is sometimes more than 70 characters, which distorts the image.

    let postCount = 5;
    
    function funcrct(JSON) {
        const POSTS = JSON.feed.entry;
        let postTitle, postUrl = "";
        let rpc = document.querySelector(".postList");
        for (let i = 0; i < postCount; i++) {
            POSTS[i].link.forEach((el, i) => {
                if (el.rel === "alternate") {
                    postTitle = el.title;
if (postTitle.length >= 70) postTitle.subString(0,69)
                    postUrl = el.href;
                }
            })
    
            let thumbnail = POSTS[i].content.$t.match(/(http)?s?:?(\/\/[^"']*\.(?:webp))/)[0];
    
            rpc.innerHTML += `<li>
    <a href="${postUrl}"><figure>       
    <img src="${thumbnail}" alt="${postTitle}"/>
    <figcaption>
    ${postTitle}</figcaption></figure></a>
    </li>`;
        }
    }
    
    var url = document.location.origin;
    var fsrc = document.createElement("script");
    fsrc.src = `${url}/feeds/posts/default?alt=json-in-script&start-index=1&max-results=${postCount}&callback=funcrct`;
    
    
    document.body.appendChild(fsrc);
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

if (postTitle.length >= 70) postTitle.substring(0,69)
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda