Understanding hugo shortcodes `"{{ index .Params 0 }}"`

Hi,

I’m trying to add cactus comments:

to my blog.

As noted in the 3rd code block, initComments function,
commentSectionId has a value of "{{ index .Params 0 }}"

From my understanding this value isn’t being properly parsed by cactus because I get the following output:
Error: M_NOT_FOUND Room alias #comments_blog_:domain.tld not found

As you can see after the blog part, there is another underscore, which I’m guessing is supposed to be the ID of the post, or it’s slug?

Since I/m pretty new to hugo, I’m trying to understand what does "{{ index .Params 0 }}" actually mean? I think it trying to pass the 1st parameter of index? What is index in this case?

What is the relation between the third code block and this shortcut? You’ll probably have a better chance to receive help if you provide more information.

Acidentally copied the wrong link.

The way I implemented it is by bypassing chat.html as in the link above, and just placing the code block into layouts/partials/comments.html

Ideally what I would want is for commentSectionId to have the value of the current post name, but then I would need to have 1:1 ratio of channels in my matrix server, same to the ammount of posts on the blog.

So the best solution would be to be able to set a custom value for every blog, similar to tags for specific matrix channels.
eg. I have a total of 10 posts, out of which 5 are tech, 5 are politics. Then, can I have hugo have a commentSectionId variable in each post.md, which will somehow be autofill the one in layouts/partials/comments.html?

Edit: This solved my issue -
"{{ index .Params.tags 0 }}"

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.