Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix links and baseurl #156

Merged
merged 4 commits into from
Jan 20, 2025
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 0 additions & 11 deletions .redirect-template.html

This file was deleted.

37 changes: 23 additions & 14 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ logo: https://static.premai.io/logo.png
repository:
url: https://github.com/premAI-io/state-of-open-source-ai
branch: main

only_build_toc_files: true
exclude_patterns: [.github/*]

html:
baseurl: http://localhost:8000
# Removed baseurl here to avoid conflicts
favicon: assets/favicon.ico
use_edit_page_button: true
use_repository_button: true
Expand All @@ -19,6 +21,7 @@ html:
label: question
repo: premAI-io/state-of-open-source-ai
theme: preferred-color-scheme

parse:
myst_substitutions:
baseurl: http://localhost:8000
Expand Down Expand Up @@ -73,18 +76,17 @@ parse:
<div>
<p>
This book is open source; you can also read &amp; contribute at<br />
<a href="https://github.com/premAI-io/state-of-open-source-ai" target="_blank"><i class="fa-brands fa-github"></i>&nbsp;premAI-io/state-of-open-source-ai</a>.
<a href="https://github.com/premAI-io/state-of-open-source-ai" target="_blank">
<i class="fa-brands fa-github"></i>&nbsp;premAI-io/state-of-open-source-ai
</a>.
</p>
<span class="email-error"></span>
</div>
</div>
</form>
</div>

myst_enable_extensions: # https://myst-parser.readthedocs.io/en/latest/using/syntax-optional.html
# needs myst-parser>=0.19 <- https://github.com/executablebooks/MyST-NB/issues/530
#- attrs_block
#- attrs_inline
myst_enable_extensions:
- deflist
- dollarmath
- html_admonition
Expand All @@ -93,6 +95,7 @@ parse:
- smartquotes
- substitution
- tasklist

sphinx:
extra_extensions:
- sphinx_last_updated_by_git
Expand All @@ -102,12 +105,18 @@ sphinx:
committers: .
bibliography: .
prem_theme: .
recursive_update: true # append to rather than overwrite html_theme_options
recursive_update: true
config:
# Add templates_path so Sphinx can see your _templates/page.html override
templates_path: ["_templates"]

html_theme: prem_theme
html_theme_options:
# (NEW) Provide your base URL here, so you can reference it in page.html as {{ theme_options.baseurl }}
baseurl: https://book.premai.io/state-of-open-source-ai
navigation_with_keys: false
use_download_button: false

myst_heading_anchors: 4
html_js_files:
- [
Expand All @@ -117,7 +126,6 @@ sphinx:
linkcheck_ignore:
- http://localhost:8000
- https://github.com/premAI-io/state-of-open-source-ai/edit/main/.*.md
# GitHub anchors
- https://github.com/\w+/\w+/blob/\w+/.*#L\d+(-L\d+)?
- https://github.com/premAI-io/prem-app#.*
- https://github.com/BlinkDL/RWKV-LM#.*
Expand All @@ -132,7 +140,6 @@ sphinx:
- https://github.com/onnx/onnx-tensorrt#.*
- https://github.com/onnx/tutorials#.*
- https://gist.github.com/veekaybee/be375ab33085102f9027853128dc5f0e#.*
# misc
- https://www.nytimes.com/2016/04/19/technology/google-books-case.html
- https://doi.org/10.2307/2214413
- https://direct.mit.edu/daed/article/151/2/127/110621/Human-Language-Understanding-amp-Reasoning
Expand All @@ -156,22 +163,24 @@ sphinx:
https://mozilla.org/MPL/2.0: https://www.mozilla.org/en-US/MPL/2.0
https://mxnet.apache.org: https://mxnet.apache.org/versions/[\d.]+/.*
https://gpt4all.io: https://gpt4all.io/index.html

html_last_updated_fmt: "%d %b %Y"
jblatex_show_tocs: false
bibtex_reference_style: label
latex_elements:
papersize: a4paper
# requires https://static.premai.io/book/cover.pdf
extrapackages: \usepackage{pdfpages}
maketitle: \includepdf[pages=-]{cover.pdf}
tableofcontents: ""
# fix citations in figure captions (https://github.com/mcmtroffaes/sphinxcontrib-bibtex/issues/276)
preamble: |
\usepackage{etoolbox}
\AtBeginEnvironment{figure}{\pretocmd{\hyperlink}{\protect}{}{}}
bibtex_bibfiles: [references.bib] # citations
latex: # for PDF builds

bibtex_bibfiles: [references.bib]

latex:
latex_documents:
targetname: book.tex

execute:
execute_notebooks: force # re-exec on each build (https://jupyterbook.org/content/execute.html)
execute_notebooks: force
16 changes: 16 additions & 0 deletions _templates/page.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{% extends "!page.html" %}

{% block meta %}
<link rel="canonical" href="{{ theme_options.baseurl }}/{{ pagename }}/">
<script>location="{{ theme_options.baseurl }}/{{ pagename }}/"</script>
<meta http-equiv="refresh" content="0; url={{ theme_options.baseurl }}/{{ pagename }}/">
<meta name="robots" content="noindex">

{{ super() }}
{% endblock meta %}

{% block main %}
<h1>Redirecting…</h1>
<p><a href="{{ theme_options.baseurl }}/{{ pagename }}/">Click here if you are not redirected.</a></p>
{{ super() }}
{% endblock main %}