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: fixed localisation for notes block #943

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
1 change: 1 addition & 0 deletions src/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ export interface ResolverOptions {
fileExtension: string;
outputPath: string;
outputBundlePath: string;
lang: string;
metadata?: MetaDataOptions;
}

Expand Down
11 changes: 6 additions & 5 deletions src/resolvers/md2html.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@ const FileTransformer: Record<string, Function> = {
'.md': MdFileTransformer,
};

const getFileData = async ({fileExtension, metadata, inputPath}: ResolverOptions) => {
const getFileData = async ({fileExtension, metadata, inputPath, lang}: ResolverOptions) => {
const {input, allowCustomResources} = ArgvService.getConfig();

const resolvedPath: string = resolve(input, inputPath);
const content: string = readFileSync(resolvedPath, 'utf8');

const transformFn: Function = FileTransformer[fileExtension];
const {result} = transformFn(content, {path: inputPath, root: input});
const {result} = transformFn(content, {path: inputPath, root: input, lang});

const vars = getVarsPerFile(inputPath);
const updatedMetadata = metadata?.isContributorsEnabled
Expand Down Expand Up @@ -77,14 +77,14 @@ const getFileProps = async (options: ResolverOptions) => {
const {inputPath} = options;
const {lang: configLang, langs: configLangs, analytics, search} = ArgvService.getConfig();

const data = await getFileData(options);

const tocBaseLang = inputPath.replace(/\\/g, '/').split('/')[0];
const tocLang = configLangs?.includes(tocBaseLang as Lang) && tocBaseLang;

const lang = tocLang || configLang || configLangs?.[0] || Lang.RU;
const langs = configLangs?.length ? configLangs : [lang];

const data = await getFileData({...options, lang});

const pathname = inputPath.replace(extname(inputPath), '');

return {
Expand Down Expand Up @@ -217,7 +217,7 @@ export function liquidMd2Html(input: string, vars: Record<string, unknown>, path

function MdFileTransformer(content: string, transformOptions: FileTransformOptions): Output {
const {input, ...options} = ArgvService.getConfig();
const {path: filePath} = transformOptions;
const {path: filePath, lang} = transformOptions;

const plugins = PluginService.getPlugins();
const vars = getVarsPerFile(filePath);
Expand All @@ -230,6 +230,7 @@ function MdFileTransformer(content: string, transformOptions: FileTransformOptio
vars,
root,
path,
lang,
assetsPublicPath: './',
getVarsPerFile: getVarsPerRelativeFile,
getPublicPath,
Expand Down
Loading