-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #34 from HyunmoAhn/env/combine-blogs
Env/combine blogs
- Loading branch information
Showing
10 changed files
with
92 additions
and
23 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains 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
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains 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 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,59 @@ | ||
import React from 'react'; | ||
import clsx from 'clsx'; | ||
import Translate from '@docusaurus/Translate'; | ||
import { PageMetadata, HtmlClassNameProvider, ThemeClassNames } from '@docusaurus/theme-common'; | ||
import { useBlogTagsPostsPageTitle } from '@docusaurus/theme-common/internal'; | ||
import Link from '@docusaurus/Link'; | ||
import BlogLayout from '@theme/BlogLayout'; | ||
import BlogListPaginator from '@theme/BlogListPaginator'; | ||
import SearchMetadata from '@theme/SearchMetadata'; | ||
import type { Props } from '@theme/BlogTagsPostsPage'; | ||
import BlogPostItems from '@theme/BlogPostItems'; | ||
import Unlisted from '@theme/ContentVisibility/Unlisted'; | ||
import Heading from '@theme/Heading'; | ||
import { getTaggedSideBar } from '../../utils'; | ||
|
||
function BlogTagsPostsPageMetadata({ tag }: Props): JSX.Element { | ||
const title = useBlogTagsPostsPageTitle(tag); | ||
return ( | ||
<> | ||
<PageMetadata title={title} description={tag.description} /> | ||
<SearchMetadata tag="blog_tags_posts" /> | ||
</> | ||
); | ||
} | ||
|
||
function BlogTagsPostsPageContent({ tag, items, sidebar, listMetadata }: Props): JSX.Element { | ||
const title = useBlogTagsPostsPageTitle(tag); | ||
const taggedSideBar = getTaggedSideBar({ selectTag: tag.label, items, sidebar }); | ||
|
||
return ( | ||
<BlogLayout sidebar={taggedSideBar}> | ||
{tag.unlisted && <Unlisted />} | ||
<header className="margin-bottom--xl"> | ||
<Heading as="h1">{title}</Heading> | ||
{tag.description && <p>{tag.description}</p>} | ||
<Link href={tag.allTagsPath}> | ||
<Translate | ||
id="theme.tags.tagsPageLink" | ||
description="The label of the link targeting the tag list page" | ||
> | ||
View All Tags | ||
</Translate> | ||
</Link> | ||
</header> | ||
<BlogPostItems items={items} /> | ||
<BlogListPaginator metadata={listMetadata} /> | ||
</BlogLayout> | ||
); | ||
} | ||
export default function BlogTagsPostsPage(props: Props): JSX.Element { | ||
return ( | ||
<HtmlClassNameProvider | ||
className={clsx(ThemeClassNames.wrapper.blogPages, ThemeClassNames.page.blogTagPostListPage)} | ||
> | ||
<BlogTagsPostsPageMetadata {...props} /> | ||
<BlogTagsPostsPageContent {...props} /> | ||
</HtmlClassNameProvider> | ||
); | ||
} |
This file contains 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,25 @@ | ||
import type { PropBlogPostContent, BlogSidebar } from '@docusaurus/plugin-content-blog'; | ||
|
||
export interface TaggedSideBarParams { | ||
items: readonly { readonly content: PropBlogPostContent }[]; | ||
sidebar: BlogSidebar; | ||
selectTag: string; | ||
} | ||
|
||
export const getTaggedSideBar = ({ items, selectTag, sidebar }: TaggedSideBarParams) => { | ||
const taggedContents = items.filter((item) => | ||
item.content.metadata.tags.some((tag) => { | ||
return tag.label === selectTag; | ||
}), | ||
); | ||
|
||
return { | ||
...sidebar, | ||
title: `"${selectTag}" posts`, | ||
items: sidebar.items.filter((item) => { | ||
return taggedContents.some((taggedContent) => { | ||
return item.permalink === taggedContent.content.metadata.permalink; | ||
}); | ||
}), | ||
}; | ||
}; |