Skip to content

Commit ae814b3

Browse files
committed
add external and mail icons to links, fix link underlines
1 parent 1ec5db0 commit ae814b3

File tree

10 files changed

+40
-15
lines changed

10 files changed

+40
-15
lines changed

config/webc.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ export default function webcConfig(eleventyConfig) {
1919
// any `.webc` files found in the top-level of our `includes` directory
2020
// or in the `components` directory inside of our `includes` directory
2121
// will be processed as global webc components.
22-
components: `${config.dir.input}/${config.dir.includes}/components/*.webc`,
22+
components: [
23+
`${config.dir.input}/${config.dir.includes}/components/*.webc`,
24+
`${config.dir.input}/${config.dir.includes}/elements/*.webc`,
25+
],
2326
});
2427
}

links.md

+1
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
- [tailwindcss as a utility generator with eleventy](https://eleventy-excellent.netlify.app/blog/what-is-tailwind-css-doing-here/)
5555
- [tailwindcss v4 alpha](https://tailwindcss.com/blog/tailwindcss-v4-alpha#try-out-the-alpha)
5656
- [relevant 11ty Serverless plugin code that helped me figure out how to use the programmatic api to generate a page](https://github.com/11ty/eleventy/blob/v2.x/src/Serverless.js#L160)
57+
- [show all links to external pages from jim nielsen's blog](https://blog.jim-nielsen.com/about/external-links)
5758

5859
## webc
5960

src/_includes/components/main-nav.webc

+2-2
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,11 @@
6060

6161
& a {
6262
text-transform: lowercase;
63-
text-decoration: none;
63+
text-decoration-line: none;
6464
}
6565

6666
& a:is(:hover, :active, :focus-visible) {
67-
text-decoration: underline;
67+
text-decoration-line: underline;
6868
}
6969
}
7070

src/_includes/elements/img.webc

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<script webc:type='render'>
2+
function() {
3+
if (!this.alt) {
4+
throw new Error("Need to have an `alt` attribute for the <img> tag.");
5+
}
6+
return `<img src="${this.src}" alt="${this.alt}">`;
7+
}
8+
</script>

src/_includes/layouts/post.webc

+2-2
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,10 @@
8383

8484
& > a {
8585
color: var(--color-primary);
86-
text-decoration: none;
86+
text-decoration-line: none;
8787

8888
&:hover {
89-
text-decoration: underline;
89+
text-decoration-line: underline;
9090
}
9191
}
9292
}

src/index.webc

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44

55
<ul>
66
<li webc:for="link of socials">
7-
<a rel="noreferrer" :href="link.href" @text="link.text"></a>
7+
<a :href="link.href" @text="link.text"></a>
88
</li>
99
</ul>
1010

1111
<p>
1212
<span @text="p1[0]"></span>
13-
<a href="https://www.vincit.com" rel="noreferrer" @text="p1[1]"></a>
13+
<a href="https://www.vincit.com" @text="p1[1]"></a>
1414
<span @text="p1[2]"></span>
1515
</p>
1616
<p>

src/projects.webc

+10-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
<ul webc:if="projects.length > 0">
1111
<li webc:for="project of projects">
12-
<a :href='project.url' rel="noreferrer">
12+
<a :href='project.url'>
1313
<h2 @text='`~/${project.name}`'></h2>
1414
<p @text='project.description'></p>
1515
</a>
@@ -45,7 +45,15 @@
4545
padding: 0.6em 0.9em;
4646
margin-inline: -0.9em;
4747

48-
text-decoration: none;
48+
text-decoration-line: none;
49+
50+
/* disable icon on external link, but put it on the first child of the link */
51+
&:after {
52+
content: none;
53+
}
54+
&:first-child :after {
55+
content: ' \2197';
56+
}
4957

5058
&:focus-visible {
5159
outline-color: var(--color-primary);
@@ -55,7 +63,6 @@
5563

5664
h2 {
5765
font-size: var(--font-size-lg);
58-
5966
}
6067
&:hover h2 {
6168
color: var(--color-primary);

src/styles/base.css

+8-1
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,13 @@ a {
5454
color: var(--color-primary);
5555
}
5656
}
57+
/* show icons for external and mailto: links */
58+
a[href^='http']:after {
59+
content: ' \2197';
60+
}
61+
a[href^='mailto:']:after {
62+
content: ' \2709';
63+
}
5764

5865
/*
5966
* but if they're in an paragraph or are anchor links inside of a heading on one
@@ -71,7 +78,7 @@ a[data-anchor="true"] {
7178

7279
/* override tailwind default of no underline for links */
7380
a {
74-
text-decoration: underline;
81+
text-decoration-line: underline;
7582
text-decoration-thickness: 2px;
7683
}
7784
/* disable link underline by default if it's a direct child of a heading element */

src/styles/components.css

+3-3
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,12 @@ main {
3333

3434
a {
3535
font-size: var(--font-size-md);
36-
text-decoration: none;
36+
text-decoration-line: none;
3737
max-width: 32ch;
3838

3939
&:hover,
4040
&:focus-visible {
41-
text-decoration: underline;
41+
text-decoration-line: underline;
4242
}
4343
}
4444

@@ -74,7 +74,7 @@ main {
7474
var(--padding-block-size) + var(--padding-inline-size) +
7575
var(--tag-hole-punch-size)
7676
);
77-
text-decoration: none;
77+
text-decoration-line: none;
7878
position: relative;
7979
/* clips the element to match the ::before element's path, otherwise
8080
* the background color of this element will escape the bounds

src/words/drafts/tailwind-is-good-enough.md

-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ plugins: [
2424
## downsides/gripes
2525
- css grid kinda sucks with tailwind
2626
- to use the power of grid, you just need to use bespoke CSS (i.e. `grid-template-areas` and `grid-area: *`)
27-
-
2827
- logical properties support is half-assed
2928
- why don't you just update `ml-*` / `pt-*` / etc utilities under the hood to use logical properties ??
3029
- no `-block-` logical property utilities due to (understandable) naming collision with `-bottom` utilities

0 commit comments

Comments
 (0)