Skip to content

Conversation

@nattsw
Copy link
Contributor

@nattsw nattsw commented Dec 14, 2025

Currently in several endpoints (topic list, sidebar, etc), we return an array of strings for tags, e.g. topic_list.top_tags = ["tag-name1", "tag-name2"].

This PR expands tag attributes in various places to return an array of tag objects e.g. [{ id: 123, name: "tag-name1" }, { id:213, name: "tag-name2" }]. This allows us to return more information regarding a tag, and reference a tag by its id rather than the name which can be edited.

At the same time, we keep compatibility in places where an array of strings are used. In time we will retire this backward compatibility.

(need to find best way to add warning)

get tagClassNames() {
return this.args.topic.tags?.map((tagName) => `tag-${tagName}`);
return this.args.topic.tags?.map((tag) => {
const tagName = typeof tag === "string" ? tag : tag.name;
Copy link
Contributor Author

@nattsw nattsw Dec 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Locally, I have this prepended in all the frontend files affected

      if (typeof tag === "string") {
        // print the trace here so we know who is violating
        console.warn(
          `Topic tag is a string (${tag}) - this will be deprecated soon. Please pass tag objects instead.`
        );
        console.warn(new Error().stack);
      }

But am thinking of a better way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants