Skip to content

Commit

Permalink
Merge pull request #214 from fritx/fix-ci
Browse files Browse the repository at this point in the history
Again! Fix the failed CI
  • Loading branch information
tipiirai authored Feb 22, 2024
2 parents 70fa76c + c638ff8 commit 493aa13
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
5 changes: 4 additions & 1 deletion packages/nuekit/src/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import { compileFile as nueCompile} from 'nuejs-core'
import { join, basename } from 'node:path'
import { promises as fs } from 'node:fs'
import { resolve } from 'import-meta-resolve'
import { buildJS } from './builder.js'
import { colors } from './util.js'

Expand Down Expand Up @@ -91,7 +92,9 @@ export async function init({ dist, is_dev, esbuild }) {

async function resolvePath(npm_path) {
const [ npm_name, ...parts ] = npm_path.split('/')
const main = await import.meta.resolve(npm_name)
let main = await resolve(npm_name, `file://${process.cwd()}/`)
main = main.replace(/^file:\/\//, '')
main = process.platform === 'win32' && main.startsWith('/') ? main.slice(1) : main
return main.replace('index.js', parts.join('/'))
}

Expand Down
5 changes: 4 additions & 1 deletion packages/nuekit/src/site.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,10 @@ export async function createSite(args) {
arr.push({ ...meta, ...getParts(path) })
}

arr.sort((a, b) => b.pubDate - a.pubDate)
arr.sort((a, b) => {
const [d1, d2] = [a, b].map(v => v.pubDate || Infinity)
return d2 - d1
})
if (is_bulk) cache[key] = arr
return arr
}
Expand Down
4 changes: 2 additions & 2 deletions packages/nuekit/test/nuekit.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,8 @@ test('content collection', async () => {
expect(actual).toEqual([
{ pubDate: undefined, url: '/blog/first-a.html', title: 'First', dir: 'blog', slug: 'first-a.html' },
{ pubDate: new Date('2020-01-04'), url: '/blog/first-b.html', title: 'Second', dir: 'blog', slug: 'first-b.html' },
{ pubDate: new Date('2020-01-03'), url: '/blog/nested/hey2.html', title: 'Fourth', dir: 'blog/nested', slug: 'hey2.html' },
{ pubDate: new Date('2020-01-02'), url: '/blog/nested/hey1.html', title: 'Third', dir: 'blog/nested', slug: 'hey1.html' },
{ pubDate: new Date('2020-01-03'), url: '/blog/nested/hey2.html', title: 'Fourth', dir: join('blog', 'nested'), slug: 'hey2.html' },
{ pubDate: new Date('2020-01-02'), url: '/blog/nested/hey1.html', title: 'Third', dir: join('blog', 'nested'), slug: 'hey1.html' },
])
})

Expand Down

0 comments on commit 493aa13

Please sign in to comment.