Skip to content

Commit 72feda8

Browse files
committed
22.0 RTW
[index] - fix socials hover style - fix sections event listeners in all platforms [projects] - add missing techs to some projects [til] - new entry: ios-event-bubbling - minor fixes and style changes
1 parent 3e3903f commit 72feda8

12 files changed

Lines changed: 120 additions & 42 deletions

File tree

assets/icons/tech/json.svg

Lines changed: 1 addition & 0 deletions
Loading

package.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/content/collections/projects/dotfiles.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
title: dotfiles
33
desc: "personal themes, configs and tweaks for my linux setups"
44
source: https://github.com/miermontoto/dotfiles
5-
icons: [fedora]
5+
icons: [fedora, linux]
66
emoji: 🐧
77
---

src/content/collections/projects/mier.info.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,11 @@
22
title: mier.info
33
desc: my personal portfolio, the very website you are looking at right now.
44
source: https://github.com/miermontoto/mier.info
5-
icons: [eleventy, firebase, sass, markdown, nunjucks, js]
6-
# links: [{icon: "β", url: "https://mier-f6277--beta-ms6exjco.web.app/", name: "beta"}]
5+
icons: [eleventy, firebase, sass, markdown, nunjucks, js, json]
76
star: star
87
permalink: /this/
98
redirect_from: [/mier.info/, /self/]
109
emoji: 🌐
11-
# buttons: [
12-
# {img: "β ", url: "https://mier-f6277--beta-ms6exjco.web.app/", text: "beta"}
13-
# ]
1410
eleventyNavigation:
1511
key: this
1612
title: mier.info

src/content/collections/projects/quizzes.njk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: quizzes
33
emoji: 📝
44
permalink: /quizzes/
55
lang: es
6-
icons: [eleventy, js]
6+
icons: [eleventy, js, json]
77
desc: quizzes for different uni courses.
88
eleventyNavigation:
99
key: quizzes

src/content/collections/projects/til.njk

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,16 @@ title: til
33
emoji: ❔
44
desc: collection of general questions I've asked myself over time
55
subtitle: inspired by <a href="https://til.simonwillison.net/" target="_blank">Simon Willison's TIL</a>
6-
icons: [eleventy, markdown]
6+
icons: [eleventy, markdown, js]
77
permalink: /til/
88
eleventyNavigation:
99
key: til
1010
---
1111

1212
{% addStyle 'til' %}
1313

