Skip to content

Commit

Permalink
fixing origin url bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
justdaksh committed Nov 20, 2024
1 parent b0edb15 commit 166692e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/nuclia_sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Nuclia Sync

on:
push:

jobs:
sync:
runs-on: ubuntu-latest
Expand All @@ -23,6 +23,10 @@ jobs:
pip install -q -r requirements.txt -c constraints.txt
pip freeze
- name: Building html
run: |
make html
- name: Run Nuclia Sync
env:
DEPLOY_NUCLIA_URL: ${{secrets.DEPLOY_NUCLIA_URL}}
Expand Down
19 changes: 18 additions & 1 deletion upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,23 @@ def normalize_path(path):
def create_url(origin_url, url_path):
return f"{origin_url.rstrip('/')}/{url_path}"

def transform_path_to_url(path, base_url):
"""
Transform a file path to a URL, replacing underscores with hyphens in folder names only.
Args:
path (str): The path to the HTML file.
base_url (str): The base URL.
Returns:
str: The transformed URL.
"""
transformed_path = '/'.join(
part.replace('_', '-') if '.html' not in part else part
for part in path.replace('./_build/html/', '').split('/')
)
return f"{base_url.rstrip('/')}/{transformed_path}"


def generate_breadcrumb_for_path(path):
"""
Expand Down Expand Up @@ -143,7 +160,7 @@ def upload_doc(path):
"""
slug = get_slug(path)
title, article = extract_content(path)
origin_url = f"{PUBLIC_URL}{path.replace('./_build/html/', '')}" # noqa
origin_url = transform_path_to_url(path, PUBLIC_URL)
sdk.NucliaUpload().text (
path=path,
format="HTML",
Expand Down

0 comments on commit 166692e

Please sign in to comment.