Skip to content
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
4 changes: 4 additions & 0 deletions config/_default/config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
baseURL: 'https://innersourcecommons.org/'
defaultContentLanguage: 'en'
defaultContentLanguageInSubdir: false
params:
# Redirect to default language if translation is missing
redirectMissingTranslations: true

title: InnerSource Commons

pluralizeListTitles: false
Expand Down
25 changes: 25 additions & 0 deletions layouts/_default/baseof.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,29 @@
{{- partial "footer.html" . -}}
</body>

{{ if not .Content }}
{{ if .Site.Params.redirectMissingTranslations }}
<script>
const path = window.location.pathname;
const pathParts = path.split('/');
const currentLang = pathParts[1];

// If not English, try English version
if (currentLang !== 'en' && currentLang.length === 2) {
const englishPath = path.replace(`/${currentLang}/`, '/en/');

// Check if English version exists (you'd need to implement this check)
fetch(englishPath)
.then(response => {
if (response.ok) {
window.location.href = englishPath;
}
})
.catch(() => {
// Show 404 page
});
}
</script>
{{ end }}
{{ end }}
</html>
Loading