Git Product home page Git Product logo

hugo-notice's Introduction

hugo-notice

Awesome

About

A Hugo theme component providing a shortcode: notice to display nice notices, and supporting dark mode.

Several sets of icons are provided too: make your choice second your taste!

Four notice types are provided: warning, info, note and tip.

This component comes with localization in 18 languages: English, French, German, Italian, Portuguese, Spanish, Chinese, Russian, Turkish, Arabic, Polish, Finnish, Korean, Vietnamese, Swahili, Japanese, Chinese (Taiwan) and Swedish.

Other languages welcome! Send your pull request.

Screenshot

Installation

As a Hugo module

  1. Initialize your existing site as hugo module

    hugo mod init github.com/USERNAME/REPO
  2. Add the hugo-notice as a hugo module to be able to get upstream changes later

    hugo mod get github.com/martignoni/hugo-notice
  3. In your site's or theme's configuration file hugo.yaml or hugo.toml, add a new module section and define both hugo-notice and your currently used theme as modules to be imported.

    Example, with hugo.yaml:

    module:
      imports:
        - path: github.com/martignoni/hugo-notice
        - path: my-theme

    or, with hugo.toml,

    [module]
      [[module.imports]]
        path = "github.com/martignoni/hugo-notice"
      [[module.imports]]
        path = "my-theme"

As a Git submodule

  1. Add the hugo-notice as a submodule to be able to get upstream changes later git submodule add https://github.com/martignoni/hugo-notice.git themes/hugo-notice

  2. Add hugo-notice as the left-most element of the theme list variable in your site's or theme's configuration file hugo.yaml or hugo.toml.

    Example, with hugo.yaml:

    theme: ["hugo-notice", "my-theme"]

    or, with hugo.toml,

    theme = ["hugo-notice", "my-theme"]

Usage

In your site, use the shortcode, this way:

{{< notice warning >}}
This is a warning notice. Be warned!
{{< /notice >}}

or

{{< notice tip >}}
This is a very good tip.
{{< /notice >}}

Enabling dark mode

We recommend that you use the standard prefers-color-scheme CSS media feature to detect if a user has requested light or dark color themes. In this case, dark mode will work automatically. The prefers-color-scheme media feature is fully supported by all modern browsers.

Another way to make it work is to inject (e.g. via Javascript) the class dark into the body element of your pages when dark mode is needed.

Changing icon set

Just copy the icons from one of the subfolders of folder icons/ into folder icons/.

Any solid SVG icons can be used. If you want to contribute your open licensed icons, your pull request is welcome.

Acknowledgements

Copyright © 2019 onwards, Nicolas Martignoni [email protected].

Localization

Thanks to

Development

Thanks to

  • Gary Tai for raising a nasty spacing bug.
  • Dephilia for suggesting and implementing dark mode.
  • RoneoOrg for implementing default notice type.
  • Andreas Deininger for installation as a Hugo module How To.
  • rea1shane for suggesting and implementing a few useful features.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.