astro-d2
Version:
Astro integration and remark plugin to transform D2 Markdown code blocks into diagrams.
18 lines (13 loc) • 527 B
text/typescript
import fs from 'node:fs'
import type { AstroConfig, AstroIntegrationLogger } from 'astro'
const dataStoreFile = 'data-store.json'
export async function clearContentLayerCache(config: AstroConfig, logger: AstroIntegrationLogger) {
const dataStore = getDataStoreFile(config)
if (fs.existsSync(dataStore)) {
logger.info('Invalidating content layer cache…')
await fs.promises.rm(dataStore, { force: true })
}
}
function getDataStoreFile(config: AstroConfig) {
return new URL(dataStoreFile, config.cacheDir)
}