mirror of
https://github.com/teableio/teable
synced 2024-11-22 15:31:39 +00:00
fix: i18n for share page (#370)
This commit is contained in:
parent
2991d861eb
commit
d2d6e3c958
@ -2,9 +2,9 @@ import type { I18nActiveNamespaces } from '@/lib/i18n';
|
||||
|
||||
export interface IShareConfig {
|
||||
// Define namespaces in use in both the type and the config.
|
||||
i18nNamespaces: I18nActiveNamespaces<'share' | 'sdk'>;
|
||||
i18nNamespaces: I18nActiveNamespaces<'share' | 'common' | 'table' | 'sdk'>;
|
||||
}
|
||||
|
||||
export const shareConfig: IShareConfig = {
|
||||
i18nNamespaces: ['share', 'sdk'],
|
||||
i18nNamespaces: ['share', 'common', 'table', 'sdk'],
|
||||
};
|
||||
|
@ -4,19 +4,23 @@ import type { GetServerSideProps } from 'next';
|
||||
import { ssrApi } from '@/backend/api/rest/table.ssr';
|
||||
import type { IShareViewPageProps } from '@/features/app/blocks/share/view/ShareViewPage';
|
||||
import { ShareViewPage } from '@/features/app/blocks/share/view/ShareViewPage';
|
||||
import { shareConfig } from '@/features/i18n/share.config';
|
||||
import { getTranslationsProps } from '@/lib/i18n';
|
||||
|
||||
export const getServerSideProps: GetServerSideProps<IShareViewPageProps> = async ({
|
||||
res,
|
||||
req,
|
||||
query,
|
||||
}) => {
|
||||
export const getServerSideProps: GetServerSideProps<IShareViewPageProps> = async (context) => {
|
||||
const { res, req, query } = context;
|
||||
const { shareId } = query;
|
||||
const { i18nNamespaces } = shareConfig;
|
||||
|
||||
try {
|
||||
res.setHeader('Content-Security-Policy', "frame-ancestors 'self' *;");
|
||||
ssrApi.axios.defaults.headers['cookie'] = req.headers.cookie || '';
|
||||
const shareViewData = await ssrApi.getShareView(shareId as string);
|
||||
return {
|
||||
props: { shareViewData },
|
||||
props: {
|
||||
shareViewData,
|
||||
...(await getTranslationsProps(context, i18nNamespaces)),
|
||||
},
|
||||
};
|
||||
} catch (e) {
|
||||
const error = e as IHttpError;
|
||||
|
Loading…
Reference in New Issue
Block a user