diff --git a/src/index.mjs b/src/index.mjs index b6fb16e..bc4f308 100644 --- a/src/index.mjs +++ b/src/index.mjs @@ -155,7 +155,7 @@ function astroRehypeRelativeMarkdownLinks(opts = {}) { // Debugging debug("--------------------------------------"); - debug("BasePath : %s", options.basePath); + debug("Base path : %s", options.base); debug("ContentDir : %s", contentDir); debug("CollectionPathMode : %s", collectionPathMode); debug("TrailingSlashMode : %s", trailingSlashMode); diff --git a/src/index.test.mjs b/src/index.test.mjs index c6c6f71..7acb3d9 100644 --- a/src/index.test.mjs +++ b/src/index.test.mjs @@ -401,14 +401,14 @@ describe("astroRehypeRelativeMarkdownLinks", () => { await runValidationTest(context, { contentPath: "src" })); }); - describe("config option - basePath", () => { + describe("config option - base", () => { test("should prefix base to output on file paths that exist", async () => { const input = 'foo'; const { value: actual } = await rehype() .use(testSetupRehype) .use(astroRehypeRelativeMarkdownLinks, { contentPath: "src", - basePath: "/testBase", + base: "/testBase", }) .process(input); diff --git a/src/options.mjs b/src/options.mjs index f265615..ed8cc33 100644 --- a/src/options.mjs +++ b/src/options.mjs @@ -34,20 +34,20 @@ export const OptionsSchema = z.object({ .union([z.literal("subdirectory"), z.literal("root")]) .default("subdirectory"), /** - * @name basePath + * @name base * @reference https://docs.astro.build/en/reference/configuration-reference/#base * @description * The base path to deploy to. Astro will use this path as the root for your pages and assets both in development and in production build. - * + * @example * In the example below, `astro dev` will start your server at `/docs`. - * + * * ```js * { * base: '/docs' * } * ``` */ - basePath: z.string().optional(), + base: z.string().optional(), /** * @name trailingSlash * @default `ignore` diff --git a/src/options.test.mjs b/src/options.test.mjs index d5717b2..b36fdf7 100644 --- a/src/options.test.mjs +++ b/src/options.test.mjs @@ -130,17 +130,17 @@ describe("validateOptions", () => { }); }); - describe("basePath", () => { - test("should have expected basePath default", () => { - expectsValidOption({}, "basePath", defaultOptions.basePath); + describe("base", () => { + test("should have expected base default", () => { + expectsValidOption({}, "base", defaultOptions.base); }); - test("should be basePath value specified when provided", () => { - expectsValidOption({ basePath: "foobar" }, "basePath", "foobar"); + test("should be base value specified when provided", () => { + expectsValidOption({ base: "foobar" }, "base", "foobar"); }); - test("should fail when baesPath not a string", () => { - expectsZodError({ basePath: {} }, "invalid_type"); + test("should fail when base not a string", () => { + expectsZodError({ base: {} }, "invalid_type"); }); }); diff --git a/src/utils.mjs b/src/utils.mjs index 17aa21e..0c0a918 100644 --- a/src/utils.mjs +++ b/src/utils.mjs @@ -103,15 +103,15 @@ export const splitPathFromQueryAndFragment = (url) => { /** @type {import('./utils.d.ts').NormaliseAstroOutputPath} */ export const normaliseAstroOutputPath = (initialPath, options = {}) => { const buildPath = () => { - if (!options.basePath) { + if (!options.base) { return initialPath; } - if (options.basePath.startsWith(URL_PATH_SEPARATOR)) { - return path.join(options.basePath, initialPath); + if (options.base.startsWith(URL_PATH_SEPARATOR)) { + return path.join(options.base, initialPath); } - return URL_PATH_SEPARATOR + path.join(options.basePath, initialPath); + return URL_PATH_SEPARATOR + path.join(options.base, initialPath); }; if (!initialPath) { diff --git a/src/utils.test.mjs b/src/utils.test.mjs index 78aaf98..9214a1e 100644 --- a/src/utils.test.mjs +++ b/src/utils.test.mjs @@ -206,7 +206,7 @@ describe("normaliseAstroOutputPath", () => { describe("prefix base to path", () => { test("base with no slashes", () => { const actual = normaliseAstroOutputPath("/foo-testing-test", { - basePath: "base", + base: "base", }); assert.equal(actual, "/base/foo-testing-test"); @@ -214,7 +214,7 @@ describe("normaliseAstroOutputPath", () => { test("base with slash at start", () => { const actual = normaliseAstroOutputPath("/foo-testing-test", { - basePath: "/base", + base: "/base", }); assert.equal(actual, "/base/foo-testing-test"); @@ -222,7 +222,7 @@ describe("normaliseAstroOutputPath", () => { test("base with slash at end", () => { const actual = normaliseAstroOutputPath("/foo-testing-test", { - basePath: "base/", + base: "base/", }); assert.equal(actual, "/base/foo-testing-test"); @@ -230,7 +230,7 @@ describe("normaliseAstroOutputPath", () => { test("base with slash at start and end", () => { const actual = normaliseAstroOutputPath("/foo-testing-test", { - basePath: "/base/", + base: "/base/", }); assert.equal(actual, "/base/foo-testing-test");