Skip to content

Fix redirects #283

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

Merged
merged 17 commits into from
May 30, 2023
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,6 @@ jobs:
env:
BING_TOKEN: ${{ secrets.BING_TOKEN }}

- name: Add sitemap.xml to root directory
run: mv build/html/en/sitemap.xml build/html

- name: Deploy documentation sphinx
uses: JamesIves/[email protected]
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
Expand Down
22 changes: 11 additions & 11 deletions build.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
"""


def build_docs(language: str) -> None:
def build_docs(language: str, isroot: bool) -> None:
"""
Build the documentation for a single language.

Expand All @@ -78,7 +78,7 @@ def build_docs(language: str) -> None:
"-b",
"dirhtml",
str(srcdir),
str(outdir / language),
str(outdir) if isroot else str(outdir / language),
f"-Dlanguage={language}",
],
cwd=root,
Expand All @@ -97,14 +97,14 @@ def build_redirects(redirects: Dict[str, str], language: str) -> None:
language : str
The language to build the redirects for.
"""

for source, target in redirects.items():
source_path = outdir / source
redirect = template.format(target.format(language))
if not source_path.parent.exists():
source_path.parent.mkdir(parents=True)
with open(source_path, "w", encoding="utf-8") as fp:
fp.write(redirect)
pass
# for source, target in redirects.items():
# source_path = outdir / source
# redirect = template.format(target.format(language))
# if not source_path.parent.exists():
# source_path.parent.mkdir(parents=True)
# with open(source_path, "w", encoding="utf-8") as fp:
# fp.write(redirect)


def build_all(redirects: Dict[str, str], languages: List[str]) -> None:
Expand All @@ -120,7 +120,7 @@ def build_all(redirects: Dict[str, str], languages: List[str]) -> None:
"""

for language in languages:
build_docs(language)
build_docs(language, language == languages[0])

build_redirects(redirects, languages[0])

Expand Down
29 changes: 16 additions & 13 deletions source/_templates/version-switcher.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,62 +48,62 @@
{
name: "English",
version: "en",
url: "../en/",
url: "",
},
{
name: "bn",
version: "bn",
url: "../bn/",
url: "bn/",
},
{
name: "cs",
version: "cs",
url: "../cs/",
url: "cs/",
},
{
name: "Deutsch",
version: "de",
url: "../de/",
url: "de/",
},
{
name: "Español",
version: "es",
url: "../es/",
url: "es/",
},
{
name: "Français",
version: "fr",
url: "../fr/",
url: "fr/",
},
{
name: "ja",
version: "ja",
url: "../ja/",
url: "ja/",
},
{
name: "Nederlands",
version: "nl",
url: "../nl/",
url: "nl/",
},
{
name: "pl",
version: "pl",
url: "../pl/",
url: "pl/",
},
{
name: "Português",
version: "pt",
url: "../pt/",
url: "pt/",
},
{
name: "Русский",
version: "ru",
url: "../ru/",
url: "ru/",
},
{
name: "简体中文",
version: "zh_CN",
url: "../zh_CN/",
url: "zh_CN/",
},
];
// console.log(data);
Expand All @@ -116,10 +116,13 @@
const node = document.createElement("a");
node.setAttribute("class", "list-group-item list-group-item-action py-1");
node.textContent = `${entry.name}`;


node.setAttribute(
"href",
`${indexFilePath}${entry.url}${currentFilePath}`,
`https://fortran-lang.org/${entry.url}${currentFilePath}`,
);

// on click, AJAX calls will check if the linked page exists before
// trying to redirect, and if not, will redirect to the homepage
// for that version of the docs.
Expand Down