Is it possible to show post numbers for each post (Or easy to do via CSS or similar). My use case is running forum mafia, where allowing users to easily refer to a post without the bulk of quoting it would be amazing.
Just press the link button under each post, and the post number is visible there.
It is hard to say if this is what you are looking for, but it should get you close.
We use that CSS to put #1, #2, et al on a topic after the date/timestamp.
Yes, it is, this is amazing 
Thanks so much!
a.post-date span {
margin-right: 1em;
}
a.post-date:after {
content: "#"attr(data-post-number);
}
Esto ya no parece funcionar. ¿Hay alguna forma actual de mostrar los números de las publicaciones?
Ahora la etiqueta post no tiene un identificador data-post-number, este estilo CSS no funciona, ¿hay alguna otra forma de solucionarlo?
No sin javascript.
Gracias por la respuesta, ¿es este un plugin que necesita ser escrito para llamar a la API? ¿O está simplemente escrito en el componente del tema?
¡Muchas gracias! ¡Ya he resuelto el problema!
api.decorateCooked(() => {
var add_post_number_timer = setTimeout(() => {
var articles = document.getElementsByTagName("article");
for (var i = 0; i < articles.length; i++) {
var post_date = articles[i].getElementsByClassName("post-date");
if (post_date.length != 0) {
var post_number = articles[i].getAttribute("id").replace("post_", "");
post_date[1].setAttribute("data-post-number", post_number);
}
}
clearTimeout(add_post_number_timer);
}, 500);
}, {
id: 'add_post_number'
});
¡Genial! Descubriste cómo hacerlo. ![]()
Aquí tienes algunas mejoras que puedes hacer:
-
api.decoratedCookedserá obsoleto y se llama en cada publicación.
Puedes usardecorateCookedElementen su lugar, que funciona sin jQuery. -
Se pasa un
elementque representa la publicación actual a la API; puedes usarlo como contexto de tu publicación. -
Puedes trabajar con la función
schedulede ember para esperar a que se renderice el elemento.
import { schedule } from "@ember/runloop";
// const { schedule } = require("@ember/runloop"); // usa esto si se ejecuta en Admin UI
api.decorateCookedElement((element, /* helper */) => {
schedule("afterRender", () => {
const article = element.closest("article");
if (article) {
article.dataset.postNumber = article.id.replace("post_", "");
}
});
});

Muchas gracias por la corrección.