From 1dbebaec61202fa97bfe3e86a9ca6b535d5e3749 Mon Sep 17 00:00:00 2001 From: techfg Date: Sun, 21 Apr 2024 02:55:01 -0700 Subject: [PATCH 1/3] chore: update tests --- src/index.test.mjs | 4 ++-- src/options.test.mjs | 14 +++++++------- src/utils.test.mjs | 8 ++++---- 3 files changed, 13 insertions(+), 13 deletions(-) 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.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.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"); From 975a7cbea9f6d0e213d35b781be2ad7a9f915867 Mon Sep 17 00:00:00 2001 From: techfg Date: Sun, 21 Apr 2024 03:12:21 -0700 Subject: [PATCH 2/3] fix: rename basePath to base --- docs/README.md | 2 +- docs/interfaces/Options.md | 12 +++++++----- src/index.mjs | 2 +- src/options.mjs | 8 ++++---- src/utils.mjs | 8 ++++---- 5 files changed, 17 insertions(+), 15 deletions(-) diff --git a/docs/README.md b/docs/README.md index c8ca625..ee50d74 100644 --- a/docs/README.md +++ b/docs/README.md @@ -37,4 +37,4 @@ Rehype plugin for Astro to add support for transforming relative links in MD and #### Defined in -[src/index.mjs:33](https://github.com/vernak2539/astro-rehype-relative-markdown-links/blob/main/src/index.mjs#L33) +[src/index.mjs:34](https://github.com/vernak2539/astro-rehype-relative-markdown-links/blob/main/src/index.mjs#L34) diff --git a/docs/interfaces/Options.md b/docs/interfaces/Options.md index dce7876..c85aadd 100644 --- a/docs/interfaces/Options.md +++ b/docs/interfaces/Options.md @@ -12,20 +12,20 @@ ### Properties -- [basePath](Options.md#basepath) +- [base](Options.md#base) - [collectionPathMode](Options.md#collectionpathmode) - [contentPath](Options.md#contentpath) - [trailingSlash](Options.md#trailingslash) ## Properties -### basePath +### base -• `Optional` **basePath**: `string` +• `Optional` **base**: `string` **`Name`** -basePath +base **`Reference`** @@ -35,6 +35,8 @@ https://docs.astro.build/en/reference/configuration-reference/#base 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 @@ -45,7 +47,7 @@ In the example below, `astro dev` will start your server at `/docs`. #### Inherited from -z.input.basePath +z.input.base #### Defined in 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/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/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) { From 4cccc4069e58d0341bf1d2dd3d74f59290b2f765 Mon Sep 17 00:00:00 2001 From: Alex Vernacchia Date: Thu, 16 May 2024 15:19:48 +0100 Subject: [PATCH 3/3] reset docs to master --- docs/README.md | 2 +- docs/interfaces/Options.md | 12 +++++------- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/docs/README.md b/docs/README.md index ee50d74..c8ca625 100644 --- a/docs/README.md +++ b/docs/README.md @@ -37,4 +37,4 @@ Rehype plugin for Astro to add support for transforming relative links in MD and #### Defined in -[src/index.mjs:34](https://github.com/vernak2539/astro-rehype-relative-markdown-links/blob/main/src/index.mjs#L34) +[src/index.mjs:33](https://github.com/vernak2539/astro-rehype-relative-markdown-links/blob/main/src/index.mjs#L33) diff --git a/docs/interfaces/Options.md b/docs/interfaces/Options.md index c85aadd..dce7876 100644 --- a/docs/interfaces/Options.md +++ b/docs/interfaces/Options.md @@ -12,20 +12,20 @@ ### Properties -- [base](Options.md#base) +- [basePath](Options.md#basepath) - [collectionPathMode](Options.md#collectionpathmode) - [contentPath](Options.md#contentpath) - [trailingSlash](Options.md#trailingslash) ## Properties -### base +### basePath -• `Optional` **base**: `string` +• `Optional` **basePath**: `string` **`Name`** -base +basePath **`Reference`** @@ -35,8 +35,6 @@ https://docs.astro.build/en/reference/configuration-reference/#base 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 @@ -47,7 +45,7 @@ In the example below, `astro dev` will start your server at `/docs`. #### Inherited from -z.input.base +z.input.basePath #### Defined in