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

How can I get icons directly from icons.svg or icons.json? #72

Open
DuoZhangRobotics opened this issue Dec 13, 2022 · 0 comments
Open

Comments

@DuoZhangRobotics
Copy link

I am trying to add a button in the menu to switch dark mode and light mode, and I want to use the moon icon in font-awesome. Thus I changed menu.html to the following:

<nav>
  {%- for item in include.menu -%}
  {%- assign node = site.pages | where: "name", item.file | first -%}
  {%- assign url = item.url | default: node.url -%}
  {%- assign title = item.title | default: node.title -%}
  <a href="{{ url | relative_url }}" {% if url==page.url %}class="selected" {% endif %}>
    {%- if item.icon -%}<svg aria-label="{{ title }}" class="icon">
      <use xlink:href="{{ "/assets/fontawesome/icons.svg" | relative_url }}#{{ item.icon }}"></use>
    </svg>{%- else -%}{{ title }}{%- endif -%}
  </a>
  {%- endfor -%}
  <a class="dark-mode-button">
    <svg class="icon">
      <use xlink:href="/assets/fontawesome/icons.svg#moon"></use>
    </svg>
  </a>
</nav>

But I cannot get the icon from it. I am really not sure about how to get the icon by just reading the json file.

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

No branches or pull requests

1 participant