mirror of
https://github.com/samkaraca/lazuri-doviguram.git
synced 2026-04-29 17:59:51 +00:00
theme page moved to getStaticProps and getStaticPaths
This commit is contained in:
parent
cf7fbf8837
commit
96edb85316
@ -26,6 +26,23 @@ export class ThemeReposityImplementation implements ThemeRepository {
|
||||
return ThemeReposityImplementation.instance;
|
||||
}
|
||||
|
||||
getThemeIds = async (): Promise<any> => {
|
||||
const dbClient = DynamoDBClientSingleton.getInstance();
|
||||
const queryCommand = new QueryCommand({
|
||||
TableName: "themes",
|
||||
KeyConditionExpression: "PK = :pk",
|
||||
ExpressionAttributeValues: {
|
||||
":pk": { S: "theme" },
|
||||
},
|
||||
ProjectionExpression: "SK",
|
||||
});
|
||||
|
||||
const rawThemeIdDatas = await dbClient.send(queryCommand);
|
||||
const themeIds = rawThemeIdDatas.Items!.map((item) => unmarshall(item));
|
||||
|
||||
return themeIds;
|
||||
};
|
||||
|
||||
getThemeMetas = async (): Promise<ThemeMetaDTO[]> => {
|
||||
const dbClient = DynamoDBClientSingleton.getInstance();
|
||||
const queryCommand = new QueryCommand({
|
||||
|
||||
@ -7,7 +7,7 @@ export default function ThemePage({ themeData }: { themeData: Theme }) {
|
||||
return <ThemePageElement theme={Theme.from(themeData)} isAdmin={false} />;
|
||||
}
|
||||
|
||||
export async function getServerSideProps(context: GetServerSidePropsContext) {
|
||||
export async function getStaticProps(context: GetServerSidePropsContext) {
|
||||
const path = context.params as unknown as { theme: string };
|
||||
const themeRepository = ThemeReposityImplementation.getInstance();
|
||||
const themeData = await themeRepository.getThemeData(path.theme);
|
||||
@ -18,3 +18,11 @@ export async function getServerSideProps(context: GetServerSidePropsContext) {
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
export async function getStaticPaths() {
|
||||
const themeRepository = ThemeReposityImplementation.getInstance();
|
||||
const themeIds = (await themeRepository.getThemeIds()) as { SK: string }[];
|
||||
const themePaths = themeIds.map((item) => ({ params: { theme: item.SK } }));
|
||||
|
||||
return { paths: themePaths, fallback: false };
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user