mirror of
https://github.com/kremalicious/astro-redirect-from.git
synced 2024-11-24 11:01:42 +01:00
refactor
This commit is contained in:
parent
93e72936e4
commit
3ca573ae10
@ -5,8 +5,9 @@
|
|||||||
"author": "Matthias Kretschmann <m@kretschmann.io>",
|
"author": "Matthias Kretschmann <m@kretschmann.io>",
|
||||||
"homepage": "https://kremalicious.com/astro-redirect-from",
|
"homepage": "https://kremalicious.com/astro-redirect-from",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"main": "dist/index.js",
|
|
||||||
"type": "module",
|
"type": "module",
|
||||||
|
"main": "dist/index.js",
|
||||||
|
"types": "./dist/index.d.ts",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "tsc",
|
"build": "tsc",
|
||||||
"start": "tsc --watch",
|
"start": "tsc --watch",
|
||||||
@ -18,9 +19,6 @@
|
|||||||
"release": "release-it --non-interactive",
|
"release": "release-it --non-interactive",
|
||||||
"prepublishOnly": "npm run build"
|
"prepublishOnly": "npm run build"
|
||||||
},
|
},
|
||||||
"exports": {
|
|
||||||
".": "./dist/index.js"
|
|
||||||
},
|
|
||||||
"files": [
|
"files": [
|
||||||
"dist"
|
"dist"
|
||||||
],
|
],
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import path from 'node:path'
|
import path from 'node:path'
|
||||||
import type { Redirects } from './types'
|
import type { Redirects } from '.'
|
||||||
import { getMarkdownFrontmatter } from './utils'
|
import { getMarkdownFrontmatter } from './utils'
|
||||||
|
|
||||||
export async function getRedirects(
|
export async function getRedirects(
|
||||||
|
10
src/index.ts
10
src/index.ts
@ -1,9 +1,17 @@
|
|||||||
import path from 'node:path'
|
import path from 'node:path'
|
||||||
import type { AstroIntegration } from 'astro'
|
import type { AstroIntegration } from 'astro'
|
||||||
import type { PluginOptions } from './types'
|
|
||||||
import { getMarkdownFiles, getSlugFromFilePath, writeJson } from './utils'
|
import { getMarkdownFiles, getSlugFromFilePath, writeJson } from './utils'
|
||||||
import { getRedirects } from './getRedirects'
|
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({
|
export default function astroRedirectFrom({
|
||||||
contentDir = 'src/pages/',
|
contentDir = 'src/pages/',
|
||||||
getSlug = getSlugFromFilePath
|
getSlug = getSlugFromFilePath
|
||||||
|
@ -1,8 +0,0 @@
|
|||||||
export type GetSlug = (filePath: string) => string
|
|
||||||
|
|
||||||
export type PluginOptions = {
|
|
||||||
contentDir?: string
|
|
||||||
getSlug?: GetSlug
|
|
||||||
}
|
|
||||||
|
|
||||||
export type Redirects = { [old: string]: string }
|
|
Loading…
Reference in New Issue
Block a user