Appearance
DAM Share URL Mixin
File Information
- Path:
mixins/damShareUrl.js - Purpose: Share URL generation and normalization for DAM assets
Overview
The DAM Share URL mixin provides filters for normalizing and generating share URLs for DAM assets. It handles URL generation for both admin (backend) and frontend contexts, and provides source normalization for display purposes.
Key Features
URL Normalization
- Source normalization (admin/frontend)
- URL generation with proper domain
- Custom domain support
Share URL Generation
- Type-based URL construction
- Status parameter handling
- Domain selection logic
Source Display
- Normalizes source names
- "admin" → "Backend"
- "frontend" → "Frontend"
Filters
normalizedSource(source)
Normalizes source name for display:
- Converts "admin" to "Backend"
- Converts other values to "Frontend"
- Used for UI display
Parameters:
source(string): Source identifier ("admin" or "frontend")
Returns: Normalized source string
Example:
javascript
normalizedSource('admin') // Returns "Backend"
normalizedSource('frontend') // Returns "Frontend"normalizedUrl(url, source, customDomain)
Normalizes and generates share URL:
- Parses URL parameters
- Extracts type and status
- Generates full URL with appropriate domain
- Supports custom domain for frontend
Parameters:
url(string): Share URL string with parameterssource(string): Source identifier ("admin" or "frontend")customDomain(string): Optional custom domain for frontend
Returns: Complete normalized URL string
URL Format:
- Input:
type=asset&status=active - Output:
{domain}/{type}?{status}
Domain Selection:
- If
source === 'admin': UsescurrentSource(window.location.origin) - If
source === 'frontend': UsescustomDomainorDAM_FRONTEND_URL
Environment Variables
DAM_FRONTEND_URL- Frontend domain URL (from environment)
Usage Examples
In Template
vue
<template>
<div>
<p>Source: {{ shareLink.source | normalizedSource }}</p>
<a :href="shareLink.url | normalizedUrl(shareLink.source)">
Share Link
</a>
</div>
</template>
<script>
import damShareUrl from '~/mixins/dam-share-url'
export default {
mixins: [damShareUrl],
data() {
return {
shareLink: {
url: 'type=asset&status=active',
source: 'admin'
}
}
}
}
</script>With Custom Domain
vue
<template>
<a :href="shareLink.url | normalizedUrl('frontend', customDomain)">
Frontend Share Link
</a>
</template>
<script>
import damShareUrl from '~/mixins/dam-share-url'
export default {
mixins: [damShareUrl],
data() {
return {
shareLink: {
url: 'type=asset&status=active'
},
customDomain: 'https://custom-domain.com'
}
}
}
</script>URL Parameter Parsing
The mixin parses URL parameters:
- Extracts
typeparameter - Extracts
statusparameter - Reconstructs URL with proper domain
Input Format:
type=asset&status=activeOutput Format:
https://domain.com/asset?status=activeIntegration Points
- Share Dialogs: Share URL generation
- Asset Details: Share link display
- Sharing Page: Share management
- External Pages: Share link access
Notes for Development
- Mixin uses Vue filters (legacy approach)
- Source normalization for UI display
- URL generation handles both admin and frontend
- Custom domain support for frontend
- Current source detected from window.location
Related Documentation
- Share Asset Dialog - Share functionality
- Sharing Page - Share management
- Asset Sharing Feature - Share system