Feat/language detection (#31)
* feat: implementation of language detection * run utility scripts in tasks * fix: addiitonal fixes for background utilities * feat: toast() also for utility scripts --------- Co-authored-by: hugo <hugoms@me.com>
This commit is contained in:
@@ -20,6 +20,7 @@ function makePost(overrides: Partial<PostData> = {}): PostData {
|
||||
content: overrides.content ?? `# ${title}\n\nBody`,
|
||||
status: overrides.status ?? 'published',
|
||||
author: overrides.author,
|
||||
language: overrides.language,
|
||||
createdAt,
|
||||
updatedAt,
|
||||
publishedAt: overrides.publishedAt,
|
||||
@@ -155,4 +156,31 @@ describe('GenerationSitemapFeedService', () => {
|
||||
expect(result.rssXml).toBe('');
|
||||
expect(result.atomXml).toBe('');
|
||||
});
|
||||
|
||||
it('includes per-post language in RSS dc:language and Atom xml:lang', () => {
|
||||
const publishedPosts = [
|
||||
makePost({ id: '1', slug: 'post-en', title: 'English', language: 'en' }),
|
||||
makePost({ id: '2', slug: 'post-de', title: 'German', language: 'de' }),
|
||||
makePost({ id: '3', slug: 'post-no-lang', title: 'Default' }),
|
||||
];
|
||||
|
||||
const result = buildSitemapAndFeeds({
|
||||
baseUrl: 'https://example.com',
|
||||
projectName: 'Test Blog',
|
||||
maxPostsPerPage: 10,
|
||||
publishedPosts,
|
||||
publishedListPosts: publishedPosts,
|
||||
postIndex: buildIndex(publishedPosts),
|
||||
includeFeeds: true,
|
||||
});
|
||||
|
||||
// RSS should have dc:language per item
|
||||
expect(result.rssXml).toContain('xmlns:dc=');
|
||||
expect(result.rssXml).toContain('<dc:language>en</dc:language>');
|
||||
expect(result.rssXml).toContain('<dc:language>de</dc:language>');
|
||||
|
||||
// Atom should have xml:lang on entries with language
|
||||
expect(result.atomXml).toContain('xml:lang="en"');
|
||||
expect(result.atomXml).toContain('xml:lang="de"');
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user