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

Add remark-prepend-url to list of plugins #1375

Merged
merged 1 commit into from
Oct 3, 2024
Merged

Conversation

alxjpzmn
Copy link
Contributor

@alxjpzmn alxjpzmn commented Oct 2, 2024

Initial checklist

  • I read the support docs
  • I read the contributing guide
  • I agree to follow the code of conduct
  • I searched issues and couldn’t find anything (or linked relevant results below)
  • If applicable, I’ve added docs and tests

Description of changes

Add remark-prepend-url to the plugin list.

@github-actions github-actions bot added 👋 phase/new Post is being triaged automatically 🤞 phase/open Post is being triaged manually and removed 👋 phase/new Post is being triaged automatically labels Oct 2, 2024
@codecov-commenter
Copy link

codecov-commenter commented Oct 2, 2024

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (a185821) to head (ea8e27c).
Report is 17 commits behind head on main.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff            @@
##              main     #1375   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            6         6           
  Lines          142       140    -2     
=========================================
- Hits           142       140    -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ChristianMurphy
Copy link
Member

Welcome @alxjpzmn 👋
Thanks for sharing

The types look a bit off, you may want to leverage @types/mdast
https://github.com/alxjpzmn/remark-prepend-url/blob/ab819c73f4c4dd01d044c8da2679c6cc8531b272/index.ts#L9-L10

The plugin will be passed a Root node, and once that is in place, your visit function should be able to infer it will be given an Link node without additional annotations.
See https://unifiedjs.com/learn/recipe/tree-traversal-typescript/ for reference

Useful if you're using a static site generator like Astro with .mdx files and you'd like to prepare them for a full-text RSS feed.

Is the intent that you want to modify the source markdown to have the absolute URL? (if so a remark plugin is good)
If you only want it to change the resulting HTML, you may want a rehype plugin.

@alxjpzmn
Copy link
Contributor Author

alxjpzmn commented Oct 2, 2024

Thanks for the quick review @ChristianMurphy & the pointer re: the types :)

Changed to @types/mdast and published a new release here.

Is the intent that you want to modify the source markdown to have the absolute URL? (if so a remark plugin is good)

For my personal use case (generating a XML file) rehype would work, but I think being able to modify the source markdown is more versatile. For example, if I author a markdown file with relative links and the desired output is not only HTML but also a e.g. PDF, I'd first want the source markdown to uniformly contain absolute links.

Copy link
Member

@ChristianMurphy ChristianMurphy left a comment

Choose a reason for hiding this comment

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

LGTM!

@wooorm wooorm merged commit 820e616 into remarkjs:main Oct 3, 2024
5 checks passed
@wooorm wooorm added 📚 area/docs This affects documentation 💪 phase/solved Post is done labels Oct 3, 2024

This comment has been minimized.

@wooorm
Copy link
Member

wooorm commented Oct 3, 2024

Thank you!

@github-actions github-actions bot removed the 🤞 phase/open Post is being triaged manually label Oct 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📚 area/docs This affects documentation 💪 phase/solved Post is done
Development

Successfully merging this pull request may close these issues.

5 participants