jlelseโ€™s Blog 27 Oct 2021 10:30

Awesome! Do you still use Hugo as underlying static site builder? And how do you integrate the admin bar into your site? Some JS magic?

Do you still use Hugo as underlying static site builder?

Yes, I do. I still find it fast enough and it’s not introducing extra complexity right now.

And how do you integrate the admin bar into your site? Some JS magic?

No JS! I thought about that at first, but then I thought: well, I know when the user is logged in so it shouldn’t be that hard.

What I did was to wrap the http.ResponseWriter when the response file is HTML and the user is logged in, and inject a <div> with the admin bar before all the content. It’s technically not valid HTML - I think - because it goes outside of <html>, but no browser complains about it and works perfectly.

I’m not sure if it’s the most correct strategy, but it’s working for now! :D

Interactions (0)

Orโ€ฆ