mirror of
https://github.com/facebook/docusaurus.git
synced 2025-06-22 20:47:53 +02:00
refactor(v2): readjust footer of blog item (#4918)
This commit is contained in:
parent
4a6de5cf7a
commit
0bbbfb641b
8 changed files with 39 additions and 22 deletions
|
@ -10,14 +10,14 @@ import clsx from 'clsx';
|
||||||
import {MDXProvider} from '@mdx-js/react';
|
import {MDXProvider} from '@mdx-js/react';
|
||||||
import Translate, {translate} from '@docusaurus/Translate';
|
import Translate, {translate} from '@docusaurus/Translate';
|
||||||
import Link from '@docusaurus/Link';
|
import Link from '@docusaurus/Link';
|
||||||
|
import {usePluralForm} from '@docusaurus/theme-common';
|
||||||
import MDXComponents from '@theme/MDXComponents';
|
import MDXComponents from '@theme/MDXComponents';
|
||||||
import Seo from '@theme/Seo';
|
import Seo from '@theme/Seo';
|
||||||
|
import EditThisPage from '@theme/EditThisPage';
|
||||||
import type {Props} from '@theme/BlogPostItem';
|
import type {Props} from '@theme/BlogPostItem';
|
||||||
|
|
||||||
import styles from './styles.module.css';
|
import styles from './styles.module.css';
|
||||||
|
|
||||||
import {usePluralForm} from '@docusaurus/theme-common';
|
|
||||||
|
|
||||||
// Very simple pluralization: probably good enough for now
|
// Very simple pluralization: probably good enough for now
|
||||||
function useReadingTimePlural() {
|
function useReadingTimePlural() {
|
||||||
const {selectMessage} = usePluralForm();
|
const {selectMessage} = usePluralForm();
|
||||||
|
@ -47,7 +47,15 @@ function BlogPostItem(props: Props): JSX.Element {
|
||||||
truncated,
|
truncated,
|
||||||
isBlogPostPage = false,
|
isBlogPostPage = false,
|
||||||
} = props;
|
} = props;
|
||||||
const {date, formattedDate, permalink, tags, readingTime, title} = metadata;
|
const {
|
||||||
|
date,
|
||||||
|
formattedDate,
|
||||||
|
permalink,
|
||||||
|
tags,
|
||||||
|
readingTime,
|
||||||
|
title,
|
||||||
|
editUrl,
|
||||||
|
} = metadata;
|
||||||
const {author, image, keywords} = frontMatter;
|
const {author, image, keywords} = frontMatter;
|
||||||
|
|
||||||
const authorURL = frontMatter.author_url || frontMatter.authorURL;
|
const authorURL = frontMatter.author_url || frontMatter.authorURL;
|
||||||
|
@ -104,7 +112,10 @@ function BlogPostItem(props: Props): JSX.Element {
|
||||||
<MDXProvider components={MDXComponents}>{children}</MDXProvider>
|
<MDXProvider components={MDXComponents}>{children}</MDXProvider>
|
||||||
</div>
|
</div>
|
||||||
{(tags.length > 0 || truncated) && (
|
{(tags.length > 0 || truncated) && (
|
||||||
<footer className="row margin-vert--lg">
|
<footer
|
||||||
|
className={clsx('row docusaurus-mt-lg', {
|
||||||
|
[styles.blogPostDetailsFull]: isBlogPostPage,
|
||||||
|
})}>
|
||||||
{tags.length > 0 && (
|
{tags.length > 0 && (
|
||||||
<div className="col">
|
<div className="col">
|
||||||
<b>
|
<b>
|
||||||
|
@ -124,7 +135,14 @@ function BlogPostItem(props: Props): JSX.Element {
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
{truncated && (
|
|
||||||
|
{isBlogPostPage && editUrl && (
|
||||||
|
<div className="col margin-top--sm">
|
||||||
|
<EditThisPage editUrl={editUrl} />
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{!isBlogPostPage && truncated && (
|
||||||
<div className="col text--right">
|
<div className="col text--right">
|
||||||
<Link
|
<Link
|
||||||
to={metadata.permalink}
|
to={metadata.permalink}
|
||||||
|
|
|
@ -12,3 +12,7 @@
|
||||||
.blogPostData {
|
.blogPostData {
|
||||||
font-size: 0.9rem;
|
font-size: 0.9rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.blogPostDetailsFull {
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
|
|
@ -12,13 +12,12 @@ import BlogPostPaginator from '@theme/BlogPostPaginator';
|
||||||
import type {Props} from '@theme/BlogPostPage';
|
import type {Props} from '@theme/BlogPostPage';
|
||||||
import BlogSidebar from '@theme/BlogSidebar';
|
import BlogSidebar from '@theme/BlogSidebar';
|
||||||
import TOC from '@theme/TOC';
|
import TOC from '@theme/TOC';
|
||||||
import EditThisPage from '@theme/EditThisPage';
|
|
||||||
import {ThemeClassNames} from '@docusaurus/theme-common';
|
import {ThemeClassNames} from '@docusaurus/theme-common';
|
||||||
|
|
||||||
function BlogPostPage(props: Props): JSX.Element {
|
function BlogPostPage(props: Props): JSX.Element {
|
||||||
const {content: BlogPostContents, sidebar} = props;
|
const {content: BlogPostContents, sidebar} = props;
|
||||||
const {frontMatter, metadata} = BlogPostContents;
|
const {frontMatter, metadata} = BlogPostContents;
|
||||||
const {title, description, nextItem, prevItem, editUrl} = metadata;
|
const {title, description, nextItem, prevItem} = metadata;
|
||||||
const {hide_table_of_contents: hideTableOfContents} = frontMatter;
|
const {hide_table_of_contents: hideTableOfContents} = frontMatter;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -40,11 +39,8 @@ function BlogPostPage(props: Props): JSX.Element {
|
||||||
isBlogPostPage>
|
isBlogPostPage>
|
||||||
<BlogPostContents />
|
<BlogPostContents />
|
||||||
</BlogPostItem>
|
</BlogPostItem>
|
||||||
<div>{editUrl && <EditThisPage editUrl={editUrl} />}</div>
|
|
||||||
{(nextItem || prevItem) && (
|
{(nextItem || prevItem) && (
|
||||||
<div className="margin-vert--xl">
|
|
||||||
<BlogPostPaginator nextItem={nextItem} prevItem={prevItem} />
|
<BlogPostPaginator nextItem={nextItem} prevItem={prevItem} />
|
||||||
</div>
|
|
||||||
)}
|
)}
|
||||||
</main>
|
</main>
|
||||||
{!hideTableOfContents && BlogPostContents.toc && (
|
{!hideTableOfContents && BlogPostContents.toc && (
|
||||||
|
|
|
@ -15,7 +15,7 @@ function BlogPostPaginator(props: Props): JSX.Element {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<nav
|
<nav
|
||||||
className="pagination-nav"
|
className="pagination-nav docusaurus-mt-lg"
|
||||||
aria-label={translate({
|
aria-label={translate({
|
||||||
id: 'theme.blog.post.paginator.navAriaLabel',
|
id: 'theme.blog.post.paginator.navAriaLabel',
|
||||||
message: 'Blog post page navigation',
|
message: 'Blog post page navigation',
|
||||||
|
|
|
@ -86,7 +86,7 @@ function DocItem(props: Props): JSX.Element {
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{(editUrl || lastUpdatedAt || lastUpdatedBy) && (
|
{(editUrl || lastUpdatedAt || lastUpdatedBy) && (
|
||||||
<footer className={clsx('row', styles.docUpdateDetails)}>
|
<footer className="row docusaurus-mt-lg">
|
||||||
<div className="col">
|
<div className="col">
|
||||||
{editUrl && <EditThisPage editUrl={editUrl} />}
|
{editUrl && <EditThisPage editUrl={editUrl} />}
|
||||||
</div>
|
</div>
|
||||||
|
@ -104,11 +104,9 @@ function DocItem(props: Props): JSX.Element {
|
||||||
)}
|
)}
|
||||||
</article>
|
</article>
|
||||||
|
|
||||||
<div className={styles.docPaginator}>
|
|
||||||
<DocPaginator metadata={metadata} />
|
<DocPaginator metadata={metadata} />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
{!hideTableOfContents && DocContent.toc && (
|
{!hideTableOfContents && DocContent.toc && (
|
||||||
<div className="col col--3">
|
<div className="col col--3">
|
||||||
<TOC toc={DocContent.toc} />
|
<TOC toc={DocContent.toc} />
|
||||||
|
|
|
@ -9,11 +9,6 @@
|
||||||
margin-top: 0;
|
margin-top: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.docUpdateDetails,
|
|
||||||
.docPaginator {
|
|
||||||
margin-top: 3rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.lastUpdated {
|
.lastUpdated {
|
||||||
margin-top: 0.2rem;
|
margin-top: 0.2rem;
|
||||||
font-style: italic;
|
font-style: italic;
|
||||||
|
|
|
@ -15,7 +15,7 @@ function DocPaginator(props: Props): JSX.Element {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<nav
|
<nav
|
||||||
className="pagination-nav"
|
className="pagination-nav docusaurus-mt-lg"
|
||||||
aria-label={translate({
|
aria-label={translate({
|
||||||
id: 'theme.docs.paginator.navAriaLabel',
|
id: 'theme.docs.paginator.navAriaLabel',
|
||||||
message: 'Docs pages navigation',
|
message: 'Docs pages navigation',
|
||||||
|
|
|
@ -19,3 +19,9 @@ body {
|
||||||
.main-wrapper {
|
.main-wrapper {
|
||||||
flex: 1 0 auto;
|
flex: 1 0 auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Docusaurus-specific utility classes */
|
||||||
|
|
||||||
|
.docusaurus-mt-lg {
|
||||||
|
margin-top: 3rem;
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue