Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@gulluth/oddments",
"version": "0.98.0",
"version": "0.98.1",
"private": false,
"type": "module",
"bin": {
Expand Down
14 changes: 13 additions & 1 deletion scripts/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ function cleanup() {
}
}

function cleanCache() {
for (const item of ['build', '.svelte-kit', ...EPHEMERAL]) {
rmSync(join(cwd, item), { recursive: true, force: true })
}
}

function resolveBin(name) {
for (const base of [cwd, packageRoot]) {
const p = join(base, 'node_modules', '.bin', name)
Expand Down Expand Up @@ -79,6 +85,12 @@ switch (command) {
break
}

case 'clean': {
cleanCache()
console.log('Removed Oddments build cache.')
break
}

case 'init': {
const templateDir = join(packageRoot, 'starter-template')

Expand Down Expand Up @@ -162,6 +174,6 @@ switch (command) {
}

default:
console.error('Usage: oddments <build|dev|preview|init|import|covers>')
console.error('Usage: oddments <build|dev|preview|clean|init|import|covers>')
process.exit(1)
}
13 changes: 12 additions & 1 deletion src/routes/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,17 @@
options: (o: object) => Promise<void>
} | null = null

async function importPagefind() {
const primary = asset('/pagefind/pagefind.js')
try {
return await import(/* @vite-ignore */ primary)
} catch (error) {
const assetBase = asset('/').replace(/\/$/, '')
if (!assetBase || !primary.startsWith(`${assetBase}/`)) throw error
return await import(/* @vite-ignore */ primary.slice(assetBase.length))
}
}

function resultToExhibit(r: PagefindResultData): Exhibit {
const slug = r.url.replace(/^.*\/exhibit\//, '').replace(/\/$/, '')
return {
Expand Down Expand Up @@ -110,7 +121,7 @@
return
}
try {
pagefind = await import(/* @vite-ignore */ asset('/pagefind/pagefind.js'))
pagefind = await importPagefind()
const baseUrl = resolve('/').replace(/\/$/, '')
if (baseUrl) await pagefind!.options({ baseUrl })
await pagefind!.init()
Expand Down
2 changes: 2 additions & 0 deletions starter-template/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ A filterable card catalog built with [Oddments](https://github.com/gulluth/oddme
git clone your-repo
npm install
npm run dev # preview at http://localhost:5173
npm run clean # remove build cache if preview/build state gets stale
```

### Codespaces or Dev Containers
Expand All @@ -32,6 +33,7 @@ CLI commands work there too:
```bash
npx oddments import template.csv --dry-run
npx oddments covers --dry-run
npx oddments clean
```

## Adding content
Expand Down
3 changes: 2 additions & 1 deletion starter-template/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@
"private": true,
"scripts": {
"build": "oddments build",
"clean": "oddments clean",
"dev": "oddments dev",
"preview": "oddments preview"
},
"dependencies": {
"@gulluth/oddments": "^0.98.0"
"@gulluth/oddments": "^0.98.1"
}
}
Loading