Skip to content

Commit

Permalink
fix: get astro pages' full paths using fdir's withFullPaths instead o…
Browse files Browse the repository at this point in the history
…f withRelativePaths

fixes #135
  • Loading branch information
yassinedoghri committed Mar 9, 2023
1 parent 9288efe commit 92a5178
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
12 changes: 7 additions & 5 deletions src/cli/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import fs from "fs";
import { resolve } from "pathe";
import { AstroI18nextConfig } from "../types";
import {
getAstroPagesPath,
getAstroPagesFullPaths,
createFiles,
FileToGenerate,
generateLocalizedFrontmatter,
Expand Down Expand Up @@ -30,12 +30,14 @@ export const generate = (
const start = process.hrtime();

// default locale page paths
const astroPagesPaths = showDefaultLocale
? getAstroPagesPath(inputPath, defaultLocale, locales)
: getAstroPagesPath(inputPath, undefined, locales);
const astroPagesFullPaths = showDefaultLocale
? getAstroPagesFullPaths(inputPath, defaultLocale, locales)
: getAstroPagesFullPaths(inputPath, undefined, locales);

const filesToGenerate: FileToGenerate[] = [];
astroPagesPaths.forEach(async function (astroFilePath: string) {
astroPagesFullPaths.forEach(async function (astroFileFullPath: string) {
const astroFilePath = astroFileFullPath.replace(resolve(inputPath), "");

const inputFilePath = showDefaultLocale
? [inputPath, defaultLocale, astroFilePath].join("/")
: [inputPath, astroFilePath].join("/");
Expand Down
4 changes: 2 additions & 2 deletions src/cli/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ export const generateLocalizedFrontmatter = (
* @param childDirToCrawl will make the function crawl inside the given
* `childDirToCrawl` (doesn't take paths, only dirname).
*/
export const getAstroPagesPath = (
export const getAstroPagesFullPaths = (
pagesDirectoryPath: string,
childDirToCrawl: AstroI18nextConfig["defaultLocale"] | undefined = undefined,
locales: AstroI18nextConfig["locales"] = []
Expand All @@ -131,7 +131,7 @@ export const getAstroPagesPath = (
(filepath) => !isFileHidden(filepath) && filepath.endsWith(".astro")
)
.exclude((dirName) => locales.includes(dirName))
.withRelativePaths();
.withFullPaths();

return childDirToCrawl
? (api
Expand Down

0 comments on commit 92a5178

Please sign in to comment.