Skip to content

[BUG] LeetCode Topic Tags Never Extracted β€” All Published Blogs Use Same 4 Hardcoded TagsΒ #170

@ayushi2577

Description

@ayushi2577

πŸ› Bug Description

Every blog post published by LeetLog AI β€” whether to Dev.to, Hashnode, or Medium β€” always uses the same 4 hardcoded tags:

This happens because content.js never extracts the topic tags from the LeetCode problem page (e.g. Array, Dynamic Programming, Binary Search, Two Pointers), so problem.tags is always null, and devto.py falls back to DEFAULT_TAGS every single time.

This kills discoverability β€” a Dynamic Programming blog tagged only as "tutorial" will never reach the right audience on Dev.to or Hashnode.


πŸ“ Root Cause (3 files)

1. extension/content.js β€” topic tags never extracted

The extension extracts title, description, code, difficulty, and author β€” but nothing reads the LeetCode topic tags from the DOM.

LeetCode renders topic tags as links in a dedicated section:

const tagElements = document.querySelectorAll('a[href*="/tag/"]');
const topics = Array.from(tagElements).map(el => el.innerText.trim().toLowerCase());

2. extension/background.js β€” tags not in destructured payload

// Line 16 β€” current code
const { title, description, code, author, client_time, custom_prompt, difficulty } = request.payload;

// tags is never destructured or forwarded to the backend

3. backend/devto.py β€” hardcoded fallback always wins

DEFAULT_TAGS = ["leetcode", "dsa", "programming", "tutorial"]

# In publish_to_platforms():
clean_tags = [
    tag.strip().lower().replace(" ", "-")
    for tag in (tags or DEFAULT_TAGS)  # tags is always None β†’ always DEFAULT_TAGS
    ...
]

πŸ” Steps to Reproduce

  1. Open any LeetCode problem (e.g. "Two Sum" β€” tagged: Array, Hash Table).
  2. Submit a solution and let LeetLog AI generate and publish a blog.
  3. Check the published article on Dev.to β€” tags will be leetcode, dsa, programming, tutorial instead of array, hash-table.

βœ… Expected Behavior

Tags extracted from the LeetCode problem page should flow through the full pipeline and be used when publishing. Hardcoded defaults should only apply if the problem has no tags at all.


πŸ’‘ Proposed Fix

content.js β€” extract topic tags:

const tagElements = document.querySelectorAll('a[href*="/tag/"]');
const topics = Array.from(tagElements)
    .map(el => el.innerText.trim().toLowerCase())
    .filter(Boolean)
    .slice(0, 4); // Dev.to allows max 4 tags

Include topics in the GENERATE_BLOG payload.

background.js β€” destructure and forward topics:

const { title, description, code, author, client_time, custom_prompt, difficulty, topics } = request.payload;
// then include topics in the fetch body as `tags: topics`

main.py β€” Problem.tags already exists, no model change needed βœ…


πŸ“Ž Additional Context

  • Affects: extension/content.js, extension/background.js, backend/devto.py
  • The Problem model in main.py already has a tags: list[str] | None field β€” the plumbing exists, it's just never filled.
  • No new dependencies required.
  • Fix also improves SEO and reach of published articles on all 3 supported platforms.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions