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

FEATURE: Add custom title to top-contributors block #48

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ You can control some features for the provided blocks via parameters.
| id | leaderboard id | | number | minimal-gamification-leaderboard |
| tag | which tag to display | | tag id | tag-topics |
| period | time period of top topics | weekly | all, yearly, quarterly, monthly, weekly, daily | top-topics |
| title | title of the block | varies | string | tag-topics, category-list |
| title | title of the block | varies | string | tag-topics, category-list, top-contributors |
| excludedGroupNames | Excludes specified groups | | Group names | top-contributors |
| order | Orders the contributors | likes_received | String (likes_received or likes_given) | top-contributors |
| period | Time period for top contributors | yearly | all, yearly, quarterly, monthly, weekly, daily | top-contributors |
| period | Time period for top contributors | yearly | all, yearly, quarterly, monthly, weekly, daily | top-contributors |
3 changes: 3 additions & 0 deletions javascripts/discourse/components/top-contributors.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Component from "@glimmer/component";
import { ajax } from "discourse/lib/ajax";
import { tracked } from "@glimmer/tracking";
import I18n from "I18n";

export default class TopContributors extends Component {
@tracked topContributors = null;
Expand All @@ -11,6 +12,8 @@ export default class TopContributors extends Component {

constructor() {
super(...arguments);
this.blockTitle =
this.args?.params?.title || I18n.t(themePrefix("top_contributors.heading"));

ajax(this.requestURL).then((data) => {
this.topContributors = data.directory_items?.slice(0, this.count);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<h3 class="top-contributors-heading">
{{theme-i18n "top_contributors.heading"}}
{{blockTitle}}
</h3>

<div class="top-contributors--container">
Expand Down Expand Up @@ -30,4 +30,4 @@
href={{this.viewAllUrl}}
>
{{theme-i18n "top_contributors.view_all"}}
</a>
</a>