14+
{# TODO: search bar #}
15+
1416
<div id="til-tags">
1517
<h2>tags</h2>
1618
{% tilTags collections.til %}

src/content/collections/til/eleventy-package.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,19 @@ eleventyNavigation:
66
keywords: ["eleventy", "package.json", "shortcodes", "package", "json"]
77
---
88

9-
For a long time now, I've been using a custom shortcode in Eleventy through the
9+
for a long time now, I've been using a custom shortcode in Eleventy through the
1010
configuration file (`.eleventy.js`) to access the `package.json` file. This is
1111
useful for various reasons, such as displaying the version number of the package
1212
or the using the package's keywords in the metadata of the website.
1313

14-
Because I was directly accessing the `package.json` file, I had to import it
15-
using `require`:
14+
because I was directly accessing the `package.json` file, I had to import it
15+
using `require` like so:
1616

1717
```js
1818
let json = require('./package.json');
1919
```
2020

21-
This works fine, but restricts the definition of the shortcode to the config
21+
this works fine, but restricts the definition of the shortcode to the config
2222
file itself, which is not ideal. I wanted to separate the shortcode from the
2323
config file so that it's easier to manage and maintain.
2424

@@ -31,7 +31,7 @@ eleventyConfig.addShortcode("version", () => {
3131
});
3232
```
3333

34-
While browsing the Eleventy documentation, I came across the
34+
while browsing the Eleventy documentation, I came across the
3535
*Eleventy Supplied Data*. In it, I found that the content of the `package.json`
3636
file is available through the `pkg` data value in the template files. This
3737
means that I can access the `package.json` file directly in the template files
@@ -41,7 +41,7 @@ without having to import it in the configuration file:
4141
{% raw %}{% pkg.version %}{% endraw %}
4242
```
4343

44-
This is a much cleaner way to access the version number of the package, and as
44+
this is a much cleaner way to access the version number of the package, and as
4545
such I can migrate the function for the shortcode to a separate script file:
4646

4747
```js
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
---
2+
title: "why click events do not work on iOS"
3+
tags: ["ios", "html", "javascript"]
4+
eleventyNavigation:
5+
key: "ios-event-bubbling"
6+
keywords: ["ios", "html", "javascript", "event bubbling", "event delegation", "event propagation", "event handling"]
7+
---
8+
9+
recently, while preparing the 22.0 release of this website, I noticed that the
10+
click events on the index page were not working on Apple devices, and as
11+
such the navigation flow was completely broken. This issue was not present on
12+
any other platform that I tested, including other mobile devices and desktop
13+
browsers.
14+
15+
after some quick searches and tests, I found out that the issue was related to
16+
the way iOS handles click events, and it is a known "bug" that has been around
17+
for a while. The problem is that iOS does not handle click events as expected,
18+
and as such, the event delegation mechanism that works on other platforms does
19+
not work on iOS.
20+
21+
the issue is related to the way iOS handles the `click` event, and it is
22+
documented in the [Apple Developer Documentation](https://developer.apple.com/library/archive/documentation/AppleApplications/Reference/SafariWebContent/HandlingEvents/HandlingEvents.html).
23+
24+
here is the *"offending"* code that was causing the issue:
25+
26+
```javascript
27+
sections.forEach(({ button, section }) => {
28+
window.addEventListener('click', (event) => { /* ... */ });
29+
});
30+
```
31+
32+
after some investigation (and Claude's help), I found out that the issue was
33+
related to [*event bubbling*](https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Building_blocks/Events#event_bubbling_and_capture). By simply moving the event listener from the
34+
`window` object to the `document` object and flipping the loop to iterate over
35+
the sections last, the issue was fixed.
36+
37+
here is the updated code that works on all platforms:
38+
39+
```javascript
40+
document.addEventListener('click', (event) => {
41+
sections.forEach(({ button, section }) => { /* ... */ });
42+
});
43+
```
44+
45+
Claude also suggested some other changes to the code, such as introducing
46+
`preventDefault()` for certain events, using `touchend` along with `click` for
47+
better compatibility, and the mentioned change of the loop order, avoiding the
48+
addition of separate event listeners.
49+
50+
*Thanks, Claude!*
51+
52+
<br>
53+
54+
### references
55+
56+
- [Apple Developer Documentation](https://developer.apple.com/library/archive/documentation/AppleApplications/Reference/SafariWebContent/HandlingEvents/HandlingEvents.html)
57+
- [MDN: Event Bubbling and Capture](https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Building_blocks/Events#event_bubbling_and_capture)
58+
- [QuircksMode: Click event delegation on iOS](https://www.quirksmode.org/blog/archives/2010/09/click_event_delegation.html)
59+
- [SitePoint: Handling .click() in the Safari browser](https://www.sitepoint.com/community/t/handling-click-in-the-safari-browser/417837)

src/content/collections/til/pdf-count.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ eleventyNavigation:
66
keywords: ["puppeteer", "pdf", "page count", "number of pages", "chromium", "wkhtmltopdf"]
77
---
88

9-
In Okticket, we are building a serverless service that generates PDF from HTML.
9+
in Okticket, we are building a serverless service that generates PDF from HTML.
1010
This feature was previously implemented using `wkhtmltopdf`,
1111
but we are migrating to Puppeteer for better performance and stability, as
1212
the previous engine is severely outdated and clogs up the API when under heavy
@@ -17,7 +17,7 @@ HTML content generated by the API using Blade templates. In this process, some
1717
specific features are required, such as the ability to get the number of pages
1818
in the generated PDF.
1919

20-
[After a quick search](https://github.com/puppeteer/puppeteer/issues/9550),
20+
[after a quick search](https://github.com/puppeteer/puppeteer/issues/9550),
2121
the seemingly most straightforward way to get the number of pages in a PDF
2222
generated by Puppeteer is to use a pdf library to read the file and count the
2323
pages. However, this approach is far from ideal, as we would need to render the
@@ -32,7 +32,7 @@ const pageCount = pdfDoc.getPages().length;
3232
this.logger.debug(`PDF has ${pageCount} pages`);
3333
```
3434

35-
However, [Puppeteer has built-in style classes](https://github.com/puppeteer/puppeteer/issues/5345)
35+
however, [Puppeteer has built-in style classes](https://github.com/puppeteer/puppeteer/issues/5345)
3636
that inject certain information in the PDF, including the page count:
3737

3838
- <b><code>pageNumber</code></b>: current page number.
@@ -41,6 +41,6 @@ that inject certain information in the PDF, including the page count:
4141
- <code>title</code>: title of the document.
4242
- <code>url</code>: URL of the document.
4343

44-
Replacing the built-in classes of `wkhtmltopdf` with Puppeteer's classes in the
44+
replacing the built-in classes of `wkhtmltopdf` with Puppeteer's classes in the
4545
blade templates allows us to get the page count directly from the PDF without
4646
the need to render it twice, cutting the processing time in half!

src/static/css/app/til.sass

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,6 @@
1515
font-size: 0.9em
1616
font-style: italic
1717
color: lightgray
18+
19+
.til-card
20+
margin: 1em 0

0 commit comments

Comments
 (0)