Skip to content

Miscellaneous ​

Shared Translations ​

Shared translations provide common static text that is available across all sections in your project. Use them for repeated phrases like "Read More", "Add to Cart", or other text shared between multiple sections.

Shared translations live in a single file at the project root:

shared/
└── translation.ts

The format is the same as section-level translations — a record keyed by language code:

typescript
// shared/translation.ts
export default {
  en: {
    '$label.shared.title': 'Title',
    '$label.shared.description': 'Description',
    '$label.shared.read_more': 'Read More',
  },
  fr: {
    '$label.shared.title': 'Titre',
    '$label.shared.description': 'Description',
    '$label.shared.read_more': 'Lire la suite',
  },
} as const;

💡 Convention

Use the $label.shared.* prefix for shared translation keys to distinguish them from section-specific keys.

Shared translations are automatically injected into every section at build time. Access them in your Vue components using the useTranslation composable:

vue
<template>
  <a>{{ t('$label.shared.read_more') }}</a>
</template>

ℹ️ Hot Reload

Changes to shared/translation.ts trigger a full rebuild in preview mode.

Factory Methods ​

All configuration objects in Crane are created using factory functions from @lightspeed/crane-api. Factories accept a typed config object, auto-inject the type discriminator field, and return a fully typed result.

FactoryPurposeDetails
contentContent editor definitionsContent Editors
designDesign editor definitionsDesign Editors
layoutLayout configurations and design overridesLayout
showcaseShowcase configurationsShowcases
templateTemplate configuration and page definitionsTemplates
sectionSection references in pages (default, custom, store)Templates — Pages
translationTranslation settingsTranslations

The content and design factories also provide content.default.*() and design.default.*() sub-factories for creating standalone default values used in showcases.

typescript
import { content, design, layout, showcase, template, section, translation } from '@lightspeed/crane-api';

Linting ​

Crane provides @lightspeed/eslint-config-crane — a preconfigured ESLint setup for section development. The template scaffolds an eslint.config.cjs that consumes it as a one-liner:

javascript
// eslint.config.cjs
module.exports = require('@lightspeed/eslint-config-crane');

What It Includes ​

  • Vue 3 — eslint-plugin-vue with recommended rules
  • TypeScript — @vue/eslint-config-typescript recommended rules
  • Scoped CSS — eslint-plugin-vue-scoped-css recommended rules
  • Accessibility — eslint-plugin-vuejs-accessibility

Notable Rules ​

RuleSettingDescription
vue/component-api-stylescript-setup, compositionOnly Composition API with <script setup> allowed
max-len160Maximum line length for .ts and .vue files
no-consolewarnConsole statements produce warnings
no-debuggerwarnDebugger statements produce warnings

Running the Linter ​

The template does not include a lint script by default. Run ESLint directly:

bash
npx eslint "./**/*.{js,ts}"

Or add a script to your package.json:

json
{
  "scripts": {
    "lint": "eslint \"./**/*.{js,ts}\""
  }
}