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

feat: add translations #52

Draft
wants to merge 13 commits into
base: main
Choose a base branch
from
Draft
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
1 change: 1 addition & 0 deletions .eleventyignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
_site
node_modules
.DS_Store
.DS_Store
26 changes: 25 additions & 1 deletion eleventy.config.cjs
Original file line number Diff line number Diff line change
@@ -1,12 +1,24 @@
const pluginWebC = require("@11ty/eleventy-plugin-webc");
const bundlerPlugin = require("@11ty/eleventy-plugin-bundle");

const { EleventyI18nPlugin } = require("@11ty/eleventy");

const i18n = require('eleventy-plugin-i18n');
const translations = require('./website/_data/i18n');

module.exports = function(eleventyConfig) {
eleventyConfig.addPlugin(pluginWebC, {
components: "website/_includes/components/*.webc",
});
eleventyConfig.addPlugin(bundlerPlugin);

eleventyConfig.addPlugin(EleventyI18nPlugin, {
// any valid BCP 47-compatible language tag is supported
defaultLanguage: "en", // Required, this site uses "en"
});

eleventyConfig.addPlugin(i18n, translations);

eleventyConfig.setServerPassthroughCopyBehavior("passthrough");
eleventyConfig.addPassthroughCopy({ public: "." });

Expand All @@ -19,6 +31,18 @@ module.exports = function(eleventyConfig) {
notify: false,
ui: false,
ghostMode: false,
callbacks: {
ready: function (err, bs) {
bs.addMiddleware('*', (req, res) => {
if (req.url === '/') {
res.writeHead(302, {
location: '/en/'
});
res.end();
}
});
}
}
});

return {
Expand All @@ -27,4 +51,4 @@ module.exports = function(eleventyConfig) {
},
markdownTemplateEngine: "njk"
};
};
};
13 changes: 13 additions & 0 deletions netlify.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Redirect for end-user’s browser preference override
[[redirects]]
from = "/*"
to = "/es/:splat"
status = 302
conditions = {Language = ["es"]}

# Default
[[redirects]]
from = "/*"
to = "/en/:splat"
status = 200

Loading