@respectify/astro 0.1.4 → 0.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -18,12 +18,13 @@ const { postSlug, apiPath = '/api/respectify/comments', enableDelete = false } =
18
18
  <p class="rf-comments__empty rf-comments__hidden">No comments yet. Be the first to comment!</p>
19
19
  </section>
20
20
 
21
- <script define:vars={{ apiPath, enableDelete }}>
21
+ <script>
22
22
  import { actions } from 'astro:actions';
23
23
  import { fetchComments, renderCommentHtml } from '@respectify/astro/client';
24
24
 
25
25
  async function checkAuthForDelete() {
26
- if (!enableDelete) return false;
26
+ const section = document.querySelector('.rf-comments__section');
27
+ if (section?.dataset.enableDelete !== 'true') return false;
27
28
  try {
28
29
  const response = await fetch('/api/auth-status');
29
30
  if (!response.ok) return false;
@@ -74,7 +75,7 @@ const { postSlug, apiPath = '/api/respectify/comments', enableDelete = false } =
74
75
 
75
76
  async function loadComments(section) {
76
77
  const postSlug = section.dataset.postSlug || '';
77
- const path = section.dataset.apiPath || apiPath;
78
+ const path = section.dataset.apiPath;
78
79
  const loadingEl = section.querySelector('.rf-comments__loading');
79
80
  const listEl = section.querySelector('.rf-comments__list');
80
81
  const emptyEl = section.querySelector('.rf-comments__empty');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@respectify/astro",
3
- "version": "0.1.4",
3
+ "version": "0.1.7",
4
4
  "description": "Respectify-powered commenting for Astro — AI moderation, spam filtering, and beautiful UX out of the box.",
5
5
  "type": "module",
6
6
  "license": "MIT",
package/src/env.d.ts ADDED
@@ -0,0 +1,23 @@
1
+ /// <reference types="astro/client" />
2
+
3
+ import '@astrojs/db';
4
+
5
+ declare global {
6
+ namespace App {
7
+ interface Locals {
8
+ isAuthenticated?: boolean;
9
+ }
10
+ }
11
+ }
12
+
13
+ declare module 'astro:env/server' {
14
+ export const RESPECTIFY_EMAIL: string | undefined;
15
+ export const RESPECTIFY_API_KEY: string | undefined;
16
+ }
17
+
18
+ declare module 'astro:db' {
19
+ export const Comment: import('@astrojs/db/runtime').Table<
20
+ 'Comment',
21
+ typeof import('./schema').RespectifyComment.columns
22
+ >;
23
+ }
package/src/index.ts CHANGED
@@ -16,8 +16,8 @@ export default function respectify(userOptions: RespectifyIntegrationOptions = {
16
16
  updateConfig({
17
17
  env: {
18
18
  schema: {
19
- RESPECTIFY_EMAIL: envField.string({ context: 'server', access: 'secret' }),
20
- RESPECTIFY_API_KEY: envField.string({ context: 'server', access: 'secret' }),
19
+ RESPECTIFY_EMAIL: envField.string({ context: 'server', access: 'secret', optional: true }),
20
+ RESPECTIFY_API_KEY: envField.string({ context: 'server', access: 'secret', optional: true }),
21
21
  },
22
22
  },
23
23
  });
package/src/schema.ts CHANGED
@@ -1,17 +1,20 @@
1
1
  import { defineTable, column, NOW } from 'astro:db';
2
+ import type { TableConfig } from '@astrojs/db/types';
3
+
4
+ const respectifyCommentColumns = {
5
+ id: column.number({ primaryKey: true }),
6
+ postSlug: column.text(),
7
+ author: column.text(),
8
+ email: column.text({ optional: true }),
9
+ content: column.text(),
10
+ createdAt: column.date({ default: NOW }),
11
+ approved: column.boolean({ default: false }),
12
+ parentId: column.number({ optional: true }),
13
+ };
2
14
 
3
15
  /** Astro DB table definition for Respectify comments. Merge into your db/config.ts. */
4
- export const RespectifyComment = defineTable({
5
- columns: {
6
- id: column.number({ primaryKey: true }),
7
- postSlug: column.text(),
8
- author: column.text(),
9
- email: column.text({ optional: true }),
10
- content: column.text(),
11
- createdAt: column.date({ default: NOW }),
12
- approved: column.boolean({ default: false }),
13
- parentId: column.number({ optional: true }),
14
- },
16
+ export const RespectifyComment: TableConfig<typeof respectifyCommentColumns> = defineTable({
17
+ columns: respectifyCommentColumns,
15
18
  indexes: [
16
19
  { on: ['postSlug'], unique: false },
17
20
  { on: ['approved'], unique: false },