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 parsing locale from context #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

unconfident
Copy link

@unconfident unconfident commented Nov 6, 2020

Fixes #4 by parsing context locale from page.filePathStem instead of page.url.

This should be considered a breaking change, especially because of regexp.

Also because filePathStem is used required minimum supported 11ty version is 0.9.0+ Nvm, it's already described in peerDependencies as ^0.11.0 so nothing changes here

@@ -4,6 +4,21 @@ const chalk = require('chalk');
const get = require('lodash.get');
const templite = require('templite');

// should match "/en/", "/en-US/", "/en_US/"
const contextLocaleRegex = /^\/([a-z]{2,}(?:[_-][a-z]{2,})?)\//i;
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe maximum length for a segment should be limited to 2 exactly but there's a chance that somebody uses "eng" or "english" as their locale name so I left it as [...]{2,}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Setting front matter variable permalink: false results in a compilation error
1 participant