-
Notifications
You must be signed in to change notification settings - Fork 29
feat: create related posts and products #1584
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,7 @@ | ||
| import { ImageWidget } from "../admin/widgets.ts"; | ||
| import { PageInfo, Person, Thing } from "../commerce/types.ts"; | ||
| import { type Section } from "@deco/deco/blocks"; | ||
| import { Product } from "../commerce/types.ts"; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Verify whether relatedProducts is already modeled/consumed elsewhere.
rg -n -C3 --type=ts '\brelatedProducts\b'
rg -n -C3 --type=ts '\binterface\s+BlogPost\b'
rg -n -C3 --type=ts '`@options` .*Product|ProductList|Catalog'Repository: deco-cx/apps Length of output: 50370 🏁 Script executed: cat -n blog/types.tsRepository: deco-cx/apps Length of output: 7062 Add the missing Line 4 imports Proposed change export interface BlogPost {
relatedPosts?: BlogPost[];
+ /**
+ * `@title` Produtos Relacionados
+ * `@description` Selecione produtos para exibir no post
+ * `@format` dynamic-options
+ * `@options` <use the same product loader path used by this PR>
+ */
+ relatedProducts?: Product[];🤖 Prompt for AI Agents |
||
|
|
||
| /** | ||
| * @titleBy name | ||
|
|
@@ -17,8 +18,18 @@ export interface Author { | |
| export interface Category { | ||
| name: string; | ||
| slug: string; | ||
| /** | ||
|
pedrophzp marked this conversation as resolved.
|
||
| * @title Categoria Pai | ||
| * @description Selecione se esta categoria for uma subcategoria de outra | ||
| * @format dynamic-options | ||
| * @options apps/blog/loaders/CategoryList.ts | ||
| */ | ||
| parent?: Category; | ||
| } | ||
|
|
||
| /** | ||
| * @titleBy title | ||
| */ | ||
| export interface BlogPost { | ||
| title: string; | ||
| excerpt: string; | ||
|
|
@@ -52,13 +63,18 @@ export interface BlogPost { | |
| content?: string; | ||
| /** | ||
| * @title Sections | ||
| * @label hidden | ||
| * @changeable true | ||
| * @description Adicione seções de conteúdo (PostTitle, PostText, PostImage) | ||
| */ | ||
| sections?: Section[]; | ||
| /** | ||
| * @title Posts Relacionados | ||
| * @description Busque posts já cadastrados pelo título | ||
| * @format dynamic-options | ||
| * @options apps/blog/loaders/BlogPostList.ts | ||
| */ | ||
| relatedPosts?: BlogPost[]; | ||
| /** | ||
| * @title Carousel in post content | ||
| * @description add a carousel in the middle of the post. Must be implemented in frontEnd | ||
| */ | ||
| imageCarousel?: ImageCarousel; | ||
| /** | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: deco-cx/apps
Length of output: 140
🏁 Script executed:
Repository: deco-cx/apps
Length of output: 2246
🏁 Script executed:
Repository: deco-cx/apps
Length of output: 6561
🏁 Script executed:
Repository: deco-cx/apps
Length of output: 1108
🏁 Script executed:
Repository: deco-cx/apps
Length of output: 1283
🏁 Script executed:
Repository: deco-cx/apps
Length of output: 3139
🏁 Script executed:
Repository: deco-cx/apps
Length of output: 4359
🏁 Script executed:
Repository: deco-cx/apps
Length of output: 779
🏁 Script executed:
Repository: deco-cx/apps
Length of output: 1468
Sanitize content before
dangerouslySetInnerHTML(Line 57).Rendering
post.contentdirectly here is an XSS risk. The content comes from the CMS (@format rich-text) and is injected without sanitization. AsanitizeHtmlutility already exists in this codebase atspire/utils/sanitizeHtml.tsthat can be reused to strip XSS vectors (scripts, event handlers, dangerous protocols).🧰 Tools
🪛 ast-grep (0.42.2)
[warning] 56-56: Usage of dangerouslySetInnerHTML detected. This bypasses React's built-in XSS protection. Always sanitize HTML content using libraries like DOMPurify before injecting it into the DOM to prevent XSS attacks.
Context: dangerouslySetInnerHTML
Note: [CWE-79] Improper Neutralization of Input During Web Page Generation [REFERENCES]
- https://reactjs.org/docs/dom-elements.html#dangerouslysetinnerhtml
- https://cwe.mitre.org/data/definitions/79.html
(react-unsafe-html-injection)
🤖 Prompt for AI Agents