diff --git a/.gitignore b/.gitignore index a96a1a90..265b49a8 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,7 @@ # documentation /public/docs/**/sections.* +/public/docs/**/termDefinitions.* /public/docs/languages.* /public/docs/revisions-dev.yml /public/docs/commits-dev.yml diff --git a/README.md b/README.md index 28ae57c5..3ef60816 100644 --- a/README.md +++ b/README.md @@ -101,6 +101,10 @@ Cloudflare Worker のビルドログとステータス表示が見れますが - このセクションに関連する、想定される質問例。 # question: 自体を省略すると、GitHub ActionがGeminiを呼び出して質問例を生成しpushします。 # 質問例が不要な場合は question: [] にしてください。 + term: + - キーワード + - きーわーど + # 他のページで [[キーワード]] と書いた場合に、このセクションの内容がポップアップで表示される。 ``` * コード例はそれが配置されているセクションの内容と関連するようにする。 ````md @@ -185,7 +189,38 @@ Cloudflare Worker のビルドログとステータス表示が見れますが ```` - 練習問題のファイル名は不都合がなければ `practice(章番号)_(問題番号).拡張子` で統一。空でもよいのでファイルコードブロックとexecコードブロックを置く -## markdown仕様 +### Alert + +GitHubのalert記法の、`NOTE` `TIP` `WARNING` `CAUTION` が使えます。 +`IMPORTANT` はwarningに置き換えられます。 + +``` +> [!NOTE] +> Highlights information that users should take into account, even when skimming. +``` + +### 内部リンク + +``` +[[用語]] +``` +と書くと、`term: - 用語` が定義されている別のセクションへのリンクになり、ポップアップでその内容も表示されます。 + +markdown書式も利用可能です。 `[[ほげ**ふが**]]` は `term: - ほげふが` へのリンクになり、表示は「ほげ**ふが**」になります。ただし `**[[ふが]]**` はリンクの色が優先されるのに対し `[[**ふが**]]` は強調の色が優先されます。 + +``` +[[./1-foo]] +[[./1]] +``` +と書くと、同じ言語のページID `1-foo` またはindex `1` (ページのindexはindex.ymlの記述順で0-based) へのリンクになり、表示は「第1章」になります + +``` +[[./prev]] +[[./next]] +``` +と書くと、同じ言語の前のページ・次のページへのリンクになり、表示は「第1章」(実際の章番号)になります + +### コード実行環境仕様 実行環境の説明は ./packages/runtime/README.md を参照 diff --git a/app/(docs)/@chat/chat/[chatId]/chatArea.tsx b/app/(docs)/@chat/chat/[chatId]/chatArea.tsx index e3300cc9..0f5413b0 100644 --- a/app/(docs)/@chat/chat/[chatId]/chatArea.tsx +++ b/app/(docs)/@chat/chat/[chatId]/chatArea.tsx @@ -4,9 +4,10 @@ import { ChatAreaStateUpdater } from "@/(docs)/chatAreaState"; import { useStreamingChatContext } from "@/(docs)/streamingChatContext"; import { deleteChatAction } from "@/actions/deleteChat"; import { ChatWithMessages } from "@/lib/chatHistory"; -import { LanguageEntry, MarkdownSection, PageEntry } from "@/lib/docs"; +import { LangId, MarkdownSection, PageSlug } from "@/lib/docs"; import { Heading } from "@/markdown/heading"; import { StyledMarkdown } from "@/markdown/markdown"; +import { usePagesListForLang } from "@/pagesListContext"; import clsx from "clsx"; import Link from "next/link"; import { useRouter } from "next/navigation"; @@ -70,12 +71,15 @@ export function ChatAreaContainer(props: { interface Props { chatId: string; chatData: ChatWithMessages; - targetLang: LanguageEntry | undefined; - targetPage: PageEntry | undefined; + langId: LangId; + pageSlug: PageSlug; targetSection: MarkdownSection | undefined; } export function ChatAreaContent(props: Props) { - const { chatId, chatData, targetLang, targetPage, targetSection } = props; + const { chatId, chatData, langId, pageSlug, targetSection } = props; + + const langEntry = usePagesListForLang(langId); + const pageEntry = langEntry?.pages.find((p) => p.slug === pageSlug); const messagesAndDiffs = [ ...chatData.messages.map((msg) => ({ type: "message" as const, ...msg })), @@ -97,13 +101,13 @@ export function ChatAreaContent(props: Props) {