Skip to content
Open
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
18 changes: 14 additions & 4 deletions plugins/docusaurus-plugin-ionic-component-api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,15 @@ module.exports = function (context, options) {
* Generates the markdown files for all components in a given version.
* @param {*} version The version, e.g.: v6
* @param {*} npmTag The npm tag, e.g.: 6 or next
* @param {*} lang The language, e.g.: en or ja
* @param {*} isCurrentVersion Whether or not this is the current version of the docs
*/
const generateMarkdownForVersion = async (version, npmTag, isCurrentVersion) => {
const generateMarkdownForVersion = async (version, npmTag, lang, isCurrentVersion) => {
let COMPONENT_LINK_REGEXP;
const response = await fetch(`https://unpkg.com/@ionic/docs@${npmTag}/core.json`);
const response =
isCurrentVersion && lang === 'ja'
? await fetch(`https://raw.githubusercontent.com/ionic-jp/ionic-docs/main/scripts/data/translated-api.json`)
: await fetch(`https://unpkg.com/@ionic/docs@${npmTag}/core.json`);
const { components } = await response.json();

const names = components.map((component) => component.tag.slice(4));
Expand Down Expand Up @@ -47,7 +51,7 @@ module.exports = function (context, options) {
for (const version of options.versions) {
const npmTag = version.slice(1);

await generateMarkdownForVersion(version, npmTag, false);
await generateMarkdownForVersion(version, npmTag, context.i18n.currentLocale, false);
}

let npmTag = 'latest';
Expand All @@ -57,7 +61,12 @@ module.exports = function (context, options) {
npmTag = currentVersion.path.slice(1);
}
// Latest version
await generateMarkdownForVersion(currentVersion.path || currentVersion.label, npmTag, true);
await generateMarkdownForVersion(
currentVersion.path || currentVersion.label,
npmTag,
context.i18n.currentLocale,
true
);

return data;
},
Expand All @@ -83,6 +92,7 @@ module.exports = function (context, options) {

await Promise.all(promises);
},

configureWebpack(config, isServer, utils) {
/**
* Adds a custom import alias to the webpack configuration, so that the markdown files
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion scripts/i18n.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ set -o nounset
mkdir -p i18n/ja/docusaurus-plugin-content-docs/current/
curl -fsSL https://github.com/ionic-team/ionic-docs/archive/refs/heads/translation/jp.tar.gz |
tar -zxf - -C i18n/ja/docusaurus-plugin-content-docs/current/ --strip-components 2 ionic-docs-translation-jp/docs
node scripts/api-ja.mjs
# node scripts/api-ja.mjs