-
Notifications
You must be signed in to change notification settings - Fork 7
docs(blog): add client generator intro blog post #399
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
Open
Marshevskyy
wants to merge
4
commits into
main
Choose a base branch
from
docs/client-generator-intro-blog-post
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
13ce631
docs(blog): add client generator intro blog post as a React page
Marshevskyy 8786652
docs(realm): fix list indentation in MCP server page for markdownlint
Marshevskyy 8790795
docs(other): exclude mcp-server page from markdownlint instead of re-…
Marshevskyy 6724343
docs(blog): address PR review feedback
Marshevskyy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| import * as React from 'react'; | ||
| import styled from 'styled-components'; | ||
|
|
||
| import { useThemeHooks } from '@redocly/theme/core/hooks'; | ||
|
|
||
| import { ArticleCard } from '@redocly/marketing-pages/components/Blog/RecentPosts.js'; | ||
| import { H2Title } from '@redocly/marketing-pages/components/TypographyElements/TypographyElements.js'; | ||
|
|
||
| type RecentPost = { slug: string; title: string; description?: string }; | ||
|
|
||
| // Same layout as marketing-pages RecentPosts, but reads the deeper 'blog-recent-posts' | ||
| // shared data and filters out the post it renders on, so a post never lists itself. | ||
| export function RecentPosts({ currentSlug }: { currentSlug?: string }) { | ||
| // @ts-ignore | ||
| const { usePageSharedData } = useThemeHooks(); | ||
| const recentPosts = usePageSharedData<RecentPost[]>('blog-recent-posts') ?? []; | ||
|
|
||
| const posts = recentPosts.filter((post) => post.slug !== currentSlug).slice(0, 3); | ||
|
|
||
| if (posts.length === 0) { | ||
| return null; | ||
| } | ||
|
|
||
| return ( | ||
| <> | ||
| <H2Title textAlign={{ base: 'center' }} mb={{ base: '34px', small: '42px' }}> | ||
| Latest from our blog | ||
| </H2Title> | ||
| <RecentPostsGrid> | ||
| {posts.map((post) => ( | ||
| <ArticleCard | ||
| key={post.slug} | ||
| title={post.title} | ||
| description={post.description ?? ''} | ||
| slug={post.slug} | ||
| /> | ||
| ))} | ||
| </RecentPostsGrid> | ||
| </> | ||
| ); | ||
| } | ||
|
|
||
| const RecentPostsGrid = styled.div` | ||
| display: grid; | ||
| grid-template-columns: 1fr; | ||
| grid-gap: 5rem; | ||
| justify-items: center; | ||
|
|
||
| @media screen and (min-width: 900px) { | ||
| grid-template-columns: 1fr 1fr 1fr; | ||
| } | ||
| `; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,63 @@ | ||
| import Page from '@redocly/marketing-pages/templates/BlogPost.js'; | ||
| import React from 'react'; | ||
| import styled from 'styled-components'; | ||
|
|
||
| export default Page; | ||
| import type { Post } from '@redocly/marketing-pages/components/Blog/types.js'; | ||
|
|
||
| import { useThemeHooks } from '@redocly/theme/core/hooks'; | ||
| import { Markdown } from '@redocly/theme/components/Markdown/Markdown'; | ||
| import PostInfo from '@redocly/marketing-pages/components/Blog/PostInfo.js'; | ||
| import { MediaBox } from '@redocly/marketing-pages/components/PositionItems/MediaBox.js'; | ||
| import { Box } from '@redocly/marketing-pages/ui/Box.js'; | ||
|
|
||
| import { RecentPosts } from '../components/Blog/RecentPosts'; | ||
|
|
||
| // Local version of @redocly/marketing-pages/templates/BlogPost.js — the only | ||
| // difference is the RecentPosts section, which excludes the currently open post. | ||
| export default function BlogPost(props: { children?: React.ReactNode }) { | ||
| const { usePageProps } = useThemeHooks(); | ||
| const pageProps = usePageProps(); | ||
|
|
||
| const { publishedDate, author, categories, title, image, slug } = pageProps.metadata as Post & { | ||
| slug?: string; | ||
| }; | ||
|
|
||
| return ( | ||
| <PageWrapper style={{ background: 'white' }}> | ||
| <BlogMediaBox> | ||
| <PostInfo | ||
| authorName={author?.name} | ||
| authorBIO={author?.authorBIO} | ||
| publishedDate={publishedDate} | ||
| categories={categories} | ||
| title={title} | ||
| author={author} | ||
| avatar={author?.image} | ||
| image={image} | ||
| /> | ||
|
|
||
| <Markdown>{props.children}</Markdown> | ||
| </BlogMediaBox> | ||
|
|
||
| <MediaBox> | ||
| <Box style={{ margin: '80px 0' }}> | ||
| <RecentPosts currentSlug={slug} /> | ||
| </Box> | ||
| </MediaBox> | ||
| </PageWrapper> | ||
| ); | ||
| } | ||
|
|
||
| const BlogMediaBox = styled.div` | ||
| margin-left: auto; | ||
| margin-right: auto; | ||
| max-width: calc(90vw); | ||
|
|
||
| @media screen and (min-width: 900px) { | ||
| max-width: 800px; | ||
| } | ||
| `; | ||
|
|
||
| const PageWrapper = styled.div` | ||
| position: relative; | ||
| overflow: hidden; | ||
| `; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,11 +10,19 @@ export const buildAndSortBlogPosts = async (postRoutes, context, outdir) => { | |
| const metadata = await transformMetadata(metadataContentRecord.data, context.fs.cwd, outdir); | ||
|
|
||
| for (const route of postRoutes) { | ||
| const { | ||
| data: { content, frontmatter }, | ||
| } = await context.cache.load(route.fsPath, 'markdown-frontmatter'); | ||
| // React blog posts export `frontmatter`; markdown posts use YAML frontmatter | ||
| const isReactPage = /\.page\.tsx?$/.test(route.fsPath); | ||
|
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. Using regext seems fragile to me. |
||
| const { data } = await context.cache.load( | ||
| route.fsPath, | ||
| isReactPage ? 'react-frontmatter' : 'markdown-frontmatter', | ||
| ); | ||
| const frontmatter = isReactPage ? data : data?.frontmatter; | ||
|
|
||
| if (frontmatter?.ignore === true || (await context.isPathIgnored(route.fsPath))) { | ||
| if ( | ||
| (isReactPage && !frontmatter) || | ||
| frontmatter?.ignore === true || | ||
| (await context.isPathIgnored(route.fsPath)) | ||
| ) { | ||
| continue; | ||
| } | ||
|
|
||
|
|
@@ -26,15 +34,15 @@ export const buildAndSortBlogPosts = async (postRoutes, context, outdir) => { | |
| .map((categoryId) => { | ||
| const categoryData = metadata.categories.get(categoryId); | ||
| if (!categoryData) return null; | ||
|
|
||
| if (categoryData.category && categoryData.subcategory) { | ||
| return categoryData; | ||
| return categoryData; | ||
| } else { | ||
| return { | ||
| return { | ||
| category: { | ||
| id: categoryData.id, | ||
| label: categoryData.label | ||
| } | ||
| id: categoryData.id, | ||
| label: categoryData.label, | ||
| }, | ||
| }; | ||
| } | ||
| }) | ||
|
|
@@ -72,12 +80,12 @@ async function transformMetadata(metadata, cwd, outdir) { | |
| categories.set(fullId, { | ||
| category: { | ||
| id: category.id, | ||
| label: category.label | ||
| label: category.label, | ||
| }, | ||
| subcategory: { | ||
| id: subcategory.id, | ||
| label: subcategory.label | ||
| } | ||
| label: subcategory.label, | ||
| }, | ||
| }); | ||
| } | ||
| } | ||
|
|
||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Why do we need to modify Page in theme? It looks a better option to either modify it in the marketing pages or to enhance a specific page with the RecentPosts component. What do you think?