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
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@ Find and replace all on all files (CMD+SHIFT+F):
- Package name: @threenine/nuxstr-comments
- Description: Nuxstr Comments
-->

![Nuxt Fathom module](https://res.cloudinary.com/threenine-co-uk/image/upload/v1733252921/nuxstr-comments_rk7pig.png)
# Nuxstr Comments

[![npm version][npm-version-src]][npm-version-href]
[![npm downloads][npm-downloads-src]][npm-downloads-href]
[![License][license-src]][license-href]
[![Nuxt][nuxt-src]][nuxt-href]

![]()
Enable [nostr protocol](https://nostr.com/) based comment system on your Nuxt 4 based applications.

- [✨  Release Notes](/CHANGELOG.md)
Expand Down
4 changes: 3 additions & 1 deletion eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ export default createConfigForNuxt({
})
.append(
{
ignores: ['playground/**/*'],
rules: {
'vue/multi-word-component-names': 'off',
},

},
// your custom flat config here...
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,20 +41,20 @@
"@nuxt/devtools": "^2.6.2",
"@nuxt/eslint": "1.9.0",
"@nuxt/eslint-config": "^1.9.0",
"@nuxt/kit": "^4.2.1",
"@nuxt/kit": "^4.3.1",
"@nuxt/module-builder": "^1.0.2",
"@nuxt/schema": "^4.2.1",
"@nuxt/scripts": "0.11.10",
"@nuxt/test-utils": "^3.19.2",
"@nuxt/ui": "^4.3.0",
"@nuxt/ui": "^4.5.1",
"@testing-library/jest-dom": "^6.8.0",
"@testing-library/vue": "^8.1.0",
"@types/node": "latest",
"@unhead/vue": "^2.0.14",
"changelogen": "^0.6.2",
"eslint": "^9.35.0",
"jsdom": "^26.1.0",
"nuxt": "^4.2.1",
"nuxt": "^4.3.1",
"typescript": "~5.9.2",
"vitest": "^3.2.4",
"vue-tsc": "^3.0.6"
Expand Down
142 changes: 71 additions & 71 deletions playground/app/app.config.ts
Original file line number Diff line number Diff line change
@@ -1,84 +1,84 @@
export default defineAppConfig({

ui: {
colors: {
primary: 'orange',
neutral: 'neutral'
ui: {
colors: {
primary: 'orange',
neutral: 'neutral',
},
chip: {
slots: {
root: 'relative inline-flex items-center justify-center shrink-0',
base: 'rounded-full ring ring-bg flex items-center justify-center text-inverted font-medium whitespace-nowrap',
},
chip: {
slots: {
root: 'relative inline-flex items-center justify-center shrink-0',
base: 'rounded-full ring ring-bg flex items-center justify-center text-inverted font-medium whitespace-nowrap'
variants: {
color: {
primary: 'bg-primary',
secondary: 'bg-secondary',
success: 'bg-success',
info: 'bg-info',
warning: 'bg-warning',
error: 'bg-error',
neutral: 'bg-inverted',
},
size: {
'3xs': 'h-[4px] min-w-[4px] text-[4px]',
'2xs': 'h-[5px] min-w-[5px] text-[5px]',
'xs': 'h-[6px] min-w-[6px] text-[6px]',
'sm': 'h-[7px] min-w-[7px] text-[7px]',
'md': 'h-[8px] min-w-[8px] text-[8px]',
'lg': 'h-[9px] min-w-[9px] text-[9px]',
'xl': 'h-[10px] min-w-[10px] text-[10px]',
'2xl': 'h-[11px] min-w-[11px] text-[11px]',
'3xl': 'h-[12px] min-w-[12px] text-[12px]',
},
position: {
'top-right': 'top-0 right-0',
'bottom-right': 'bottom-0 right-0',
'top-left': 'top-0 left-0',
'bottom-left': 'bottom-0 left-0',
},
variants: {
color: {
primary: 'bg-primary',
secondary: 'bg-secondary',
success: 'bg-success',
info: 'bg-info',
warning: 'bg-warning',
error: 'bg-error',
neutral: 'bg-inverted'
},
size: {
'3xs': 'h-[4px] min-w-[4px] text-[4px]',
'2xs': 'h-[5px] min-w-[5px] text-[5px]',
xs: 'h-[6px] min-w-[6px] text-[6px]',
sm: 'h-[7px] min-w-[7px] text-[7px]',
md: 'h-[8px] min-w-[8px] text-[8px]',
lg: 'h-[9px] min-w-[9px] text-[9px]',
xl: 'h-[10px] min-w-[10px] text-[10px]',
'2xl': 'h-[11px] min-w-[11px] text-[11px]',
'3xl': 'h-[12px] min-w-[12px] text-[12px]'
},
position: {
'top-right': 'top-0 right-0',
'bottom-right': 'bottom-0 right-0',
'top-left': 'top-0 left-0',
'bottom-left': 'bottom-0 left-0'
},
inset: {
false: ''
},
standalone: {
false: 'absolute'
}
inset: {
false: '',
},
standalone: {
false: 'absolute',
},
compoundVariants: [
{
position: 'top-right',
inset: false,
class: '-translate-y-1/2 translate-x-1/2 transform'
},
{
position: 'bottom-right',
inset: false,
class: 'translate-y-1/2 translate-x-1/2 transform'
},
{
position: 'top-left',
inset: false,
class: '-translate-y-1/2 -translate-x-1/2 transform'
},
{
position: 'bottom-left',
inset: false,
class: 'translate-y-1/2 -translate-x-1/2 transform'
}
],
defaultVariants: {
size: 'md',
color: 'primary',
position: 'top-right'
}
},
compoundVariants: [
{
position: 'top-right',
inset: false,
class: '-translate-y-1/2 translate-x-1/2 transform',
},
{
position: 'bottom-right',
inset: false,
class: 'translate-y-1/2 translate-x-1/2 transform',
},
{
position: 'top-left',
inset: false,
class: '-translate-y-1/2 -translate-x-1/2 transform',
},
{
position: 'bottom-left',
inset: false,
class: 'translate-y-1/2 -translate-x-1/2 transform',
},
],
defaultVariants: {
size: 'md',
color: 'primary',
position: 'top-right',
},
},
icons: {
light: 'i-ph-sun',
dark: 'i-ph-moon'
dark: 'i-ph-moon',
},
skeleton: {
base: 'animate-pulse rounded-md bg-elevated'
}
base: 'animate-pulse rounded-md bg-elevated',
},

},
})
10 changes: 8 additions & 2 deletions playground/app/pages/another-page.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,14 @@

<template>
<div>
<nuxt-link to="/" class="text-primary">Back</nuxt-link>
<nuxt-link to="/another" class="text-primary">Another</nuxt-link>
<nuxt-link
to="/"
class="text-primary"
>Back</nuxt-link>
<nuxt-link
to="/another"
class="text-primary"
>Another</nuxt-link>
<nuxstr-comments />
</div>
</template>
Expand Down
1 change: 0 additions & 1 deletion playground/app/pages/another/deeper/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
</script>

<template>

<nuxstr-comments />
</template>

Expand Down
10 changes: 5 additions & 5 deletions playground/app/pages/another/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
</script>

<template>

<div>

<nuxt-link to="/another/deeper" class="text-primary">Another deeper</nuxt-link>
<u-separator></u-separator>
<nuxt-link
to="/another/deeper"
class="text-primary"
>Another deeper</nuxt-link>
<u-separator />
<nuxstr-comments />
</div>

</template>

<style scoped>
Expand Down
12 changes: 6 additions & 6 deletions playground/app/pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
<template>
<nuxt-layout name="default-layout">
<UContainer>
<h1>Playground</h1>
<p>Index Page</p> <nuxt-link
to="another-page"
class="text-primary"
> Another Page</nuxt-link>
<NuxstrComments />
<h1>Playground</h1>
<p>Index Page</p> <nuxt-link
to="another-page"
class="text-primary"
> Another Page</nuxt-link>
<NuxstrComments />
</UContainer>
</nuxt-layout>
</template>
Expand Down
2 changes: 1 addition & 1 deletion playground/nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ export default defineNuxtConfig({
css: ['~/assets/css/main.css'],
compatibilityDate: '2025-08-19',
nuxstrComments: {
relays: ['wss://relay.threenine.services']
relays: ['ws://localhost:10547'],
},
})
4 changes: 2 additions & 2 deletions src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,12 @@ export default defineNuxtModule<ModuleOptions>({
nuxt.hook('nitro:config', (nitroConfig) => {
nitroConfig.externals = nitroConfig.externals || {}
nitroConfig.externals.inline = nitroConfig.externals.inline || []
nitroConfig.externals.inline.push('tseep', 'nostr-tools', 'defu')
nitroConfig.externals.inline.push('nostr-tools', 'defu')
})

// Build transpilation (you already had this)
nuxt.options.build.transpile = nuxt.options.build.transpile || []
nuxt.options.build.transpile.push('tseep', 'nostr-tools', 'defu')
nuxt.options.build.transpile.push('nostr-tools', 'defu')

// Expose runtime config to plugin
nuxt.options.runtimeConfig.public.nuxstrComments = defu(nuxt.options.runtimeConfig.public.nuxstrComments || {}, options)
Expand Down
5 changes: 4 additions & 1 deletion src/runtime/classes/NostrManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,16 @@ export class NostrManager {
return NostrManager.instance
}

public subscribe(filter: Filter, onEvent: (event: NToolEvent) => void) {
public subscribe(filter: Filter, onEvent: (event: NToolEvent) => void, onEose?: () => void) {
return this.pool.subscribeMany(this.relays, filter, {
onevent(event) {
if (verifyEvent(event)) {
onEvent(event)
}
},
oneose() {
if (onEose) onEose()
},
})
}

Expand Down
Loading