Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
296 changes: 296 additions & 0 deletions apps/web/client/CommunityBoard.tsx

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions apps/web/client/app.css

Large diffs are not rendered by default.

91 changes: 91 additions & 0 deletions apps/web/client/community.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions apps/web/client/community.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<!doctype html>
<html lang="zh-CN" class="practice-root">
<head>
<meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="theme-color" content="#f5f4ee"><meta name="referrer" content="no-referrer">
<title>社区开放解题 · TheoremOS</title><link rel="icon" type="image/svg+xml" href="assets/favicon.svg">
<script src="theme.js"></script><link rel="stylesheet" href="app.css"><link rel="stylesheet" href="researchPractice.css"><link rel="stylesheet" href="community.css">
</head>
<body class="practice-page">
<a class="skip-link" href="#main">跳到主要内容</a>
<header class="topbar"><a class="brand" href="./" aria-label="TheoremOS"><img src="assets/mark.svg" alt="" width="26" height="26"><span>Theorem<span class="brand-os">OS</span></span></a>
<nav aria-label="TheoremOS"><a href="community.html?lang=en" class="locale-switch" data-community-language>English</a><a href="./" class="button" data-community-home>打开工作台</a></nav></header>
<main id="main" tabindex="-1"><div id="community-root"></div><noscript><p>请启用 JavaScript 查看社区题目。 Enable JavaScript to see the community board.</p></noscript></main>
<script src="community.js" type="module"></script>
</body>
</html>
17 changes: 17 additions & 0 deletions apps/web/client/community.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { h, render } from 'preact';
import { CommunityBoard } from './CommunityBoard';
import { locale, otherLocale } from '../i18n';

const explicit = new URLSearchParams(location.search).get('lang');
const language = explicit === 'zh' || explicit === 'en' ? explicit : locale;
const tx = (zh: string, en: string) => language === 'en' ? en : zh;
document.documentElement.lang = language === 'en' ? 'en' : 'zh-CN';
document.title = tx('社区开放解题 · TheoremOS', 'Community open problems · TheoremOS');
const root = document.getElementById('community-root');
if (root) render(h(CommunityBoard, { language }), root);
const home = document.querySelector<HTMLAnchorElement>('[data-community-home]');
if (home) { home.textContent = tx('打开工作台', 'Open the workbench'); home.href = `./?lang=${language}`; }
const languageLink = document.querySelector<HTMLAnchorElement>('[data-community-language]');
if (languageLink) { languageLink.textContent = otherLocale.label; languageLink.href = `community.html?lang=${otherLocale.locale}${location.hash}`; }
const skip = document.querySelector<HTMLAnchorElement>('.skip-link');
if (skip) skip.textContent = tx('跳到主要内容', 'Skip to main content');
Loading
Loading