code-hike / codehike

Marvellous code walkthroughs
https://codehike.org
MIT License
4.39k stars 135 forks source link

link annotation support target='_blank' #266

Open nekochan0122 opened 1 year ago

nekochan0122 commented 1 year ago

image

// link[7:14] https://codehike.org _blank <=== maybe can add this ( ?
const codehike = 'perfect'
brianespinosa commented 1 year ago

@NekoChanTaiwan it is possible to change the way links render in markdown using rehype/remark plugins. I think rehype-external-links would work for your use case. It would also give you a way to safely add the rel attribute, which is good to pay attention to for safety.

nekochan0122 commented 1 year ago

@NekoChanTaiwan it is possible to change the way links render in markdown using rehype/remark plugins. I think rehype-external-links would work for your use case. It would also give you a way to safely add the rel attribute, which is good to pay attention to for safety.

Idk why this plugin is not working 🥲 image

brianespinosa commented 1 year ago

Hmm. If you have this configured correctly, I'd have to go look at the code. It is possible that rehype is not processing comment metadata and that is being done manually in Codehike.

pomber commented 1 year ago

Yes, the rehype plugin won't work for this.

Before adding this feature we need a good syntax to pass options to annotations. Maybe something like this:

// link[7:14] https://codehike.org target=_blank title="lorem ipsum"

but I want to make sure it scales with more annotations and options before implementing it.