mirror of
https://github.com/misskey-dev/misskey.git
synced 2026-05-25 01:34:07 +02:00
enhance(backend): pugをやめ、JSXベースのテンプレートに変更 (#16908)
* enhance(backend): pugをやめ、JSXベースのテンプレートに変更 (to misskey-dev dev branch) (#16889)
* wip
* wip
* wip
* wip
* fix lint
* attempt to fix test
* fix
* fix
* fix: oauthページの描画がおかしい問題を修正
* typo [ci skip]
* fix
* fix
* fix
* fix
* fix
* refactor
* fix
* fix
* fix broken lockfile
* fix: expose supported languages as global variable
* remove i18n package from root as it is no longer required [ci skip]
* fix
* fix: add i18n package.json to Docker target-builder stage for federation tests (#16909)
* Initial plan
* fix: add i18n package.json to Docker target-builder stage for federation tests
Co-authored-by: syuilo <4439005+syuilo@users.noreply.github.com>
---------
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: syuilo <4439005+syuilo@users.noreply.github.com>
* fix: followup-test-federation for enh-remove-pug (#16910)
* fix: followup-test-federation for enh-remove-pug
* Revert "fix: add i18n package.json to Docker target-builder stage for federation tests (#16909)"
This reverts commit 14313468d3.
* fix: CSSが読み込まれない場合がある問題を修正
* fix [ci skip]
* fix: propsのデフォルト値をnull合体演算子から論理和演算子に変更(空文字に対処するため)
* remove @types/pug
* enhance: bootloaderを埋め込むように
* fix possible race condition
* remove esbuild
---------
Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
Co-authored-by: syuilo <4439005+syuilo@users.noreply.github.com>
Co-authored-by: おさむのひと <46447427+samunohito@users.noreply.github.com>
This commit is contained in:
94
packages/backend/src/server/web/views/note.tsx
Normal file
94
packages/backend/src/server/web/views/note.tsx
Normal file
@@ -0,0 +1,94 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: syuilo and misskey-project
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
import type { Packed } from '@/misc/json-schema.js';
|
||||
import type { MiUserProfile } from '@/models/UserProfile.js';
|
||||
import type { CommonProps } from '@/server/web/views/_.js';
|
||||
import { Layout } from '@/server/web/views/base.js';
|
||||
import { isRenotePacked } from '@/misc/is-renote.js';
|
||||
import { getNoteSummary } from '@/misc/get-note-summary.js';
|
||||
|
||||
export function NotePage(props: CommonProps<{
|
||||
note: Packed<'Note'>;
|
||||
profile: MiUserProfile;
|
||||
}>) {
|
||||
const title = props.note.user.name ? `${props.note.user.name} (@${props.note.user.username}${props.note.user.host ? `@${props.note.user.host}` : ''})` : `@${props.note.user.username}${props.note.user.host ? `@${props.note.user.host}` : ''}`
|
||||
const isRenote = isRenotePacked(props.note);
|
||||
const images = (props.note.files ?? []).filter(f => f.type.startsWith('image/'));
|
||||
const videos = (props.note.files ?? []).filter(f => f.type.startsWith('video/'));
|
||||
const summary = getNoteSummary(props.note);
|
||||
|
||||
function ogBlock() {
|
||||
return (
|
||||
<>
|
||||
<meta property="og:type" content="article" />
|
||||
<meta property="og:title" content={title} />
|
||||
<meta property="og:description" content={summary} />
|
||||
<meta property="og:url" content={`${props.config.url}/notes/${props.note.id}`} />
|
||||
{videos.map(video => (
|
||||
<>
|
||||
<meta property="og:video:url" content={video.url} />
|
||||
<meta property="og:video:secure_url" content={video.url} />
|
||||
<meta property="og:video:type" content={video.type} />
|
||||
{video.thumbnailUrl ? <meta property="og:video:image" content={video.thumbnailUrl} /> : null}
|
||||
{video.properties.width != null ? <meta property="og:video:width" content={video.properties.width.toString()} /> : null}
|
||||
{video.properties.height != null ? <meta property="og:video:height" content={video.properties.height.toString()} /> : null}
|
||||
</>
|
||||
))}
|
||||
{images.length > 0 ? (
|
||||
<>
|
||||
<meta property="twitter:card" content="summary_large_image" />
|
||||
{images.map(image => (
|
||||
<>
|
||||
<meta property="og:image" content={image.url} />
|
||||
{image.properties.width != null ? <meta property="og:image:width" content={image.properties.width.toString()} /> : null}
|
||||
{image.properties.height != null ? <meta property="og:image:height" content={image.properties.height.toString()} /> : null}
|
||||
</>
|
||||
))}
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<meta property="twitter:card" content="summary" />
|
||||
<meta property="og:image" content={props.note.user.avatarUrl} />
|
||||
</>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
function metaBlock() {
|
||||
return (
|
||||
<>
|
||||
{props.note.user.host != null || isRenote || props.profile.noCrawle ? <meta name="robots" content="noindex" /> : null}
|
||||
{props.profile.preventAiLearning ? (
|
||||
<>
|
||||
<meta name="robots" content="noimageai" />
|
||||
<meta name="robots" content="noai" />
|
||||
</>
|
||||
) : null}
|
||||
<meta name="misskey:user-username" content={props.note.user.username} />
|
||||
<meta name="misskey:user-id" content={props.note.user.id} />
|
||||
<meta name="misskey:note-id" content={props.note.id} />
|
||||
|
||||
{props.federationEnabled ? (
|
||||
<>
|
||||
{props.note.user.host == null ? <link rel="alternate" type="application/activity+json" href={`${props.config.url}/notes/${props.note.id}`} /> : null}
|
||||
{props.note.uri != null ? <link rel="alternate" type="application/activity+json" href={props.note.uri} /> : null}
|
||||
</>
|
||||
) : null}
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<Layout
|
||||
{...props}
|
||||
title={`${title} | ${props.instanceName}`}
|
||||
desc={summary}
|
||||
metaSlot={metaBlock()}
|
||||
ogSlot={ogBlock()}
|
||||
></Layout>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user