Skip to content

Commit

Permalink
spex: upgrade to 0.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ludovicm67 committed Jun 12, 2024
1 parent 354c6cc commit 9d02f2a
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 7 deletions.
5 changes: 5 additions & 0 deletions .changeset/flat-eggs-live.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"trifid-plugin-spex": minor
---

Upgrade SPEX to 0.2.0.
6 changes: 3 additions & 3 deletions packages/spex/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import path, { dirname } from 'node:path'
import { dirname, join } from 'node:path'
import { fileURLToPath } from 'node:url'

import { resolve } from 'import-meta-resolve'
Expand All @@ -7,7 +7,7 @@ import fastifyStatic from '@fastify/static'
const __dirname = dirname(fileURLToPath(import.meta.url))

const defaults = {
template: path.join(__dirname, 'views/index.hbs'),
template: join(__dirname, 'views/index.hbs'),
}

const defaultOptions = {
Expand Down Expand Up @@ -40,7 +40,7 @@ const createPlugin = async (server, config, render) => {
config = { ...defaults, ...config, spexOptions }

// Serve static files from SPEX dist folder
const distPath = resolve('@zazuko/spex/dist', import.meta.url)
const distPath = dirname(resolve('@zazuko/spex', import.meta.url))
server.register(fastifyStatic, {
root: distPath.replace(/^file:\/\//, ''),
prefix: '/spex/static/',
Expand Down
4 changes: 2 additions & 2 deletions packages/spex/test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,13 @@ describe('trifid-plugin-spex', () => {
})

it('should serve the static JavaScript file', async () => {
const res = await fetch(`${getListenerURL(trifidListener)}/spex/static/spex.umd.min.js`)
const res = await fetch(`${getListenerURL(trifidListener)}/spex/static/spex.umd.cjs`)
await res.text() // Just make sure that the stream is consumed
strictEqual(res.status, 200)
})

it('should serve the static CSS file', async () => {
const res = await fetch(`${getListenerURL(trifidListener)}/spex/static/spex.css`)
const res = await fetch(`${getListenerURL(trifidListener)}/spex/static/style.css`)
await res.text() // Just make sure that the stream is consumed
strictEqual(res.status, 200)
})
Expand Down
4 changes: 2 additions & 2 deletions packages/spex/views/index.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<div id="spex"></div>
</div>

<script type="text/javascript" src="static/spex.umd.min.js"></script>
<script type="text/javascript" src="static/spex.umd.cjs"></script>
<style type="text/css">
html,
body {
Expand Down Expand Up @@ -43,7 +43,7 @@
// create style element in the shadow element to avoid any style conflicts
const style = document.createElement("style");
style.type = "text/css";
style.innerHTML = "@import url('static/spex.css');"
style.innerHTML = "@import url('static/style.css');"
// create the shadow element and put the style element and the mount point
const spexContainer = document.getElementById("spex");
Expand Down

0 comments on commit 9d02f2a

Please sign in to comment.