Skip to content

Commit

Permalink
Refactor a bit theme code and CSS
Browse files Browse the repository at this point in the history
  • Loading branch information
slorber committed Mar 15, 2024
1 parent 718c7c3 commit cb7a7ee
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 73 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ module.exports = {
'no-constant-binary-expression': ERROR,
'no-continue': OFF,
'no-control-regex': WARNING,
'no-else-return': [WARNING, {allowElseIf: true}],
'no-else-return': OFF,
'no-empty': [WARNING, {allowEmptyCatch: true}],
'no-lonely-if': WARNING,
'no-nested-ternary': WARNING,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ import EditMetaRow from '@theme/EditMetaRow';
import TagsListInline from '@theme/TagsListInline';
import ReadMoreLink from '@theme/BlogPostItem/Footer/ReadMoreLink';

import styles from './styles.module.css';

export default function BlogPostItemFooter(): JSX.Element | null {
const {metadata, isBlogPostPage} = useBlogPost();
const {
Expand All @@ -37,41 +35,56 @@ export default function BlogPostItemFooter(): JSX.Element | null {
return null;
}

const canDisplayEditMetaRow = !!(editUrl || lastUpdatedAt || lastUpdatedBy);

return (
<footer
className={clsx(
'row docusaurus-mt-lg',
isBlogPostPage && styles.blogPostFooterDetailsFull,
)}>
{tagsExists && (
<div className={clsx('col', {'col--9': truncatedPost})}>
<TagsListInline tags={tags} />
</div>
)}

{!truncatedPost && canDisplayEditMetaRow && (
<EditMetaRow
className={clsx(
'col margin-top--sm',
ThemeClassNames.blog.blogFooterEditMetaRow,
styles.blogFooterPagePadding,
)}
editUrl={editUrl}
lastUpdatedAt={lastUpdatedAt}
lastUpdatedBy={lastUpdatedBy}
/>
)}
// BlogPost footer - details view
if (isBlogPostPage) {
const canDisplayEditMetaRow = !!(editUrl || lastUpdatedAt || lastUpdatedBy);

{truncatedPost && (
<div
className={clsx('col text--right', {
'col--3': tagsExists,
})}>
<ReadMoreLink blogPostTitle={title} to={metadata.permalink} />
</div>
)}
</footer>
);
return (
<footer className="docusaurus-mt-lg">
{tagsExists && (
<div
className={clsx(
'row',
'margin-top--sm',
ThemeClassNames.blog.blogFooterEditMetaRow,
)}>
<div className="col">
<TagsListInline tags={tags} />
</div>
</div>
)}
{canDisplayEditMetaRow && (
<EditMetaRow
className={clsx(
'margin-top--sm',
ThemeClassNames.blog.blogFooterEditMetaRow,
)}
editUrl={editUrl}
lastUpdatedAt={lastUpdatedAt}
lastUpdatedBy={lastUpdatedBy}
/>
)}
</footer>
);
}
// BlogPost footer - list view
else {
return (
<footer className="row docusaurus-mt-lg">
{tagsExists && (
<div className={clsx('col', {'col--9': truncatedPost})}>
<TagsListInline tags={tags} />
</div>
)}
{truncatedPost && (
<div
className={clsx('col text--right', {
'col--3': tagsExists,
})}>
<ReadMoreLink blogPostTitle={title} to={metadata.permalink} />
</div>
)}
</footer>
);
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,10 @@ import React from 'react';
import clsx from 'clsx';
import {ThemeClassNames} from '@docusaurus/theme-common';
import {useDoc} from '@docusaurus/theme-common/internal';
import TagsListInline, {
type Props as TagsListInlineProps,
} from '@theme/TagsListInline';
import TagsListInline from '@theme/TagsListInline';

import EditMetaRow from '@theme/EditMetaRow';

function TagsRow(props: TagsListInlineProps) {
return (
<div
className={clsx(
ThemeClassNames.docs.docFooterTagsRow,
'row margin-bottom--sm',
)}>
<div className="col">
<TagsListInline {...props} />
</div>
</div>
);
}

export default function DocItemFooter(): JSX.Element | null {
const {metadata} = useDoc();
const {editUrl, lastUpdatedAt, lastUpdatedBy, tags} = metadata;
Expand All @@ -45,10 +29,23 @@ export default function DocItemFooter(): JSX.Element | null {
return (
<footer
className={clsx(ThemeClassNames.docs.docFooter, 'docusaurus-mt-lg')}>
{canDisplayTagsRow && <TagsRow tags={tags} />}
{canDisplayTagsRow && (
<div
className={clsx(
'row margin-top--sm',
ThemeClassNames.docs.docFooterTagsRow,
)}>
<div className="col">
<TagsListInline tags={tags} />
</div>
</div>
)}
{canDisplayEditMetaRow && (
<EditMetaRow
className={clsx(ThemeClassNames.docs.docFooterEditMetaRow)}
className={clsx(
'margin-top--sm',
ThemeClassNames.docs.docFooterEditMetaRow,
)}
editUrl={editUrl}
lastUpdatedAt={lastUpdatedAt}
lastUpdatedBy={lastUpdatedBy}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ export const ThemeClassNames = {
},
blog: {
// TODO add other stable classNames here
blogFooterTagsRow: 'theme-blog-footer-tags-row',
blogFooterEditMetaRow: 'theme-blog-footer-edit-meta-row',
},
} as const;
4 changes: 3 additions & 1 deletion website/docusaurus.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,9 @@ export default async function createConfigAsync() {
result = result.replaceAll('{/_', '{/*');
result = result.replaceAll('_/}', '*/}');

if (isDev) {
const showDevLink = false;

if (isDev && showDevLink) {
const isPartial = path.basename(filePath).startsWith('_');
if (!isPartial) {
// "vscode://file/${projectPath}${filePath}:${line}:${column}",
Expand Down

0 comments on commit cb7a7ee

Please sign in to comment.