Skip to content

Commit 09ffc44

Browse files
author
Amaan
authored
feat(ui): show <owner>/<repo> in page title (#303)
* Added dynamic page titles, the title now contains the repo url
1 parent e5fadce commit 09ffc44

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

src/server/query_processor.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,9 @@ async def process_query(
9191
if not query.url:
9292
raise ValueError("The 'url' parameter is required.")
9393

94+
# Sets the "<user>/<repo>" for the page title
95+
context["short_repo_url"] = f"{query.user_name}/{query.repo_name}"
96+
9497
clone_config = query.extract_clone_config()
9598
await clone_repo(clone_config, token=token)
9699
summary, tree, content = ingest_query(query)

src/server/templates/base.jinja

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,13 @@
3333
<meta property="og:url" content="{{ request.url }}">
3434
<meta property="og:image" content="/static/og-image.png">
3535
<title>
36-
{% block title %}Gitingest{% endblock %}
36+
{% block title %}
37+
{% if short_repo_url %}
38+
Gitingest - {{ short_repo_url }}
39+
{% else %}
40+
Gitingest
41+
{% endif %}
42+
{% endblock %}
3743
</title>
3844
<script src="https://cdn.tailwindcss.com"></script>
3945
<script src="/static/js/utils.js"></script>

src/static/js/utils.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,9 @@ function handleSubmit(event, showLoading = false) {
109109
starsElement.textContent = starCount;
110110
}
111111

112+
// Set dynamic title that includes the repo name.
113+
document.title = document.body.getElementsByTagName('title')[0].textContent;
114+
112115
// Scroll to results if they exist
113116
const resultsSection = document.querySelector('[data-results]');
114117
if (resultsSection) {

0 commit comments

Comments
 (0)