@jjlmoya/utils-science 1.11.0 → 1.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/index.ts +2 -2
- package/src/pages/[locale]/[slug].astro +3 -4
- package/src/tests/slug_language_code_format.test.ts +23 -0
- package/src/tool/asteroid-impact/index.ts +3 -6
- package/src/tool/cellular-renewal/index.ts +3 -6
- package/src/tool/colony-counter/index.ts +3 -6
- package/src/tool/microwave-detector/index.ts +3 -6
- package/src/tool/simulation-probability/index.ts +3 -6
- package/src/tools.ts +2 -0
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { scienceCategory, scienceCategory as templateCategory } from './category';
|
|
2
|
-
export
|
|
2
|
+
export const ScienceCategorySEO = () => import('./category/seo.astro').then((m) => m.default);
|
|
3
3
|
export { COLONY_COUNTER_TOOL } from './tool/colony-counter/index';
|
|
4
4
|
export { ASTEROID_IMPACT_TOOL } from './tool/asteroid-impact/index';
|
|
5
5
|
export { MICROWAVE_DETECTOR_TOOL } from './tool/microwave-detector/index';
|
|
@@ -20,5 +20,5 @@ export type {
|
|
|
20
20
|
ToolDefinition,
|
|
21
21
|
} from './types';
|
|
22
22
|
|
|
23
|
-
export { ALL_TOOLS } from './tools';
|
|
23
|
+
export { ALL_ENTRIES, ALL_TOOLS } from './tools';
|
|
24
24
|
|
|
@@ -14,7 +14,8 @@ import type { UtilitySEOContent } from "@jjlmoya/utils-shared";
|
|
|
14
14
|
export async function getStaticPaths() {
|
|
15
15
|
const paths = [];
|
|
16
16
|
|
|
17
|
-
for (const { entry, Component } of ALL_TOOLS) {
|
|
17
|
+
for (const { entry, Component: lazyComp } of ALL_TOOLS) {
|
|
18
|
+
const { default: Component } = await lazyComp();
|
|
18
19
|
const localeEntries = Object.entries(entry.i18n) as [
|
|
19
20
|
KnownLocale,
|
|
20
21
|
() => Promise<ToolLocaleContent>,
|
|
@@ -52,8 +53,6 @@ export async function getStaticPaths() {
|
|
|
52
53
|
return paths;
|
|
53
54
|
}
|
|
54
55
|
|
|
55
|
-
type ToolComponent = (props: { ui: Record<string, string> }) => unknown;
|
|
56
|
-
|
|
57
56
|
interface NavItem {
|
|
58
57
|
id: string;
|
|
59
58
|
title: string;
|
|
@@ -62,7 +61,7 @@ interface NavItem {
|
|
|
62
61
|
}
|
|
63
62
|
|
|
64
63
|
interface Props {
|
|
65
|
-
Component:
|
|
64
|
+
Component: unknown;
|
|
66
65
|
locale: KnownLocale;
|
|
67
66
|
content: ToolLocaleContent;
|
|
68
67
|
localeUrls: Partial<Record<KnownLocale, string>>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import { ALL_TOOLS } from '../tools';
|
|
3
|
+
import type { ToolLocaleContent } from '../types';
|
|
4
|
+
|
|
5
|
+
describe('Slug Language Code Format Validation', () => {
|
|
6
|
+
ALL_TOOLS.forEach((tool) => {
|
|
7
|
+
describe(`Tool: ${tool.entry.id}`, () => {
|
|
8
|
+
it('slug should not end with 2-letter language codes like -ja, -ru, -ko', async () => {
|
|
9
|
+
const locales = Object.keys(tool.entry.i18n);
|
|
10
|
+
|
|
11
|
+
for (const locale of locales) {
|
|
12
|
+
const loader = tool.entry.i18n[locale as keyof typeof tool.entry.i18n];
|
|
13
|
+
const content = (await loader?.()) as ToolLocaleContent;
|
|
14
|
+
|
|
15
|
+
expect(
|
|
16
|
+
content.slug,
|
|
17
|
+
`Tool "${tool.entry.id}" locale "${locale}" slug ("${content.slug}") cannot end with a 2-letter language code (e.g., -ja, -ru, -ko).`,
|
|
18
|
+
).not.toMatch(/-[a-z]{2}$/);
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
});
|
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
import type { ScienceToolEntry, ToolDefinition } from '../../types';
|
|
2
|
-
import AsteroidImpactComponent from './component.astro';
|
|
3
|
-
import AsteroidImpactSEO from './seo.astro';
|
|
4
|
-
import AsteroidImpactBibliography from './bibliography.astro';
|
|
5
2
|
|
|
6
3
|
export const asteroidImpact: ScienceToolEntry = {
|
|
7
4
|
id: 'asteroid-impact',
|
|
@@ -30,7 +27,7 @@ export const asteroidImpact: ScienceToolEntry = {
|
|
|
30
27
|
|
|
31
28
|
export const ASTEROID_IMPACT_TOOL: ToolDefinition = {
|
|
32
29
|
entry: asteroidImpact,
|
|
33
|
-
Component:
|
|
34
|
-
SEOComponent:
|
|
35
|
-
BibliographyComponent:
|
|
30
|
+
Component: () => import('./component.astro'),
|
|
31
|
+
SEOComponent: () => import('./seo.astro'),
|
|
32
|
+
BibliographyComponent: () => import('./bibliography.astro'),
|
|
36
33
|
};
|
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
import type { ScienceToolEntry, ToolDefinition } from '../../types';
|
|
2
|
-
import CellularRenewalComponent from './component.astro';
|
|
3
|
-
import CellularRenewalSEO from './seo.astro';
|
|
4
|
-
import CellularRenewalBibliography from './bibliography.astro';
|
|
5
2
|
|
|
6
3
|
export const cellularRenewal: ScienceToolEntry = {
|
|
7
4
|
id: 'cellular-renewal',
|
|
@@ -30,7 +27,7 @@ export const cellularRenewal: ScienceToolEntry = {
|
|
|
30
27
|
|
|
31
28
|
export const CELLULAR_RENEWAL_TOOL: ToolDefinition = {
|
|
32
29
|
entry: cellularRenewal,
|
|
33
|
-
Component:
|
|
34
|
-
SEOComponent:
|
|
35
|
-
BibliographyComponent:
|
|
30
|
+
Component: () => import('./component.astro'),
|
|
31
|
+
SEOComponent: () => import('./seo.astro'),
|
|
32
|
+
BibliographyComponent: () => import('./bibliography.astro'),
|
|
36
33
|
};
|
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
import type { ScienceToolEntry, ToolDefinition, ToolLocaleContent } from '../../types';
|
|
2
|
-
import ColonyCounterComponent from './component.astro';
|
|
3
|
-
import ColonyCounterSEO from './seo.astro';
|
|
4
|
-
import ColonyCounterBibliography from './bibliography.astro';
|
|
5
2
|
|
|
6
3
|
export interface ColonyCounterUI {
|
|
7
4
|
[key: string]: string;
|
|
@@ -33,7 +30,7 @@ export const colonyCounter: ScienceToolEntry<ColonyCounterUI> = {
|
|
|
33
30
|
|
|
34
31
|
export const COLONY_COUNTER_TOOL: ToolDefinition = {
|
|
35
32
|
entry: colonyCounter,
|
|
36
|
-
Component:
|
|
37
|
-
SEOComponent:
|
|
38
|
-
BibliographyComponent:
|
|
33
|
+
Component: () => import('./component.astro'),
|
|
34
|
+
SEOComponent: () => import('./seo.astro'),
|
|
35
|
+
BibliographyComponent: () => import('./bibliography.astro'),
|
|
39
36
|
};
|
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
import type { ScienceToolEntry, ToolDefinition } from '../../types';
|
|
2
|
-
import MicrowaveDetectorComponent from './component.astro';
|
|
3
|
-
import MicrowaveDetectorSEO from './seo.astro';
|
|
4
|
-
import MicrowaveDetectorBibliography from './bibliography.astro';
|
|
5
2
|
|
|
6
3
|
export const microwaveDetector: ScienceToolEntry = {
|
|
7
4
|
id: 'microwave-detector',
|
|
@@ -30,7 +27,7 @@ export const microwaveDetector: ScienceToolEntry = {
|
|
|
30
27
|
|
|
31
28
|
export const MICROWAVE_DETECTOR_TOOL: ToolDefinition = {
|
|
32
29
|
entry: microwaveDetector,
|
|
33
|
-
Component:
|
|
34
|
-
SEOComponent:
|
|
35
|
-
BibliographyComponent:
|
|
30
|
+
Component: () => import('./component.astro'),
|
|
31
|
+
SEOComponent: () => import('./seo.astro'),
|
|
32
|
+
BibliographyComponent: () => import('./bibliography.astro'),
|
|
36
33
|
};
|
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
import type { ScienceToolEntry, ToolDefinition } from '../../types';
|
|
2
|
-
import SimulationProbabilityComponent from './component.astro';
|
|
3
|
-
import SimulationProbabilitySEO from './seo.astro';
|
|
4
|
-
import SimulationProbabilityBibliography from './bibliography.astro';
|
|
5
2
|
|
|
6
3
|
export const simulationProbability: ScienceToolEntry = {
|
|
7
4
|
id: 'simulation-probability',
|
|
@@ -30,7 +27,7 @@ export const simulationProbability: ScienceToolEntry = {
|
|
|
30
27
|
|
|
31
28
|
export const SIMULATION_PROBABILITY_TOOL: ToolDefinition = {
|
|
32
29
|
entry: simulationProbability,
|
|
33
|
-
Component:
|
|
34
|
-
SEOComponent:
|
|
35
|
-
BibliographyComponent:
|
|
30
|
+
Component: () => import('./component.astro'),
|
|
31
|
+
SEOComponent: () => import('./seo.astro'),
|
|
32
|
+
BibliographyComponent: () => import('./bibliography.astro'),
|
|
36
33
|
};
|