feat(route/youtube): Allow configuring custom embed url (#21248)
This commit is contained in:
@@ -236,6 +236,7 @@ type ConfigEnvKeys =
|
||||
| 'YOUTUBE_CLIENT_ID'
|
||||
| 'YOUTUBE_CLIENT_SECRET'
|
||||
| 'YOUTUBE_REFRESH_TOKEN'
|
||||
| 'YOUTUBE_VIDEO_EMBED_URL'
|
||||
| 'ZHIHU_COOKIES'
|
||||
| 'ZODGAME_COOKIE'
|
||||
| 'ZSXQ_ACCESS_TOKEN'
|
||||
@@ -675,6 +676,7 @@ export type Config = {
|
||||
clientId?: string;
|
||||
clientSecret?: string;
|
||||
refreshToken?: string;
|
||||
videoEmbedUrl?: string;
|
||||
};
|
||||
zhihu: {
|
||||
cookies?: string;
|
||||
@@ -1164,6 +1166,7 @@ const calculateValue = () => {
|
||||
clientId: envs.YOUTUBE_CLIENT_ID,
|
||||
clientSecret: envs.YOUTUBE_CLIENT_SECRET,
|
||||
refreshToken: envs.YOUTUBE_REFRESH_TOKEN,
|
||||
videoEmbedUrl: envs.YOUTUBE_VIDEO_EMBED_URL || 'https://www.youtube-nocookie.com/embed/',
|
||||
},
|
||||
zhihu: {
|
||||
cookies: envs.ZHIHU_COOKIES,
|
||||
|
||||
@@ -68,7 +68,16 @@ export const renderDescription = (embed, videoId, img, description) =>
|
||||
renderToString(
|
||||
<>
|
||||
{embed ? (
|
||||
<iframe id="ytplayer" type="text/html" width="640" height="360" src={`https://www.youtube-nocookie.com/embed/${videoId}`} frameborder="0" allowfullscreen referrerpolicy="strict-origin-when-cross-origin" />
|
||||
<iframe
|
||||
id="ytplayer"
|
||||
type="text/html"
|
||||
width="640"
|
||||
height="360"
|
||||
src={(config.youtube?.videoEmbedUrl || 'https://www.youtube-nocookie.com/embed/') + videoId}
|
||||
frameborder="0"
|
||||
allowfullscreen
|
||||
referrerpolicy="strict-origin-when-cross-origin"
|
||||
/>
|
||||
) : (
|
||||
<img src={img?.url ?? ''} />
|
||||
)}
|
||||
|
||||
Reference in New Issue
Block a user