diff --git a/ui/README.md b/ui/README.md deleted file mode 100644 index 979bb1a3..00000000 --- a/ui/README.md +++ /dev/null @@ -1,118 +0,0 @@ -# Answer - -`Answer` is a modern Q&A community application ✨ - -To learn more about the philosophy and goals of the project, visit [Answer](https://answer.dev). - -## βš™οΈ Prerequisites - -- [Node.js](https://nodejs.org/) `>=16.17` -- [pnpm](https://pnpm.io/) `>=7` - -pnpm is required by building the Answer project. To installing the pnpm tools with below commands: - -```bash -corepack enable -corepack prepare pnpm@v7.12.2 --activate -``` - -With Node.js v16.17 or newer, you may install the latest version of pnpm by just specifying the tag: - -```bash -corepack prepare pnpm@latest --activate -``` - -## πŸ”¨ Development - -clone the repo locally and run following command in your terminal: - -```shell -$ git clone git@github.com:answerdev/answer.git answer -$ cd answer/ui -$ pnpm install -$ pnpm start -``` - -now, your browser should already open automatically, and autoload `http://localhost:3000`. -you can also manually visit it. - -## πŸ‘· Workflow - -when cloning repo, and run `pnpm install` to init dependencies. you can use project commands below: - -- `pnpm start` run Answer web locally. -- `pnpm build` build Answer for production -- `pnpm lint` lint and fix the code style - -## 🌍 I18n(Multi-language) -If you need to add or edit a language entry, just go to the `/i18n/en_US.yaml` file, -all front-end language entries are placed under the `ui` field. - -If you would like to help us with the i18n translation, please visit [Answer@Crowdin](https://crowdin.com/translate/answer) - -## πŸ’‘ Project instructions - -``` -. -β”œβ”€β”€ cmd -β”œβ”€β”€ configs -β”œβ”€β”€ docs -β”œβ”€β”€ i18n - β”œβ”€β”€ en_US.yaml (basic language file) - β”œβ”€β”€ i18n.yaml (language list) -β”œβ”€β”€ internal -β”œβ”€β”€ ... -└── ui (front-end project starts here) - β”œβ”€β”€ build (built results directory, usually without concern) - β”œβ”€β”€ public (html template for public) - β”œβ”€β”€ scripts (some scripting tools on front-end project) - β”œβ”€β”€ src (almost all front-end resources are here) - β”œβ”€β”€ assets (static resources) - β”œβ”€β”€ common (project information/data defined here) - β”œβ”€β”€ components (all components of the project) - β”œβ”€β”€ hooks (all hooks of the project) - β”œβ”€β”€ i18n (Used only to initialize the front-end i18n tool) - β”œβ”€β”€ pages (all pages of the project) - β”œβ”€β”€ router (Project routing definition) - β”œβ”€β”€ services (all data api of the project) - β”œβ”€β”€ stores (all data stores of the project) - β”œβ”€β”€ utils (all utils of the project) -``` - -## 🀝 Contributing - -#### Fix Bug -If you find a bug, please don't hesitate to [submit an issue](https://github.com/answerdev/answer/issues) to us. -If you can fix it, please include a note with your issue submission. -If it is a bug definitely, you can submit your PR after we confirm it, which will ensure you don't do anything useless. - -#### Code Review & Comment -In our development, some codes are not logical we know. If you find it, please don't hesitate to submit PR to us. -In the same way, some function has no comment. We would appreciate it if you could help us supplement it. - -#### Translation -All our translations are placed in the i18n directory. - -1. If you find that the corresponding key in the language you are using does not have a translation, you can submit your translation. -2. If you want to submit a new language translation, please add your language to the `i18n.yaml` file. - -#### Features or Plugin -1. We developed the features for the plan based on the [roadmap](https://github.com/orgs/answerdev/projects/1). If you are suggestions for new functions, please confirm whether they have been planned. -2. Plugins will be available in the future, so stay tuned. - -## πŸ“±Environment Support - -| [Edge](http://godban.github.io/browsers-support-badges/)
Edge | [Firefox](http://godban.github.io/browsers-support-badges/)
Firefox | [Chrome](http://godban.github.io/browsers-support-badges/)
Chrome | [Safari](http://godban.github.io/browsers-support-badges/)
Safari | -|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| last 2 versions | last 2 versions | last 2 versions | last 2 versions | - -## ⭐ Built with -- [TypeScript](https://www.typescriptlang.org/) - strongly typed JavaScript -- [React.js](https://reactjs.org/) - Our front end is a React.js app -- [React Router](https://reactrouter.com/en/main) - Router library -- [Bootstrap](https://getbootstrap.com/) - UI library. -- [React Bootstrap](https://react-bootstrap.github.io/) - UI Library(rebuilt for React) -- [axios](https://github.com/axios/axios) - Request library -- [SWR](https://swr.bootcss.com/) - Request library -- [react-i18next](https://react.i18next.com/) - International library -- [zustand](https://github.com/pmndrs/zustand) - State-management library diff --git a/ui/src/components/Header/index.tsx b/ui/src/components/Header/index.tsx index 15a6bae9..eda36a03 100644 --- a/ui/src/components/Header/index.tsx +++ b/ui/src/components/Header/index.tsx @@ -15,6 +15,7 @@ import { Link, useNavigate, useLocation, + useMatch, } from 'react-router-dom'; import classnames from 'classnames'; @@ -35,16 +36,22 @@ import './index.scss'; const Header: FC = () => { const navigate = useNavigate(); - const { user, clear: clearUserStore } = loggedUserInfoStore(); - const { t } = useTranslation(); + const location = useLocation(); const [urlSearch] = useSearchParams(); const q = urlSearch.get('q'); + const { user, clear: clearUserStore } = loggedUserInfoStore(); + const { t } = useTranslation(); const [searchStr, setSearch] = useState(''); const siteInfo = siteInfoStore((state) => state.siteInfo); const brandingInfo = brandingStore((state) => state.branding); const loginSetting = loginSettingStore((state) => state.login); const { data: redDot } = useQueryNotificationStatus(); - const location = useLocation(); + const tagMatch = useMatch('/tags/:slugName'); + let askUrl = '/questions/ask'; + if (tagMatch && tagMatch.params.slugName) { + askUrl = `${askUrl}?tags=${tagMatch.params.slugName}`; + } + const handleInput = (val) => { setSearch(val); }; @@ -189,7 +196,7 @@ const Header: FC = () => { {t('btns.add_question')} @@ -202,7 +209,7 @@ const Header: FC = () => {