diff --git a/README.md b/README.md index 5b3b52f..eb7f41c 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ -A blog for Saucebase: posts, categories, tags, RSS and SEO, managed from the admin. +A Laravel blog for Saucebase: posts, categories, tags, RSS and SEO, managed from the admin, on Vue or React. A module for [Saucebase](https://github.com/saucebase-dev/saucebase), the AI-ready Laravel SaaS kit. Modules are Composer packages you add to a Saucebase app; once installed, the code is yours to change. diff --git a/composer.json b/composer.json index 7873256..5182225 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,29 @@ { "name": "saucebase/blog", - "description": "A blog for Saucebase: posts, categories, tags, RSS and SEO, managed from the admin.", + "description": "Laravel blog module for Saucebase: posts with a rich text editor, categories, tags, scheduling, draft preview, RSS feed and SEO (meta tags, JSON-LD structured data, server-rendered pages), with a Filament admin. Vue and React (Inertia).", + "keywords": [ + "saucebase", + "saucebase-module", + "laravel", + "laravel-package", + "filament", + "inertiajs", + "vuejs", + "reactjs", + "blog", + "laravel-blog", + "blog-engine", + "cms", + "content-management", + "rss", + "rss-feed", + "seo", + "json-ld", + "structured-data", + "rich-text-editor", + "scheduled-posts" + ], + "homepage": "https://saucebase-dev.github.io/docs/modules/blog/", "type": "saucebase-module", "license": "MIT", "version": "v3.5.0", diff --git a/resources/boost/skills/saucebase-blog-development/SKILL.md b/resources/boost/skills/saucebase-blog-development/SKILL.md index ba34922..1dece89 100644 --- a/resources/boost/skills/saucebase-blog-development/SKILL.md +++ b/resources/boost/skills/saucebase-blog-development/SKILL.md @@ -70,7 +70,7 @@ The card's title link stretches over the whole card (`after:absolute after:inset The rich-editor HTML is rendered with `v-html` / `dangerouslySetInnerHTML`. `Post::content` is cast with core's `SanitizedHtml`, which runs `Str::sanitizeHtml()` (Filament's Symfony sanitizer) on every read and stores what was written, so scripts and event handlers never reach a page, whichever endpoint sends it. Keep the cast (sc-1131). -The JSON-LD `` cannot break out of it. +The JSON-LD is built in `BlogController::jsonLd()` and sent as `json_ld` (Article and BreadcrumbList); both stacks print it as is. `JSON_HEX_TAG` escapes `<` and `>`, so a title containing `` cannot break out of the script tag (sc-1198). ### PHP → TypeScript Contract diff --git a/resources/js/react/pages/Show.tsx b/resources/js/react/pages/Show.tsx index 369e584..d389c29 100644 --- a/resources/js/react/pages/Show.tsx +++ b/resources/js/react/pages/Show.tsx @@ -20,53 +20,13 @@ interface ShowProps { related: Modules.Blog.Data.PostData[]; /** An admin viewing a post that is not public yet. */ preview: boolean; + /** Article and BreadcrumbList, built and escaped on the server. */ + json_ld: string[]; } -// `<` is escaped so a title containing a closing script tag cannot end the -// JSON-LD block. -const toJsonLd = (data: object) => - JSON.stringify(data).replaceAll('<', String.raw`\u003c`); - -export default function Show({ post, related, preview }: ShowProps) { +export default function Show({ post, related, preview, json_ld }: ShowProps) { const t = useT(); - const jsonLd = { - '@context': 'https://schema.org', - '@type': 'Article', - headline: post.title, - description: post.excerpt ?? undefined, - image: post.cover_url || undefined, - datePublished: post.published_at ?? undefined, - dateModified: post.updated_at ?? undefined, - author: post.author - ? { '@type': 'Person', name: post.author.name } - : undefined, - url: post.url, - }; - - // The same trail as the visible breadcrumbs, which search results can show - // in place of the raw URL. - const breadcrumbJsonLd = { - '@context': 'https://schema.org', - '@type': 'BreadcrumbList', - itemListElement: [ - { name: t('Blog'), item: route('blog.index') }, - ...(post.category - ? [ - { - name: post.category.name, - item: route('blog.category', post.category.slug), - }, - ] - : []), - { name: post.title, item: post.url }, - ].map((crumb, index) => ({ - '@type': 'ListItem', - position: index + 1, - ...crumb, - })), - }; - return ( )} -