Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Older/newer posts label in blog plugin should be configurable #7250

Closed
2 of 7 tasks
wgruszczyk opened this issue Apr 27, 2022 · 7 comments
Closed
2 of 7 tasks

Older/newer posts label in blog plugin should be configurable #7250

wgruszczyk opened this issue Apr 27, 2022 · 7 comments
Labels
closed: wontfix A fix will bring significant overhead, or is out of scope (for feature requests) feature This is not a bug or issue with Docusausus, per se. It is a feature request for the future.

Comments

@wgruszczyk
Copy link

Have you read the Contributing Guidelines on issues?

Prerequisites

  • I'm using the latest version of Docusaurus.
  • I have tried the npm run clear or yarn clear command.
  • I have tried rm -rf node_modules yarn.lock package-lock.json and re-installing packages.
  • I have tried creating a repro with https://new.docusaurus.io.
  • I have read the console error message carefully (if applicable).

Description

Older/newer posts label in blog plugin should be configurable. If you want to use the blog engine to post other content (like release notes), the term 'post' becomes irrelevant in this context.

Reproducible demo

No response

Steps to reproduce

Expected behavior

Configuration option (as described in https://docusaurus.io/docs/api/plugins/@docusaurus/plugin-content-blog) should be possible.

Actual behavior

Not configurable.

Your environment

  • Public source code:
  • Public site URL:
  • Docusaurus version used:
  • Environment name and version (e.g. Chrome 89, Node.js 16.4):
  • Operating system and version (e.g. Ubuntu 20.04.2 LTS):

Self-service

  • I'd be willing to fix this bug myself.
@wgruszczyk wgruszczyk added bug An error in the Docusaurus core causing instability or issues with its execution status: needs triage This issue has not been triaged by maintainers labels Apr 27, 2022
@Josh-Cena
Copy link
Collaborator

Please either use swizzle or translations to do this. See https://docusaurus.io/docs/next/swizzling#do-i-need-to-swizzle

@Josh-Cena Josh-Cena added feature This is not a bug or issue with Docusausus, per se. It is a feature request for the future. closed: wontfix A fix will bring significant overhead, or is out of scope (for feature requests) and removed bug An error in the Docusaurus core causing instability or issues with its execution status: needs triage This issue has not been triaged by maintainers labels Apr 27, 2022
@wgruszczyk
Copy link
Author

@Josh-Cena The actual problem is that I am using two blogs in parallel on one site. In the actual blog I want to keep it as it is, yet in the other I need to have it translated. Would it be possible to configure it this way ootb?

@Josh-Cena
Copy link
Collaborator

Errr... So, it's kinda complicated. We actually also have a blog purposed as release notes on our site: https://docusaurus.io/changelog However, it's heavily customized, and we've "swizzled" pretty much every component of the blog plugin.

The best way is to create a separate BlogPostPage component (you can use swizzle to eject the component, but don't put it in src/theme), and then use the blogPostComponent option to point to this custom component. This way, you can decouple the two plugins' theme components from each other. Then you can import BlogPostPaginator from a custom component instead of @theme/BlogPostPaginator.

I'm not sure if we necessarily want to offer another option just to customize the text label, provided this is a super niche use-case.

@wgruszczyk
Copy link
Author

I get the point. Maybe making your own change-log a re-usable plugin would be a cool feature? To be honest this is the first thing I was looking for. Thank you for the quick feedback!

@Josh-Cena
Copy link
Collaborator

We've seen quite a few people re-purposing the blog plugin for other stuff, like wikis or digital gardens. We'd like to collect more use-cases, and maybe make dedicated content plugins for each. For now, anything outside of blogging itself is unlikely to get first-class support (which I think you can understand).

As for exposing our own changelog plugin—maybe not a bad idea! We can think about it after the v2 release. Right now, it's mostly a hack.

@slorber
Copy link
Collaborator

slorber commented Apr 27, 2022

You can try this conditional logic after swizzling the component:

import useRouteContext from '@docusaurus/useRouteContext';

export default function BlogListPaginator(props: Props): JSX.Element {
  const isReleaseNotes = useRouteContext().plugin.id === "release-notes"

  return (
       isReleaseNotes ? 
            <Translate
                id="MY_ID">
                MY_CUSTOM_MESSAGE
            </Translate>
		       : 
            <Translate
                id="theme.blog.paginator.olderEntries"
                description="The label used to navigate to the older blog posts page (next page)">
                Older Entries
            </Translate>
     );
}

useRouteContext is experimental/undocumented for now but we'll likely keep this feature even if it's refactored.

You can also use useLocation().pathname.startsWith("/release-notes/") or whatever else makes sense for your use-case

@wgruszczyk
Copy link
Author

Thank you for the hints! Probably at the moment the most sensible and safe solution will be to translate it permanently to something more general like Next/Previous.

@Josh-Cena Josh-Cena closed this as not planned Won't fix, can't repro, duplicate, stale May 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed: wontfix A fix will bring significant overhead, or is out of scope (for feature requests) feature This is not a bug or issue with Docusausus, per se. It is a feature request for the future.
Projects
None yet
Development

No branches or pull requests

3 participants