Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

231
Visualizações
Expand JSON with UTC date/time into weekday sub-entries

I have a JSON structure built with Hugo listing all posts of each User:

{
    "user1": [{
        "publishdate": "2021-10-11T00:00:00Z",
        "section": "news",
        "url": "http://www.example.com/news/another-plain-text/"
    }],
    "user2": [{
        "publishdate": "2021-05-20T00:00:00Z",
        "section": "images",
        "url": "http://www.example.com/images/gifs/"
    }, {
        "publishdate": "2021-05-19T00:00:00Z",
        "section": "images",
        "url": "http://www.example.com/images/external-images/"
    }, {
        "publishdate": "2021-05-18T00:00:00Z",
        "section": "images",
        "url": "http://www.example.com/images/local-images/"
    }]
}

I'll be using this information to build a chart with Chartist:

const settings = {
  // A labels array that can contain any sort of values
  labels: [ 'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat' ],
  // Our series array that contains series objects or in this case series data arrays
  series: [
    [ 5, 30, 21, 14, 7, 20 ]
  ]
};

However, it proved to be quite a challenge to configure the data like the above example (slightly expanded from Chartist docs) because I don't have entries grouped by weekday and I was trying to avoid having to filter() each entry individually in order to, well, filter, by weekday just so I could count.

How could I, perhaps, expand it into something more usable, in an efficient way? — this example has just a few entries, but that could be hundreds or thousands in a few years.

I know, I should be doing this with Hugo but while it's an incredible tool, slightly more complex theme logics are incredibly difficult to create and Hugo's community is... peculiar.

If you have a more intelligent approach, I'm all ears u.u'

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda