Issue with Astro and Sveltia CMS: Relation Fields Not Resolving Correctly for Multi-language Setup #302
-
Hi @kyoshino, The Problem: For example, the author relation is saved as What I Tried: CMS Configuration (config.yml): local_backend: true
logo_url: /logo.svg
backend:
name: 'github'
repo: yacosta738/yacosta738.github.io
branch: main
base_url: https://yunielacosta.com
automatic_deployments: false
accept_roles:
- admin
- editor
slug:
encoding: 'ascii'
clean_accents: true
sanitize_replacement: '-'
publish_mode: editorial_workflow
media_folder: 'public/images'
public_folder: '/images'
i18n:
structure: 'multiple_folders'
locales: ['en', 'es']
default_locale: 'en'
canonical_slug:
key: defaultLocaleVersion
value: 'en/{{slug}}' Astro Configuration (config.ts): import { glob } from 'astro/loaders';
import { defineCollection, reference, z } from 'astro:content';
const blogCollection = defineCollection({
type: 'content',
schema: z.object({
title: z.string(),
description: z.string(),
date: z.date(),
cover: z.string(),
author: reference('authors'),
tags: z.array(reference('tags')),
categories: z.array(reference('categories')),
isExternalLink: z.boolean().default(false),
link: z.string().optional(),
draft: z.boolean(),
}),
});
const authors = defineCollection({
loader: glob({ pattern: '**/[^_]*.json', base: './authors' }),
schema: z.object({
name: z.string(),
image: z.string(),
rol: z.string(),
bio: z.string(),
email: z.string(),
social: z.array(
z.object({
name: z.string(),
url: z.string(),
icon: z.string(),
})
),
}),
});
export const collections = {
blog: blogCollection,
authors,
}; Any ideas on how to fix the relation field so that it correctly includes the locale (en/ or es/)? I appreciate any help! |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 12 replies
-
The But I think Sveltia CMS is not using the |
Beta Was this translation helpful? Give feedback.
-
I’ve fixed the Sveltia bug in v0.53.4, but I think you still need to fix some stuff on your site:
I’m not familiar with Astro, so unfortunately I cannot help the implementation details. |
Beta Was this translation helpful? Give feedback.
-
Hi @kyoshino, I’m still experiencing the same issue. I need the relation between collections to use a custom slug that includes the locale. For example, in this image, when I select a tag, category, or author, the editor saves the slug without the locale (en/{{slug}} or es/{{slug}}). Could you please advise on how to configure this correctly? Thank you! |
Beta Was this translation helpful? Give feedback.
-
Hi @kyoshino Is it possible for relationships between collections in Sveltia CMS to use a slug that matches the entry’s path, similar to how Astro handles content organization? Astro collection documentation: https://docs.astro.build/en/guides/content-collections/ |
Beta Was this translation helpful? Give feedback.
Added the locale prefix support to v0.61.0.