DEV Community

Discussion on: Static Portfolio with dynamic content

 
rpalo profile image
Ryan Palo

Sorry I just thought of another idea. You might be able to scrape Twitter from the front end, bypassing the api and avoiding the rebuild step at all, but not sure.

Thread Thread
 
niklasfyi profile image
Niklas Resch

I will have a look at your Fanbot project.

I just got it working with Hugo and gohugo.io/templates/data-templates.... You just have to disable caching and rebuild Hugo everytime.

Now I just need to use a cronjob or some other script to trigger the rebuild.

How do you want to do it with Twitter and the front end?

Thread Thread
 
rpalo profile image
Ryan Palo

Something similar to this? Essentially fetch your Mastodon feed from the client side and dynamically show your tweets?

Personally I like the server side option better, but that’s just me. It’s nice because it gives you a handy backup of all your data in one place too!

Thread Thread
 
niklasfyi profile image
Niklas Resch

This will just print the content of my last public toot from Mastodon.

<ul>
  {{ $urlPre := "https://chaos.social" }}
  {{ $gistJ := getJSON $urlPre "/api/v1/accounts/166987/statuses?limit=1" }}
    {{ .content | plainify }}
</ul>

I don't need any backup. I just want to show the last toot and link to it. So I think that would be simple enough.

When the site is complete I will check how long the hugo build will run on my uberspace.de host and then I can think about the frequency of building. Maybe every 30 min.

Thread Thread
 
rpalo profile image
Ryan Palo

The nice thing about backup is you can check to see if there have been any tweets, and only build if that is the case. If you’re averse to deploying super frequently, maybe that’s a good idea. Otherwise, what you have sounds great! 😁