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 external links class option to Markdown configuration #2717

Open
wants to merge 1 commit into
base: next
Choose a base branch
from

Conversation

welpo
Copy link
Contributor

@welpo welpo commented Nov 30, 2024

IMPORTANT: Please do not create a Pull Request adding a new feature without discussing it first.

The place to discuss new features is the forum: https://zola.discourse.group/
If you want to add a new feature, please open a thread there first in the feature requests section.

Sanity check:

  • Have you checked to ensure there aren't other open Pull Requests for the same update/change?

Code changes

(Delete or ignore this section for documentation changes)

  • Are you doing the PR on the next branch?

If the change is a new feature or adding to/changing an existing one:

  • Have you created/updated the relevant documentation page(s)?

Discussed in https://zola.discourse.group/t/style-internal-and-external-links-differently/1501/6.

This PR adds an optional external_links_class configuration option that allows adding a CSS class to all external links.

This makes it easier to style external links differently from internal ones, for example to add visual indicators for external links.

Example configuration:

[markdown]
external_links_class = "external"

with CSS:

a.external::after {
    display: inline-block;
    vertical-align: middle;
    mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cg fill='none' stroke='currentColor' stroke-linecap='round' stroke-linejoin='round' stroke-width='2'%3E%3Cpath d='M11 5h-6v14h14v-6'/%3E%3Cpath d='M13 11l7 -7'/%3E%3Cpath d='M21 3h-6M21 3v6'/%3E%3C/g%3E%3C/svg%3E");
    margin-left: 0.1em;
    background-color: currentColor;
    width: 1em;
    height: 1em;
    content: "";
}

It looks like:

external_links_class

Note: for the docs, I wasn't sure whether to do (same as author):

external_links_class =

or (make it super obvious it's a string):

external_links_class = ""

Opted for author format, for consistency.

Happy to make any necessary changes!

@welpo welpo changed the title Next version Add external links class option to Markdown configuration Nov 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant