-
|
Hi. I would like to generate a list of the links I put in a specific sections (music of the week) in my blogpost. I am not that deep in zola/tabi, but am able to code. I would like to know how someone with a bit experience would approach this. Probably with a short code, or is there some build in way? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
|
Hey @Poolitzer! What do you mean by "list of links"? It's not clear to me what's the structure of the data you have now, and what the end result would look like |
Beta Was this translation helpful? Give feedback.
-
|
I implemented it for myself. I originally thought it would be possible to load this out of pages, which is not how zola works. So I did it the way zola intends. Just in case anyone ever stumbles upon this and wants to implement it for themselves: So I wrote a music_links.toml [links]
10 = ["And I want to start to share music I listen to in this section. This week goes to {title} from {artist}, {link}. I got so much an earworm from it that I learned the accords on the guitar, the rhythm is kinda tricky for me.", "YouTube music link", "https://music.youtube.com/watch?v=BlnVP2_dIb4", "Feed the Machine", "PoorMansPosion"]
11 = ["I had a short discussion with my room mate about some electro house music, I did have <em>Around the world</em> by {artist} running in the background. He recommended {link} which I can't recall hearing before, it is such a great track though. It has a spoken intro where Giorgio Moroder says the infamous line \"my name is Giovanni Giorgio but everybody calls me Giorgio\".", "Giorgio by Moroder", "https://music.youtube.com/watch?v=ZFZM6jDTWd4", "Giorgio by Moroder", "Daft Punk"]Since my series is in the folder structure content/blog/weekly/index_starting_with_0 I can use this index from page.components[2] in the shortcode, so the shortcode works like this. The if is to check if I already wrote out the music entry for this week. Otherwise it gives an error here that the index is out of bounds, which stops the website from loading. I didn't find a proper way to use format strings like I would in python/C but this works fine. The extra interpret/song name are now used in a different short code which allows me to do a blog post where all music links are aggregated now: The only thing I am a little bit annoyed with now is that its in chronological order, so new links are added to the bottom of the list. I would have preferred it reversed but I also like this very short code and I dont see a neat way to reverse this. And 5 unnamed params is my limit where I would switch from an array to a dictionary, so its just on the edge for me. |
Beta Was this translation helpful? Give feedback.
I implemented it for myself. I originally thought it would be possible to load this out of pages, which is not how zola works. So I did it the way zola intends.
Just in case anyone ever stumbles upon this and wants to implement it for themselves:
My goal was to just have a shortcode call without params in my blog post series, so I can easily copy paste it into my blog series template, and to not have to write out stuff in two places.
So I wrote a music_links.toml