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:
Alexey Pyltsyn 2020-02-06 19:55:28 +03:00 committed by GitHub
parent 9b93416e53
commit b7a2ad2904
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 11 additions and 2 deletions

View file

@ -23,6 +23,9 @@
"react": "^16.8.4",
"react-dom": "^16.8.4"
},
"bundledDependencies": [
"@docusaurus/utils"
],
"engines": {
"node": ">=10.9.0"
}

View file

@ -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 &quot;{tagName}&quot;
{count} {pluralize(count, 'post')} tagged with &quot;{tagName}
&quot;
</h1>
<Link href={allTagsPath}>View All Tags</Link>
<div className="margin-vert--xl">

View file

@ -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';

View file

@ -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);
}