Files
zhdiary/packages/nuxt/scripts/dir.ts
T
2020-12-15 16:27:52 +07:00

25 lines
666 B
TypeScript

import fs from 'fs'
import path from 'path'
import dotenv from 'dotenv'
dotenv.config({ path: '../../.env' })
dotenv.config()
export const CONTENT_PATH = path.resolve(
process.env.CONTENT_PATH ||
(fs.existsSync('../../_posts') ? '../..' : 'content')
)
export const srcPostPath = (...ps: string[]): string =>
path.join(CONTENT_PATH, '_posts', ...ps)
export const srcMediaPath = (...ps: string[]): string =>
path.join(CONTENT_PATH, '_media', ...ps)
export const builtPath = (...ps: string[]): string =>
path.join(__dirname, '../built', ...ps)
export const dstMediaPath = (...ps: string[]): string =>
path.join(__dirname, '../public/media', ...ps)