this post was submitted on 10 Dec 2022
1 points (100.0% liked)

Lemmy

12524 readers
10 users here now

Everything about Lemmy; bugs, gripes, praises, and advocacy.

For discussion about the lemmy.ml instance, go to !meta@lemmy.ml.

founded 4 years ago
MODERATORS
 

I've written Go bindings for Lemmy's HTTP API. If anyone wants to use them, the import path is go.arsenm.dev/go-lemmy. The repo is at https://gitea.arsenm.dev/Arsen6331/go-lemmy with a mirror on GitHub: https://github.com/Arsen6331/go-lemmy.

you are viewing a single comment's thread
view the rest of the comments
[–] picoblaanket@lemmy.ml 1 points 2 years ago (6 children)

Hey, thank you for sharing.

May I ask - How are you planning to use them?

[–] Arsen6331@lemmygrad.ml 1 points 2 years ago (5 children)

I want to try making a bot and maybe a client of some sort

[–] picoblaanket@lemmy.ml 1 points 2 years ago (4 children)

Cool. I often wonder about pulling Lemmy data/components into Hugo (a static website, coded in Go).

For example:

  1. Showing Lemmy ‘cards’ in the main Hugo feed (which display meta info about a Lemmy post (such as: number of comments, topic title, and post summary)).

  2. Or even... displaying a Lemmy post’s entire comment section (creating a nested comment-section for each Hugo post).

It seems like you’ve experimented quite a bit.

Do you feel like either of those is possible?

[–] Arsen6331@lemmygrad.ml 1 points 2 years ago* (last edited 2 years ago) (1 children)

I've used Hugo quite a bit. It's a static site generator. That's the problem, it's static. There's no way to run actual Go code on a static site because it runs entirely client-side. However, Lemmy has an official JS client which is perfect for that use case. With lemmy-js-client, yes, you could (probably) display Lemmy info on a Hugo site

[–] picoblaanket@lemmy.ml 1 points 2 years ago (1 children)

Hey, thank you for the reply.

I went through the js-client docs, and the available methods.

Seems GetPost is the one required for importing comments.

I suppose it would arrive (to Hugo) as a json object (identical to the one in the console log of a Lemmy post).

Within that GetPost data, I see that each nested-comment has a parent-comment-id.

**

1 - So would the idea be to rebuild a UI for the nested comments section?

(and then connect other JS-client objects to new UI-elements, such as voting-buttons and reply-inputs)?

2 - Or is there an easier way to display the data, since [Lemmy] and [all built-Hugo-pages] are running on the same server/domain?

(and since Lemmy already has the UI code to build nested comments)

[NOTE: Lemmy is in docker, Hugo-pages are in /srv/]

**

Essentially - What is the suggested/optimal way to display that js-client info on a js-capable static page?

[Please forgive any naiveté in those questions. I am willing to experiment with new approaches.]

I appreciate your response. It's good to know that this technique is available.

[–] Arsen6331@lemmygrad.ml 1 points 2 years ago

If you want to actually display this information, you will need to use your own UI elements. If you want, you can simply reuse the code for lemmy-ui and modify it for whatever you need.

load more comments (2 replies)
load more comments (2 replies)
load more comments (2 replies)