mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-02 19:57:25 +02:00
feat(v2): pluralize posts on tag's page (#2263)
* feat(v2): pluralize posts on tag's page * FIx ESlint error for import/no-extraneous-dependencies rule * Move pluralize method to theme scope * Fix import
This commit is contained in:
parent
9b93416e53
commit
b7a2ad2904
4 changed files with 11 additions and 2 deletions
|
@ -23,6 +23,9 @@
|
|||
"react": "^16.8.4",
|
||||
"react-dom": "^16.8.4"
|
||||
},
|
||||
"bundledDependencies": [
|
||||
"@docusaurus/utils"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=10.9.0"
|
||||
}
|
||||
|
|
|
@ -11,6 +11,10 @@ import Layout from '@theme/Layout';
|
|||
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: tagName, count} = metadata;
|
||||
|
@ -23,7 +27,8 @@ function BlogTagsPostPage(props) {
|
|||
<div className="row">
|
||||
<div className="col col--8 col--offset-2">
|
||||
<h1>
|
||||
{count} post(s) tagged with "{tagName}"
|
||||
{count} {pluralize(count, 'post')} tagged with "{tagName}
|
||||
"
|
||||
</h1>
|
||||
<Link href={allTagsPath}>View All Tags</Link>
|
||||
<div className="margin-vert--xl">
|
||||
|
|
|
@ -11,7 +11,7 @@ import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
|
|||
import useBaseUrl from '@docusaurus/useBaseUrl';
|
||||
import useLockBodyScroll from '@theme/hooks/useLockBodyScroll';
|
||||
import Link from '@docusaurus/Link';
|
||||
import isInternalUrl from '@docusaurus/utils'; // eslint-disable-line import/no-extraneous-dependencies
|
||||
import isInternalUrl from '@docusaurus/utils';
|
||||
|
||||
import styles from './styles.module.css';
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
export default function isInternalUrl(url) {
|
||||
return /^\/(?!\/)/.test(url);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue