-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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(gatsby-source-drupal): drupal langcode as notlangcode #37445
Merged
Merged
Changes from 12 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
207deb5
add ts support
TylerBarnes 4dbfea1
make all files ts
TylerBarnes 05f6405
add new enabled languages plugin option object types/docs
TylerBarnes c94b8f2
add local test scripts
TylerBarnes 29f1656
add normalization code for langCode as def
TylerBarnes c8db51a
use proper joi method name
TylerBarnes 92255b7
change property name
TylerBarnes feb9d76
refactor for TS
TylerBarnes 0d9612c
Merge branch 'master' into feat/drupal-langcode-as-notlangcode
TylerBarnes 6cde5c2
ts changes
TylerBarnes 090b91f
ts fixes
TylerBarnes 249713d
use renamed code in node id
TylerBarnes 789e77e
attempt to disable easlint rules for source-drupal
TylerBarnes File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
{ | ||
"presets": [["babel-preset-gatsby-package"]] | ||
"presets": [["babel-preset-gatsby-package"], "@babel/preset-typescript"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
let options: Options = {} | ||
|
||
type RenamedLangCode = { | ||
langCode: string | ||
as: string | ||
} | ||
|
||
type Options = { | ||
// TODO: type all options | ||
[key: string]: any | ||
} & { | ||
languageConfig?: { | ||
enabledLanguages?: Array<string | RenamedLangCode> | ||
renamedEnabledLanguages?: Array<RenamedLangCode> | ||
defaultLanguage?: string | ||
translatableEntities?: Array<string> | ||
nonTranslatableEntities?: Array<string> | ||
} | ||
} | ||
|
||
const mutateOptions = (options: Options) => { | ||
if (options?.languageConfig?.enabledLanguages?.length) { | ||
// Support renamed language codes in Drupal | ||
options.languageConfig.enabledLanguages.forEach(lang => { | ||
if (typeof lang === `object`) { | ||
// move the as langcode of the complex code to the enabled languages array | ||
options!.languageConfig!.enabledLanguages!.push(lang.as) | ||
// then move the complex lang-code to a different array | ||
options!.languageConfig!.renamedEnabledLanguages ||= [] | ||
options!.languageConfig!.renamedEnabledLanguages.push(lang) | ||
} | ||
}) | ||
|
||
// since we moved all the object enabled languages to a new array, we can remove them from enabledLanguages | ||
options.languageConfig.enabledLanguages = | ||
options.languageConfig.enabledLanguages.filter( | ||
lang => typeof lang === `string` | ||
) | ||
} | ||
|
||
return options | ||
} | ||
|
||
export const setOptions = (newOptions: Options) => { | ||
options = mutateOptions(newOptions) | ||
} | ||
|
||
export const getOptions = () => options |
File renamed without changes.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want to keep this comment in here as a reminder?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wanted to make sure it's obvious the full options aren't typed yet. I can follow up in another PR with types for this