Skip to content

Commit

Permalink
auto generate table
Browse files Browse the repository at this point in the history
  • Loading branch information
dustin-decker committed Jan 26, 2024
1 parent dfee82e commit 5f10345
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 10 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/hugo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ jobs:
env:
HUGO_VERSION: 0.118.2
steps:
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- run: python generate-table.py
- name: Install Hugo CLI
run: |
wget -O ${{ runner.temp }}/hugo.deb https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_linux-amd64.deb \
Expand Down
11 changes: 11 additions & 0 deletions content/docs/introduction/_table.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
|||
|-|-|-|
[AWS](/docs/tutorials/aws)|[Airbrake](/docs/tutorials/airbrake)|[Atlassian](/docs/tutorials/atlassian)|
[Azure DevOps](/docs/tutorials/azuredevops)|[Azure Function](/docs/tutorials/azurefunctionkey)|[Azure Storage](/docs/tutorials/azure)|
[GCP](/docs/tutorials/gcp)|[GitHub](/docs/tutorials/github)|[GitLab](/docs/tutorials/gitlab)|
[Mailchimp](/docs/tutorials/mailchimp)|[MaxMind](/docs/tutorials/maxmind)|[Microsoft Teams](/docs/tutorials/microsoftteams)|
[MongoDB](/docs/tutorials/mongo)|[NPM](/docs/tutorials/npm)|[Netlify](/docs/tutorials/netlify)|
[Sendbird](/docs/tutorials/sendbird)|[Sendgrid](/docs/tutorials/sendgrid)|[Slack Webhook](/docs/tutorials/slack-webhook)|
[Slack](/docs/tutorials/slack)|[Sourcegraph](/docs/tutorials/sourcegraph)|[Square](/docs/tutorials/square)|
[Stripe](/docs/tutorials/stripe)|[Sumo Logic](/docs/tutorials/sumologic)|[Tailscale](/docs/tutorials/tailscale)|
[Twilio](/docs/tutorials/twilio)|
12 changes: 2 additions & 10 deletions content/docs/introduction/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,8 @@ weight: 1
Welcome to [**How To Rotate**](https://github.com/trufflesecurity/how-to-rotate), an open-source collection of API Key Rotation tutorials. Each tutorial provides step-by-step instructions on how to remediate a leaked API key security vulnerability by (1) Generating a new API key, (2) Replacing the compromised key, and (3) Revoking the compromised key.

To get started, click on a key rotation tutorial for a specific SaaS provider below or [read more about key rotation](/docs/introduction/key-rotation-101).
|||
|-|-|-|
|[Airbrake](/docs/tutorials/airbrake)|[Atlassian](/docs/tutorials/atlassian)|[AWS](/docs/tutorials/aws)|
[Azure Storage](/docs/tutorials/azure)|[Azure DevOps](/docs/tutorials/azuredevops)|[Azure Functions](/docs/tutorials/azurefunctionkey)|
[GCP](/docs/tutorials/gcp)|[GitHub](/docs/tutorials/github)|[GitLab](/docs/tutorials/gitlab)|
[Mailchimp](/docs/tutorials/mailchimp)|[Microsoft Teams](/docs/tutorials/microsoftteams)|[MongoDB](/docs/tutorials/mongo)|
|[Netlify](/docs/tutorials/netlify)|[NPM](/docs/tutorials/npm)|[Sendbird](/docs/tutorials/sendbird)|
[Sendgrid](/docs/tutorials/sendgrid)|[Slack](/docs/tutorials/slack)|[Slack Webhook](/docs/tutorials/slack-webhook)|
[Sourcegraph](/docs/tutorials/sourcegraph)|[Square](/docs/tutorials/square)|[Stripe](/docs/tutorials/stripe)|
[Sumo Logic](/docs/tutorials/sumologic)|[Tailscale](/docs/tutorials/tailscale)|[Twilio](/docs/tutorials/twilio)||

{{% includemarkdown "_table.md" %}}

---

Expand Down
28 changes: 28 additions & 0 deletions generate-table.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/bin/env python3

import os
import re

# Assuming the script is being run from the content/docs/tutorials/ directory
directory = 'content/docs/tutorials'
files = os.listdir(directory)

table = []
for file in sorted(files):
if file.endswith('.md'):
with open(f"{directory}/{file}", 'r') as f:
content = f.read()
title_search = re.search(r"title:\s*(.*)\n", content)
if title_search:
title = title_search.group(1)
if title != "Tutorials":
table.append(f"[{title}](/docs/tutorials/{file.replace('.md', '')})")

table.sort()

output = "|||\n|-|-|-|\n"
for i in range(0, len(table), 3):
output += '|'.join(table[i:i+3]) + '|\n'

with open("content/docs/introduction/_table.md", 'w') as f:
f.write(output)
2 changes: 2 additions & 0 deletions themes/compose/layouts/shortcodes/includemarkdown.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{{ $file := .Get 0 }}
{{ (printf "%s%s" .Page.File.Dir $file) | readFile | replaceRE "^---[\\s\\S]+?---" "" | safeHTML }}

0 comments on commit 5f10345

Please sign in to comment.