GetPublii / Publii

The most intuitive Static Site CMS designed for SEO-optimized and privacy-focused websites.
https://getpublii.com
GNU General Public License v3.0
6.35k stars 420 forks source link

[Feature Request]: Support for classes for LINKS in posts/pages editors #1675

Open bjazmoore opened 2 months ago

bjazmoore commented 2 months ago

Feature Description

It would be nice to be able to give a class to links that are added to a page or post through the Insert/Edit link dialog. This would allow some links to be styled if desired (perhaps as a button) in the post/page. Ideally it would be an extra field on the Insert/Edit link dialog: 1

bjazmoore commented 2 months ago

I found I can target these links using the Link "title" attribute, so this is not a super high priority need for me.

For those who want to use CSS and the "title" attribute to target a link for styling try the following:

  1. Give the link a unique title - I used "make_btn"
  2. In my case the link was also an H2 element
  3. Add come custom CSS

`a[title="make_btn"] { / Basic button styling / display: inline-block; padding: 20px 80px; text-decoration: none !important; border-radius: 40px; / Large value for pill shape /

/ Color and text styling / background-color: royalblue; color: white !important; font-weight: bold;

/ Transition for smooth hover effect / transition: background-color 0.3s ease; }

a[title="make_btn"]:hover { / Lighter shade of blue on hover / background-color: navy; / Cornflower Blue, a lighter shade / }`

It looks like this:

1

bjazmoore commented 2 months ago

There is still a problem with the approach shown above. The tooltip for the link says "make_btn" which is less than optimal.

So there is still a need to be able to add a class to style a link as a button.

Thanks

dziudek commented 1 month ago

@bjazmoore - sounds like a good idea - I will add it in v.0.46.2 or in v.0.47

bjazmoore commented 1 month ago

@bjazmoore - sounds like a good idea - I will add it in v.0.46.2 or in v.0.47

Thank you.

gpsblues commented 2 weeks ago

Hi,

Currently, you can use a small hack in the title field to speed up adding a class, but it can only be modified later through code:

my-title" class="my-class The result is:

<a href="#" title="my-title" class="my-class">

A class field would be a great feature addition, as adding custom classes directly in the TinyMCE editor is a bit more tedious and less flexible.