From 3ca573ae101f1883ac934799170980e8da59fa65 Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Sat, 23 Sep 2023 14:34:14 +0100 Subject: [PATCH] refactor --- package.json | 6 ++---- src/getRedirects.ts | 2 +- src/index.ts | 10 +++++++++- src/types.ts | 8 -------- 4 files changed, 12 insertions(+), 14 deletions(-) delete mode 100644 src/types.ts diff --git a/package.json b/package.json index 3892ecc..4d280f5 100644 --- a/package.json +++ b/package.json @@ -5,8 +5,9 @@ "author": "Matthias Kretschmann ", "homepage": "https://kremalicious.com/astro-redirect-from", "license": "MIT", - "main": "dist/index.js", "type": "module", + "main": "dist/index.js", + "types": "./dist/index.d.ts", "scripts": { "build": "tsc", "start": "tsc --watch", @@ -18,9 +19,6 @@ "release": "release-it --non-interactive", "prepublishOnly": "npm run build" }, - "exports": { - ".": "./dist/index.js" - }, "files": [ "dist" ], diff --git a/src/getRedirects.ts b/src/getRedirects.ts index 51f84c3..c2d5358 100644 --- a/src/getRedirects.ts +++ b/src/getRedirects.ts @@ -1,5 +1,5 @@ import path from 'node:path' -import type { Redirects } from './types' +import type { Redirects } from '.' import { getMarkdownFrontmatter } from './utils' export async function getRedirects( diff --git a/src/index.ts b/src/index.ts index e042123..38dcc89 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,9 +1,17 @@ import path from 'node:path' import type { AstroIntegration } from 'astro' -import type { PluginOptions } from './types' import { getMarkdownFiles, getSlugFromFilePath, writeJson } from './utils' import { getRedirects } from './getRedirects' +export type GetSlug = (filePath: string) => string + +export type PluginOptions = { + contentDir?: string + getSlug?: GetSlug +} + +export type Redirects = { [old: string]: string } + export default function astroRedirectFrom({ contentDir = 'src/pages/', getSlug = getSlugFromFilePath diff --git a/src/types.ts b/src/types.ts deleted file mode 100644 index d3bb47b..0000000 --- a/src/types.ts +++ /dev/null @@ -1,8 +0,0 @@ -export type GetSlug = (filePath: string) => string - -export type PluginOptions = { - contentDir?: string - getSlug?: GetSlug -} - -export type Redirects = { [old: string]: string }