VitePress Features Demo β
This page demonstrates the enhanced VitePress markdown features implemented in Phase 2.
Code Groups (Tabbed Code Blocks) β
Code groups allow you to show multiple code variants in tabs:
npm install whatsmark-saas
npm run devyarn add whatsmark-saas
yarn devpnpm add whatsmark-saas
pnpm devLine Highlighting β
Highlight specific lines to draw attention:
function connectWhatsApp(config) {
const api = new WhatsAppAPI({
apiKey: config.apiKey,
baseURL: 'https://graph.facebook.com', // Highlighted: Important URL
})
// Highlighted section: Required headers
const headers = {
'Authorization': `Bearer ${config.token}`
}
return api.connect(headers)
}Code Annotations β
Use inline annotations to highlight, focus, show diffs, and mark errors:
class PaymentGateway
{
public function process($amount)
{
$oldMethod = 'stripe';
$newMethod = 'tap';
$apiKey = env('PAYMENT_KEY');
if (!$apiKey) {
return null;
}
// Deprecated: Use processPaymentV2() instead
return $this->legacy($amount);
}
}Legend:
[!code --]- Removed code (red background)[!code ++]- Added code (green background)[!code focus]- Focused code (highlighted)[!code error]- Error code (red marker)[!code warning]- Warning code (yellow marker)
Line Numbers β
Add line numbers to code blocks:
<?php
namespace App\Services;
class WhatsAppService
{
public function sendMessage(string $to, string $message)
{
return $this->client->send($to, $message);
}
}Custom Containers β
Info Container β
Information
This is an informational message with standard styling.
Tip Container β
Pro Tip
Use environment variables for sensitive configuration like API keys and secrets.
Warning Container β
Important
Always validate user input before processing payment transactions.
Danger Container β
Critical
Never commit API keys or secrets to version control!
Collapsible Details β
Use details containers for optional or advanced content:
Click to expand: Advanced Configuration
// Advanced payment gateway configuration
return [
'gateway' => [
'mode' => env('PAYMENT_MODE', 'test'),
'test' => [
'api_key' => env('TEST_API_KEY'),
'secret_key' => env('TEST_SECRET_KEY'),
],
'live' => [
'api_key' => env('LIVE_API_KEY'),
'secret_key' => env('LIVE_SECRET_KEY'),
],
'webhook' => [
'url' => env('WEBHOOK_URL'),
'secret' => env('WEBHOOK_SECRET'),
],
'timeout' => 30,
'retry' => 3,
],
];Custom Header Anchors β
Headers with custom IDs for stable URLs:
Installation Guide β
You can link to installation section using the custom anchor.
Configuration Setup β
Link to configuration with a custom ID.
Combined Example β
Real-world example combining multiple features:
Payment Gateway Integration
Follow these steps to integrate a payment gateway:
# Install required packages
composer require stripe/stripe-php
npm install @stripe/stripe-js# Add to .env file
STRIPE_API_KEY=sk_test_...
STRIPE_PUBLIC_KEY=pk_test_...
STRIPE_WEBHOOK_SECRET=whsec_...// app/Services/StripeGateway.php
use Stripe\StripeClient;
public function charge($amount, $token) {
$stripe = new StripeClient(env('STRIPE_API_KEY'));
try {
// Create payment intent
$intent = $stripe->paymentIntents->create([
'amount' => $amount * 100,
'currency' => 'usd',
'payment_method' => $token,
]);
return $intent;
} catch (\Exception $e) {
throw new PaymentException($e->getMessage());
}
}Click to expand: Testing the integration
Use Stripe test cards:
- Success:
4242 4242 4242 4242 - Decline:
4000 0000 0000 0002
- Success:
Test webhook locally:
bashstripe listen --forward-to localhost:8000/webhook/stripeVerify payment in Stripe Dashboard
Summary β
This demo showcases:
- Code Groups - Tabbed code blocks for multiple variants
- Line Highlighting -
{4,7-9}syntax - Code Annotations -
[!code ++],[!code --],[!code focus],[!code error],[!code warning] - Line Numbers -
:line-numberssuffix - Custom Containers -
::: info,::: tip,::: warning,::: danger - Details Container -
::: detailsfor collapsible content - Custom Anchors -
{#custom-id}for stable URLs
All features are VitePress-native with no external dependencies!