Skip to content

Dynamic code mention #518

Open
Open

Description

@genert

In previous CodeHike, it was possible to do the following:

<CH.Section>
Some text [hover here](focus://code.py#3)

```python code.py
def method():
    print("hello")
    print("world")
``

</CH.Section>

The current version has the following capability - https://codehike.org/docs/code/code-mentions

BUT it requires hard-coding the hover values in CSS styles. Is there a generic way for this as previous versions supported?

Activity

  1. pomber commented on May 19, 2025

    @pomber
    Contributor

    It's possible. The key is in the last paragraph of that page:

    If you need a more complex behavior, you could add a React Context Provider to the HoverContainer component and use it to store the current hover state. Then, you can use the useContext hook in the Line component to check if the current line is the one being hovered over.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions