feat(v2): bootstrap theme tags and specific tag page (#2590)

* feat(v2): init the blog post card

* feat(v2): Update card design

* chore(v2): remove unused dependency

* feat(v2): add post list

* feat(v2): improve html tags

* chore(v2): run prettier

* feat(v2): remove old tag

* feat(v2): apply suggestions

* feat(v2): add tags for blog post

* feat(v2): add post content

* feat(v2): add tags

* feat(v2): add specific tag page

* feat(v2): fix tablet layout

* feat(v2): fix tablet layout
This commit is contained in:
Fanny 2020-04-13 02:58:30 -03:00 committed by GitHub
parent 9c93d53a64
commit 1c2e8f92cc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 77 additions and 9 deletions

View file

@ -17,7 +17,7 @@ function BlogListPage(props) {
{items.map(({content: BlogPostContent}) => (
<div
key={BlogPostContent.metadata.permalink}
className="col col-md-4 offset-md-4 col-xs-6 mb-5">
className="col col-xl-4 offset-xl-4 col-xs-6 mb-5">
<BlogPostCard
frontMatter={BlogPostContent.frontMatter}
metadata={BlogPostContent.metadata}

View file

@ -6,6 +6,7 @@
*/
import React from 'react';
import Link from '@docusaurus/Link';
const MONTHS = [
'January',
@ -63,17 +64,17 @@ function BlogPostItem(props) {
<div className="card-body">
<h3 className="card-title text-primary">{title}</h3>
<p className="lead">{children}</p>
<div className="lead">{children}</div>
</div>
<footer className="row no-gutters m-3 justify-content-between">
<div className="col col-xs">
{tags.length > 0 && (
<>
{tags.map(({label}) => (
<span key={label} className="badge badge-primary m-1">
{label}
</span>
{tags.map(({label, permalink: tagPermalink}) => (
<Link key={tagPermalink} className="m-1" to={tagPermalink}>
<span className="badge badge-primary">{label}</span>
</Link>
))}
</>
)}

View file

@ -4,5 +4,31 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import React from 'react';
import Link from '@docusaurus/Link';
export default () => {};
function BlogTagsListPage(props) {
const {tags} = props;
const renderAllTags = () => (
<>
{Object.keys(tags).map((tag) => (
<Link
href={tags[tag].permalink}
key={tag}
className="btn btn-primary m-2">
{tags[tag].name}{' '}
<span className="badge badge-light">{tags[tag].count}</span>
</Link>
))}
</>
);
return (
<div className="container my-3 justify-content-center">
<h1 className="text-primary">Tags</h1>
<ul className="my-xl-4">{renderAllTags()}</ul>
</div>
);
}
export default BlogTagsListPage;

View file

@ -5,4 +5,45 @@
* LICENSE file in the root directory of this source tree.
*/
export default () => {};
import React from 'react';
import BlogPostItem from '@theme/BlogPostItem';
import Link from '@docusaurus/Link';
function pluralize(count, word) {
return count > 1 ? `${word}s` : word;
}
function BlogTagsPostPage(props) {
const {metadata, items} = props;
const {allTagsPath, name, count} = metadata;
return (
<div className="container-fluid my-4">
<header className="text-center">
<h1>
{count} {pluralize(count, 'post')} tagged with &quot;{name}
&quot;
</h1>
<Link href={allTagsPath}>View All Tags</Link>
</header>
<div className="my-4">
{items.map(({content: BlogPostContent}) => (
<div
key={BlogPostContent.metadata.permalink}
className="col col-xl-4 offset-xl-4 col-xs-6 mb-5">
<BlogPostItem
key={BlogPostContent.metadata.permalink}
frontMatter={BlogPostContent.frontMatter}
metadata={BlogPostContent.metadata}
truncated>
<BlogPostContent />
</BlogPostItem>
</div>
))}
</div>
</div>
);
}
export default BlogTagsPostPage;

View file

@ -20,7 +20,7 @@ declare global {
interface Props {
readonly isNavLink?: boolean;
readonly to?: string;
readonly href: string
readonly href: string;
}
function Link({isNavLink, ...props}: Props) {