Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 0 additions & 4 deletions .github/workflows/build-production-site.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -218,10 +218,6 @@ jobs:
cd public
cp sitemap.xml ${{ vars.DUPE_SITEMAP_NAME }}

SED_ESCAPED_URL=$(echo ${{ secrets.DOCS_WEBSITE_URL }} | sed 's|\.|\\\.|g')
sed -i "s|<loc>$SED_ESCAPED_URL\([a-z0-9\/-]*\)/</loc>|<loc>https://akamai.com/cloud/\1</loc>|g" ${{ vars.DUPE_SITEMAP_NAME }}
sed -i "s|<loc>$SED_ESCAPED_URL</loc>|<loc>https://akamai.com/cloud</loc>|g" ${{ vars.DUPE_SITEMAP_NAME }}

# Make a tarball of the site, because it will upload much, much quicker
# than the uncompressed rendered site. The commit for this workflow run
# is encoded in the name of the tarball.
Expand Down
4 changes: 0 additions & 4 deletions .github/workflows/build-staging-site.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -225,10 +225,6 @@ jobs:
cd public
cp sitemap.xml ${{ vars.DUPE_SITEMAP_NAME }}

SED_ESCAPED_URL=$(echo ${{ secrets.DOCS_WEBSITE_URL }} | sed 's|\.|\\\.|g')
sed -i "s|<loc>$SED_ESCAPED_URL\([a-z0-9\/-]*\)/</loc>|<loc>https://akamai.com/cloud/\1</loc>|g" ${{ vars.DUPE_SITEMAP_NAME }}
sed -i "s|<loc>$SED_ESCAPED_URL</loc>|<loc>https://akamai.com/cloud</loc>|g" ${{ vars.DUPE_SITEMAP_NAME }}

# Make a tarball of the site, because it will upload much, much quicker
# than the uncompressed rendered site. The commit for this workflow run
# is encoded in the name of the tarball.
Expand Down
4 changes: 0 additions & 4 deletions .github/workflows/build-testing-site.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -226,10 +226,6 @@ jobs:
cd public
cp sitemap.xml ${{ vars.DUPE_SITEMAP_NAME }}

SED_ESCAPED_URL=$(echo ${{ secrets.DOCS_WEBSITE_URL }} | sed 's|\.|\\\.|g')
sed -i "s|<loc>$SED_ESCAPED_URL\([a-z0-9\/-]*\)/</loc>|<loc>https://akamai.com/cloud/\1</loc>|g" ${{ vars.DUPE_SITEMAP_NAME }}
sed -i "s|<loc>$SED_ESCAPED_URL</loc>|<loc>https://akamai.com/cloud</loc>|g" ${{ vars.DUPE_SITEMAP_NAME }}

# Make a tarball of the site, because it will upload much, much quicker
# than the uncompressed rendered site. The commit for this workflow run
# is encoded in the name of the tarball.
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,5 @@ hugo_stats.json
.hugo_build.lock
redirects.conf
scripts/duplicates.csv
scripts/.product_link_cache.json
algolia_out/

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion _vendor/modules.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# github.com/linode/linode-docs-theme v0.0.0-20260527191020-967a1fed9ff8
# github.com/linode/linode-docs-theme v0.0.0-20260616154148-26d1400a2a41
# github.com/gohugoio/hugo-mod-jslibs-dist/alpinejs/v3 v3.21300.20800
# github.com/gohugoio/hugo-mod-jslibs/turbo/v8 v8.20000.20400
# github.com/hotwired/turbo v8.0.4+incompatible
Expand Down
81 changes: 81 additions & 0 deletions apply-redirects.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
#!/usr/bin/env python3
"""Replace relative links in the markdown library with their techdocs.akamai.com
replacements, as defined in cloud-techdocs-redirects.csv.

The CSV has two columns: the relative link to find, and the replacement link.
Links in the markdown appear as Markdown inline link targets, i.e. wrapped in
parentheses: ``(link)``. Matching on ``(link)`` keeps replacements exact and
avoids prefix collisions (e.g. ``/foo/`` vs ``/foo/bar/``).

Usage:
python3 apply-redirects.py [--dry-run]
"""

import argparse
import csv
import sys
from pathlib import Path

REPO_ROOT = Path(__file__).resolve().parent
CSV_PATH = REPO_ROOT / "cloud-techdocs-redirects.csv"
DOCS_DIR = REPO_ROOT / "docs"


def load_redirects(csv_path):
"""Return a list of (old, new) link pairs from the CSV."""
pairs = []
with open(csv_path, newline="", encoding="utf-8") as f:
for row in csv.reader(f):
if not row or not row[0].strip():
continue
if len(row) < 2:
print(f"Skipping malformed row: {row!r}", file=sys.stderr)
continue
old, new = row[0].strip(), row[1].strip()
pairs.append((old, new))
return pairs


def main():
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument(
"--dry-run",
action="store_true",
help="Report what would change without writing files.",
)
args = parser.parse_args()

redirects = load_redirects(CSV_PATH)
# Map the parenthesized link-target forms.
replacements = [(f"({old})", f"({new})", old) for old, new in redirects]

total_replacements = 0
changed_files = 0

for md_file in sorted(DOCS_DIR.rglob("*.md")):
text = md_file.read_text(encoding="utf-8")
original = text
file_count = 0

for old_token, new_token, old_link in replacements:
n = text.count(old_token)
if n:
text = text.replace(old_token, new_token)
file_count += n
rel = md_file.relative_to(REPO_ROOT)
print(f" {rel}: {n}x {old_link}")

if text != original:
changed_files += 1
total_replacements += file_count
if not args.dry_run:
md_file.write_text(text, encoding="utf-8")

action = "Would replace" if args.dry_run else "Replaced"
print(
f"\n{action} {total_replacements} link(s) across {changed_files} file(s)."
)


if __name__ == "__main__":
main()
Loading
Loading