-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Improve .gitignore configuration for examples * [i18nIgnore] Update VitePress example structure * Add new `routingStrategy` API * Remove unnecessary comment * No need to define the default option * Create tidy-days-learn.md
- Loading branch information
1 parent
8fea07a
commit f57c9f1
Showing
11 changed files
with
113 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@lunariajs/core": patch | ||
--- | ||
|
||
Add new `routingStrategy` API |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# example build output | ||
.vitepress/cache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { defineConfig } from 'vitepress'; | ||
|
||
export default defineConfig({ | ||
locales: { | ||
en: { | ||
label: 'English', | ||
lang: 'en', | ||
link: '/en/', | ||
}, | ||
pt: { | ||
label: 'Português', | ||
lang: 'pt', | ||
link: '/pt/', | ||
}, | ||
es: { | ||
label: 'Spanish', | ||
lang: 'es', | ||
link: '/es/', | ||
}, | ||
}, | ||
}); |
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,64 +1,7 @@ | ||
import { z } from 'zod'; | ||
import type { DictionaryObject } from '../types.js'; | ||
|
||
export const SharedPathResolverSchema = z | ||
.function() | ||
.args( | ||
z.object({ | ||
lang: z.string(), | ||
localePath: z.string(), | ||
}) | ||
) | ||
.returns(z.string()) | ||
.optional() | ||
.default(() => ({ lang, localePath }: { lang: string; localePath: string }) => { | ||
const pathParts = localePath.split('/'); | ||
const localePartIndex = pathParts.findIndex((part) => part === lang); | ||
if (localePartIndex > -1) pathParts.splice(localePartIndex, 1); | ||
|
||
return pathParts.join('/'); | ||
}) | ||
.describe( | ||
"Fuction to extract a shared path from a locale's path, used to 'link' the content between two locales." | ||
); | ||
|
||
export const LocalePathConstructorSchema = z | ||
.function() | ||
.args( | ||
z.object({ | ||
sourceLang: z.string(), | ||
localeLang: z.string(), | ||
sourcePath: z.string(), | ||
}) | ||
) | ||
.returns(z.string()) | ||
.optional() | ||
.default( | ||
() => | ||
({ | ||
sourceLang, | ||
localeLang, | ||
sourcePath, | ||
}: { | ||
sourceLang: string; | ||
localeLang: string; | ||
sourcePath: string; | ||
}) => { | ||
const pathParts = sourcePath.split('/'); | ||
const localePartIndex = pathParts.findIndex((part) => part === sourceLang); | ||
if (localePartIndex > -1) pathParts.splice(localePartIndex, 1, localeLang); | ||
|
||
return pathParts.join('/'); | ||
} | ||
) | ||
.describe( | ||
'Fuction to construct the locale-specific path from the source path of the same content.' | ||
); | ||
|
||
export const DictionaryContentSchema: z.ZodType<DictionaryObject> = z.record( | ||
z.string(), | ||
z.lazy(() => z.string().or(DictionaryContentSchema)) | ||
); | ||
|
||
export type SharedPathResolver = z.infer<typeof SharedPathResolverSchema>; | ||
export type LocalePathConstructor = z.infer<typeof LocalePathConstructorSchema>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters