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

No javascript for emoji styling #26

Open
8hantanu opened this issue Feb 2, 2025 · 0 comments
Open

No javascript for emoji styling #26

8hantanu opened this issue Feb 2, 2025 · 0 comments
Labels
enhancement New feature or request

Comments

@8hantanu
Copy link
Collaborator

8hantanu commented Feb 2, 2025

Currently the emojis are custom styled with the Noto Emoji font.

When the page is loaded the emojis are wrapped in a span with class emoji and then the css styling is applied.

In _layouts/default.html

<script>
  document.addEventListener('DOMContentLoaded', () => {
    const emojiRegex = /([\u{1F600}-\u{1F64F}\u{1F300}-\u{1F5FF}\u{1F680}-\u{1F6FF}\u{1F700}-\u{1F77F}\u{1F900}-\u{1F9FF}\u{2600}-\u{26FF}\u{2700}-\u{27BF}\u{2702}\u{1F004}\u{1F0CF}\u{1F191}-\u{1F251}\u{1F1E6}-\u{1F1FF}\u{200D}\u{2620}\u{26A7}\u{FE0F}\u{1F308}\u{1F38C}\u{1F3C1}\u{1F3F3}-\u{1F3F4}\u{1F6A9}\u{E0062}-\u{E007F}\u{1FA00}-\u{1FAFF}])/gu;
    document.body.innerHTML = document.body.innerHTML.replace(emojiRegex, '<span class="emoji">$1</span>');
  });
</script>

In _sass/mold.scss

.emoji {
  font-family: 'Noto Emoji', sans-serif;
  font-weight: 400;
}

Find a way to do this without JS. One option could be to do this emoji-span-wrap during static site generation step, but find a css only way.

@8hantanu 8hantanu added the enhancement New feature or request label Feb 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant