Skip to content

Navbar

The navbar configuration controls the top navigation menu links and search functionality.

Config File

src/config/navBarConfig.ts

Firefly provides built-in navigation link presets:

PresetDescription
LinkPresets.HomeHome page
LinkPresets.ArchiveArchive
LinkPresets.CategoriesCategories
LinkPresets.TagsTags
LinkPresets.FriendsFriends
LinkPresets.SponsorSponsor
LinkPresets.GuestbookGuestbook
LinkPresets.AboutAbout
LinkPresets.BangumiBangumi
LinkPresets.GalleryGallery

Custom links support the following properties:

PropertyTypeRequiredDescription
namestringYesLink name
urlstringYesLink URL
iconstringNoIcon (Iconify format)
externalbooleanNoExternal link
childrenarrayNoSubmenu items (supports nesting)
pageKeystringNoKey in siteConfig.pages, used to dynamically show/hide the link

Example

ts
import { type NavBarLink } from "../types/navBarConfig";
import { LinkPresets } from "../config/navBarConfig";

const links: NavBarLink[] = [
  LinkPresets.Home,
  LinkPresets.Archive,

  // Custom link with submenu
  {
    name: "Links",
    url: "/links/",
    icon: "material-symbols:link",
    children: [
      {
        name: "GitHub",
        url: "https://github.com/CuteLeaf/Firefly",
        external: true,
        icon: "fa7-brands:github",
      },
    ],
  },

  LinkPresets.Friends,
];

Search Configuration

PropertyTypeDefaultDescription
methodNavBarSearchMethodNavBarSearchMethod.PageFindSearch method, currently supports PageFind

Dynamic Navbar

The navbar automatically adjusts based on siteConfig.pages settings. Set the pageKey property on a link to connect it to a page toggle.

How It Works

Set pageKey on a NavBarLink to match a key in siteConfig.pages:

ts
// siteConfig.ts
pages: {
  friends: true,    // Friends page enabled
  guestbook: false, // Guestbook page disabled
  bangumi: true,    // Bangumi enabled
  gallery: false,   // Gallery disabled
  dynamic: true,    // Moments enabled
  sponsor: true,    // Sponsor enabled
}
ts
// navBarConfig.ts - set pageKey
LinkPresets.Friends    // pageKey: "friends"
LinkPresets.Guestbook  // pageKey: "guestbook"
LinkPresets.Bangumi    // pageKey: "bangumi"

When a page is disabled (false):

  • The corresponding navbar link is hidden
  • If all children of a parent menu are hidden, the parent menu is also hidden
  • If only one child remains, it is shown directly (parent wrapper removed)

Examples

ConfigEffect
siteConfig.pages.guestbook = falseGuestbook link hidden
siteConfig.pages.sponsor = falseSponsor link hidden
siteConfig.pages.bangumi = falseBangumi link hidden
siteConfig.pages.gallery = falseGallery link hidden
siteConfig.pages.dynamic = falseMoments link hidden
pages.gallery = false and pages.bangumi = false"My" entire menu hidden

TIP

Pre-installed icon sets: fa7-brands, fa7-regular, fa7-solid, material-symbols, simple-icons. Visit icones.js.org for icon codes. Install additional sets with: pnpm add @iconify-json/<icon-set-name>.