hexo-theme-solitude

repository·dev·Indexed 22 days ago

https://github.com/everfu/hexo-theme-solitude

An elegant, high-performance Hexo theme featuring PWA support, lazy loading, and a stable Browser Extension API via window.Solitude. It supports multiple comment systems (Twikoo, Waline, Valine, Artalk, Giscus), light/dark mode switching, and special pages such as Music Room and Album Page. Version 4.0.0 includes support for mathematical formulas, AI-generated summaries, and dynamic resource loading.

Tokens
800
Snippets
5
Records
6
Agent score
28%

What's inside hexo-theme-solitude

  1. Overview of hexo-theme-solitude features

    dev

    Solitude is an elegant Hexo theme that includes the following features:

    • Performance & PWA: Lazy loading for pages (Pjax), images (LazyLoad), and offline application support (PWA).
    • Comments: Supports multiple systems including Twikoo, Waline, Valine, Artalk, and Giscus. It also supports dual comment systems.
    • UI/UX: Light/Dark mode switching (ColorMode) and Lightbox support (medium-zoom, fancybox).
    • Content Support: Mathematical formulas (Latex), AI-generated summaries, and code highlighting.
    • Special Pages: Instant articles, My Team, Online Tools, Music Room, Friend Links, Album Page, Douban Page, and Bullet Message page.

    For detailed configuration, visit the official Documentation.

  2. Install and apply hexo-theme-solitude

    dev

    To use the Solitude theme in your Hexo blog, install the NPM package and update your Hexo configuration file.

    1. Install the package via npm:

      npm i hexo-theme-solitude
    2. In your Hexo _config.yml file, set the theme property to solitude:

      theme: solitude
    npm i hexo-theme-solitude
  3. Use the window.Solitude Browser Extension API

    dev

    The theme provides a stable extension entry point via window.Solitude using native ES modules. If you are writing custom scripts, migrate away from legacy objects like sco, utils, pjax, GLOBAL_CONFIG, or PAGE_CONFIG and use the following API instead:

    • navigate(url): Navigate to a specific URL.
    • refresh(): Refresh the current page.
    • copy(text): Copy text to the clipboard.
    • toggleTheme(): Switch between light and dark modes.

    Resource Loading

    • loadScript(url, options): Dynamically load a script.
    • loadStyle(url, options): Dynamically load a stylesheet.

    Event Listeners

    Use on(event, handler) to listen for lifecycle events. This method returns an unsubscribe function to stop listening to the event.

    Supported events:

    • ready: When the theme is ready.
    • beforeNavigate: Before a navigation event occurs.
    • afterNavigate: After a navigation event completes.
    • themeChange: When the color mode (light/dark) changes.
    // Example: Listening for theme changes
    const unsubscribe = window.Solitude.on('themeChange', (newTheme) => {
      console.log('Theme changed to:', newTheme);
    });
    
    // To stop listening:
    unsubscribe();
    
    // Example: Navigating programmatically
    window.Solitude.navigate('/about');