Giter Site home page Giter Site logo

hexo-tag-swiper's Introduction

hexo-tag-swiper

using swiperjs in Hexo posts/pages

Installation

npm install --save hexo-tag-swiper

Usage

{% swiper %}
  {% swiperItem %}
    content1
  {% endswiperItem %}
  {% swiperItem %}
    content2
  {% endswiperItem %}
  {% swiperItem %}
    content2
  {% endswiperItem %}
{% endswiper %}

or

{% swiper %}
  {% swiperImageItem [url] [ratio = 1.77778] %}
  {% swiperImageItem [url] [ratio = 1.77778] %}
{% endswiper %}

see the demo page

Configuration

You can configure the jsUrl, cssUrl in your main _config.yml:

Example configuration:

swiper:
  jsUrl: "https://cdn.jsdelivr.net/npm/swiper@9/swiper-bundle.min.js"  // default is "https://cdn.jsdelivr.net/npm/swiper@9/swiper-bundle.min.js"
  cssUrl: "https://cdn.jsdelivr.net/npm/swiper@9/swiper-bundle.min.css"  // default is "https://cdn.jsdelivr.net/npm/swiper@9/swiper-bundle.min.css"

Style

there are some custom style for swiper.

Built-in global css

:root {
  --swiper-navigation-size: 1.25em;
}

.swiper {
  margin-bottom: 20px;
}

.swiper-slide {
  box-sizing: border-box;
  padding: 0 calc(var(--swiper-navigation-size) / 44 * 27 + 2 * var(
          --swiper-navigation-sides-offset,
          10px
        ) + 6px);
}

.swiper-button-wrapper {
  position: absolute;
  z-index: 10;
  top: 0;
  bottom: 0;
  width: calc(
    var(--swiper-navigation-size) / 44 * 27 + 2 * var(
        --swiper-navigation-sides-offset,
        10px
      ) + 6px
  );
  background-color: var(--content-bg-color);
}

.swiper-button-wrapper.swiper-button-wrapper-prev {
  left: 0;
}

.swiper-button-wrapper.swiper-button-wrapper-next {
  right: 0;
}

Built-in next theme css

:root {
  --swiper-theme-color: var(--theme-color);
}

.swiper .swiper-slide .swiper-slide-img {
  display: block;
  width: 100%;
  object-fit: contain;
  background: var(--body-bg-color);
  margin: 0;
}

if your theme is not next, you can write extra style to adapt it in scripts folder, such as:

// scripts/swiper.theme.js
hexo.extend.injector.register("body_end", () => {
  const { theme = "your theme" } = hexo.config || {};
  if (theme === "your theme") {
    return `<style>
      // some extra style
    </style>`;
  }
  return "";
});

there are many css variable in swiper, for examples: --swiper-theme-color, --swiper-navigation-size ... you can find them in the source code of swiper.

hexo-tag-swiper's People

Contributors

dedicatus546 avatar

Stargazers

 avatar

Watchers

 avatar

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.