Skip to content

Instantly share code, notes, and snippets.

@gavinrozzi
Last active February 25, 2018 06:30
Show Gist options
  • Save gavinrozzi/0ded171e8dbedf4a922e6bb7ffe61b31 to your computer and use it in GitHub Desktop.
Save gavinrozzi/0ded171e8dbedf4a922e6bb7ffe61b31 to your computer and use it in GitHub Desktop.
Using Alaveteli JSON feeds with Hugo data-driven content

Using Alaveteli JSON feeds with Hugo data-driven content

The open source Alaveteli software provides JSON endpoints for feeds of information about freedom information requests sent through an installation. The following snippet of code is a Hugo partial that I created for my personal website to implement this.

To see this code in action, visit this page.

To implement this code, enter the following into a shortcode HTML file on your Hugo-based website. Call the shortcode on any page you wish.

  • Replace 'https://opramachine.com' with the URL of your Alaveteli installation.
  • Replace 'YOUR_USER' with your username from your Alaveteli installation.
<ul>
  {{ $opra_requests := getJSON "https://opramachine.com/feed/user/YOUR_USER.json" }}
  {{ range first 3 $opra_requests }}
   <li><a href="https://opramachine.com/request/{{ .info_request.url_title }}" target="">{{ .info_request.title }}</a><p>Requested from: <a href="https://opramachine.com/body/{{ .public_body.url_name }}" target="">{{ .public_body.name }}</a></p><p>Status: <strong>{{ .display_status }}</strong></p> <p><i>{{ .snippet }}</i></p></li>
  {{ end }}
</ul>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment