fix: use vite import.meta.glob
This commit is contained in:
parent
1c44cb6417
commit
42d13c7e89
1 changed files with 4 additions and 9 deletions
|
@ -3,16 +3,11 @@ import Layout from '../layouts/Layout.astro'
|
||||||
import Footer from '../components/Footer.astro'
|
import Footer from '../components/Footer.astro'
|
||||||
import Posts from '../components/Posts.astro'
|
import Posts from '../components/Posts.astro'
|
||||||
import now from '../constants/now.json'
|
import now from '../constants/now.json'
|
||||||
import { dirname, resolve } from 'pathe'
|
|
||||||
import { readFileSync } from 'node:fs'
|
|
||||||
import { fileURLToPath } from 'node:url'
|
|
||||||
import { mdToHTML } from '../../commands/md-to-html'
|
|
||||||
|
|
||||||
const __filename = fileURLToPath(import.meta.url)
|
const nowGlob = await import.meta.glob('../constants/now.md', { eager: true })
|
||||||
const __dirname = dirname(__filename)
|
const nowPosts = Object.values(nowGlob)
|
||||||
const nowMdPath = resolve(__dirname, '../constants/now.md')
|
const nowHtml = (await nowPosts[0].compiledContent()) ?? ''
|
||||||
const nowContent = readFileSync(nowMdPath, 'utf-8')
|
console.log('>>>', nowHtml)
|
||||||
const nowHtml = await mdToHTML(nowContent)
|
|
||||||
const publishedOn = now.publishedOn === '' ? now.publishDate : now.publishedOn
|
const publishedOn = now.publishedOn === '' ? now.publishDate : now.publishedOn
|
||||||
|
|
||||||
const posts = await Astro.glob('./now/and-then/posts/*.astro')
|
const posts = await Astro.glob('./now/and-then/posts/*.astro')
|
||||||
|
|
Loading…
Reference in a new issue