Cards & Containers
The cards and containers used throughout this package can also be used independently. This will let you create cards linking to custom content, in whatever order you prefer.
Setup
Do initial installation first
Before you follow any of the guides below, you should import and install this project in your VitePress site.
You are free to pick and choose which components to import, and whether you want to pair containers with cards. We recommend using cards with containers, and to use the same layout (horizontal or vertical) for all components with a particular set of cards.
- Import the component in
docs/.vitepress/theme/index.ts(or equivalent)
import {
VpvCardHorizontal,
VpvCardVertical,
VpvContainerHorizontal,
VpvContainerVertical
} from '@cynber/vitepress-valence'
// ...
export default {
// ...
enhanceApp({ app, router, siteData }) {
// ...
app.component('VpvCardHorizontal', VpvCardHorizontal)
app.component('VpvCardVertical', VpvCardVertical)
app.component('VpvContainerHorizontal', VpvContainerHorizontal)
app.component('VpvContainerVertical', VpvContainerVertical)
}
}Usage
Container Components
Both VpvContainerHorizontal and VpvContainerVertical serve as wrapper components that provide structure and optional header functionality for organizing cards or other content. They share identical props.
Basic Usage
Containers can be used as simple wrappers around your content:
<VpvContainerHorizontal>
<!-- Your cards or other content here -->
</VpvContainerHorizontal><VpvContainerVertical>
<!-- Your cards or other content here -->
</VpvContainerVertical>Optional Header Functionality
Both container types support an optional header section with the following props:
Content Props:
headerTitle: Main title text for the container headerheaderSubtitle: Subtitle text displayed below the titleheaderDate: Date to display in the headerheaderLink: URL for making the header clickable
Display Options:
headerTitleLines: Number of lines to display for the title before truncatingheaderSubtitleLines: Number of lines to display for the subtitle before truncatingheaderDateFormat: Date format - accepts"long","short","iso", or custom format strings (ex."yyyy-MMM-dd")headerDatePrefix: Text to display before the date
The header will only appear when headerTitle is provided.
Card Components
Both VpvCardHorizontal and VpvCardVertical are content display components that can function as clickable links or static content blocks.
Required Props
Both card types require basic content props:
title: The main heading for the cardexcerpt: Descriptive text content for the card
Optional Content Props
Metadata:
author: Author name to displaydate: Date to display (enter a date in the formatYYYY-MM-DD)image: the URL or relative path to an image to displayimage_dark: the URL or relative path to an image to display in dark mode (if not provided, theimageprop will be used in both light and dark modes)category: A single category name to displaytags: Array of tag names to displayurl: the URL or relative path to navigate to when the card is selected
Display Control:
titleLines: Number of lines for title before truncation (default: 2)excerptLines: Number of lines for excerpt before truncationdisableLinks: If set totrue, the card will not be clickableisExternal: If set totrue, the card will display additional formatting to indicate that the link will take you to an external site (currently affects theVerticalcard type only, as ofv0.2.0)
hide* Props:
hideAuthor: Hide the author namehideDate: Hide the datehideImage: Hide the imagehideCategory: Hide the categoryhideTags: Hide the tagshideDomain: Hide the domain from the external link formatting (currently affects theVerticalcard type only, as ofv0.2.0)
When a url is provided and disableLinks is not set to true, cards will automatically detect external links and apply appropriate attributes (target="_blank" and rel="noopener noreferrer").