Skip to content

Advertisement

The advertisement component displays in the sidebar, supporting image ads and text ads.

Config File

src/config/adConfig.ts

Properties

PropertyTypeRequiredDescription
titlestringNoAd title
contentstringNoAd text content
imageobjectNoImage configuration
linkobjectNoLink configuration
closablebooleanNoCan be closed
displayCountnumberNoDisplay count limit, -1 for unlimited
expireDatestringNoExpiry date (ISO 8601)

Image Configuration

PropertyTypeDescription
image.srcstringImage source
image.altstringAlt text
image.linkstringClick link
image.externalbooleanExternal link
PropertyTypeDescription
link.textstringLink text
link.urlstringLink URL
link.externalbooleanExternal link

Padding Configuration

PropertyTypeDescription
padding.allstringUniform padding (overrides individual)
padding.topstringTop padding
padding.rightstringRight padding
padding.bottomstringBottom padding
padding.leftstringLeft padding

Example: Image-only Ad

ts
export const adConfig1: AdConfig = {
  image: {
    src: "assets/images/cover.avif",
    alt: "Ad banner",
    link: "#",
    external: true,
  },
  closable: true,
  displayCount: -1,
  padding: { all: "0" },
};

Example: Full Content Ad

ts
export const adConfig2: AdConfig = {
  title: "Support Us",
  content: "If you find this site helpful, consider supporting us!",
  image: {
    src: "assets/images/cover.avif",
    alt: "Support",
    link: "about/",
    external: false,
  },
  link: {
    text: "Support",
    url: "about/",
    external: false,
  },
  closable: true,
  displayCount: -1,
};

TIP

Ad visibility is controlled in sidebarConfig.ts. Set the advertisement component's enable property and use configId to specify which ad config to use (e.g., "ad1" or "ad2").