-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
feat(blog): add visible RSS feed #6350
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
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
b4090e1
feat(blog): add visible RSS feed
AugustinMauroy e6f35ca
fix: rss link
AugustinMauroy 0e7d191
fix
AugustinMauroy 52390cc
fix: rss link logic
AugustinMauroy ca1a89b
fix: generic blog when category didn't exist
AugustinMauroy 7e2989b
design: add hover effect
AugustinMauroy c0e4cd9
feat(blog): introduce blogHeader
AugustinMauroy a370e9e
move component to right folder
AugustinMauroy b71f0b2
Merge branch 'main' into feat(rss)-visible-link
ovflowd f003c05
fix: test
AugustinMauroy 88e9845
Merge branch 'main' into feat(rss)-visible-link
ovflowd be1937d
fix: remove useless `max-w-8xl`
AugustinMauroy 6ea828d
revert
AugustinMauroy c7093bb
re-add extra space
AugustinMauroy 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| import { render, screen } from '@testing-library/react'; | ||
|
|
||
| import BlogHeader from '@/components/Blog/BlogHeader'; | ||
|
|
||
| describe('BlogHeader', () => { | ||
| it('should have correct href when category is all', () => { | ||
| render(<BlogHeader category="all" />); | ||
| const link = screen.getByRole('link'); | ||
| expect(link).toHaveAttribute('href', '/feed/blog.xml'); | ||
| }); | ||
|
|
||
| it('should have correct href when category is release', () => { | ||
| render(<BlogHeader category="release" />); | ||
| const link = screen.getByRole('link'); | ||
| expect(link).toHaveAttribute('href', '/feed/releases.xml'); | ||
| }); | ||
|
|
||
| it('should have correct href when category is vulnerability', () => { | ||
| render(<BlogHeader category="vulnerability" />); | ||
| const link = screen.getByRole('link'); | ||
| expect(link).toHaveAttribute('href', '/feed/vulnerability.xml'); | ||
| }); | ||
|
|
||
| it('should have correct href when category is random', () => { | ||
| render(<BlogHeader category="random" />); | ||
| const link = screen.getByRole('link'); | ||
| expect(link).toHaveAttribute('href', '/feed/blog.xml'); | ||
| }); | ||
| }); |
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,34 @@ | ||
| .blogHeader { | ||
| h1 { | ||
| @apply inline-flex | ||
| w-full | ||
| items-center | ||
| justify-between; | ||
|
|
||
| a { | ||
| @apply inline-flex | ||
| size-9 | ||
| items-center | ||
| justify-center | ||
| rounded-md | ||
| p-2; | ||
|
|
||
| &:hover { | ||
| @apply bg-neutral-100 | ||
| dark:bg-neutral-900; | ||
| } | ||
| } | ||
|
|
||
| svg { | ||
| @apply size-6 | ||
| text-neutral-500; | ||
| } | ||
| } | ||
|
|
||
| p { | ||
| @apply text-lg | ||
| font-medium | ||
| text-neutral-800 | ||
| dark:text-neutral-200; | ||
| } | ||
| } |
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,23 @@ | ||
| import type { Meta as MetaObj, StoryObj } from '@storybook/react'; | ||
|
|
||
| import BlogHeader from '@/components/Blog/BlogHeader'; | ||
|
|
||
| type Story = StoryObj<typeof BlogHeader>; | ||
| type Meta = MetaObj<typeof BlogHeader>; | ||
|
|
||
| export const Default: Story = { | ||
| args: { | ||
| // See `@/site.json` for the `rssFeeds` object | ||
| category: 'all', | ||
| }, | ||
| decorators: [ | ||
| // We need to wrap to allow global styles to be applied (markdown styles) | ||
| Story => ( | ||
| <main> | ||
| <Story /> | ||
| </main> | ||
| ), | ||
| ], | ||
| }; | ||
|
|
||
| export default { component: BlogHeader } as Meta; |
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,35 @@ | ||
| 'use client'; | ||
|
|
||
| import { RssIcon } from '@heroicons/react/24/solid'; | ||
| import { useTranslations } from 'next-intl'; | ||
| import type { FC } from 'react'; | ||
|
|
||
| import Link from '@/components/Link'; | ||
| import { siteConfig } from '@/next.json.mjs'; | ||
|
|
||
| import styles from './index.module.css'; | ||
|
|
||
| type BlogHeaderProps = { | ||
| category: string; | ||
| }; | ||
|
|
||
| const BlogHeader: FC<BlogHeaderProps> = ({ category }) => { | ||
| const t = useTranslations(); | ||
| const currentFile = | ||
| siteConfig.rssFeeds.find(item => item.category === category)?.file ?? | ||
| 'blog.xml'; | ||
|
|
||
| return ( | ||
| <header className={styles.blogHeader}> | ||
| <h1> | ||
| {t('layouts.blog.title')} | ||
| <Link href={`/feed/${currentFile}`}> | ||
| <RssIcon /> | ||
| </Link> | ||
| </h1> | ||
| <p>{t('layouts.blog.subtitle')}</p> | ||
| </header> | ||
| ); | ||
| }; | ||
|
|
||
| export default BlogHeader; |
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
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
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.
Uh oh!
There was an error while loading. Please reload this page.