Skip to content

Commit

Permalink
Fix route
Browse files Browse the repository at this point in the history
  • Loading branch information
agahkarakuzu committed Sep 8, 2024
1 parent c8be99e commit 1744e13
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
4 changes: 2 additions & 2 deletions api/myst_page.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{{ frontend_data.content.title }}</title>
<title>{{ frontend_data.content.title if frontend_data.content.title else 'MyST Page' }}</title>
<link rel="stylesheet" href="{{ url_for('serve_theme', filename='styles.css') }}">
<script src="{{ url_for('serve_theme', filename='index.js') }}"></script>
</head>
<body>
<div id="myst-article-root"></div>
<script>
const frontendData = {{ frontend_data | safe }};
const frontendData = {{ frontend_data | tojson | safe }};
window.addEventListener('DOMContentLoaded', (event) => {
if (window.renderMystContent) {
window.renderMystContent(document.getElementById('myst-article-root'), frontendData);
Expand Down
16 changes: 13 additions & 3 deletions api/neurolibre_preview_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,8 +250,18 @@ def render_page(username, repo, commit, page_path=''):
app.logger.error(f"Invalid JSON in config file: {config_path}")
return jsonify({"error": "Invalid config file"}), 500

if not page_path:
page_path = config['nav'][0]['url']
if not page_path or page_path == 'index.html':
page_path = config['index']

# if not page_path:
# if 'nav' not in config or not config['nav']:
# app.logger.error("Nav not found in config or is empty")
# return jsonify({"error": "Navigation not found"}), 500
# try:
# page_path = config['nav'][0]['url']
# except (KeyError, IndexError):
# app.logger.error("Unable to find first nav item URL")
# return jsonify({"error": "Navigation structure invalid"}), 500

json_path = os.path.join(user_build_dir, 'content', f"{page_path}.json")
app.logger.debug(f"Content JSON path: {json_path}")
Expand Down Expand Up @@ -279,7 +289,7 @@ def render_page(username, repo, commit, page_path=''):
username=username,
repo=repo,
commit=commit,
frontend_data=json.dumps(frontend_data))
frontend_data=frontend_data)

@app.route('/myst/<username>/<repo>/<commit>/public/<path:filename>')
def serve_public(username, repo, commit, filename):
Expand Down

0 comments on commit 1744e13

Please sign in to comment.