vuejs / vitepress

Vite & Vue powered static site generator.
https://vitepress.dev
MIT License
11.48k stars 1.86k forks source link

Enter the secondary page link, and the page content is displayed incorrectly #1668

Closed NoiseFan closed 1 year ago

NoiseFan commented 1 year ago

Describe the bug

Directly accessing the three-tier link in the browser will directly display the content of the home page

Reproduction

Direct access in browser

https://docs.mc6d.com/advanced/logicalExpression Recurrence address

image

Expected behavior

Open the specified page content without displaying the home page content

System Info

System:
    OS: Linux 5.4 Ubuntu 20.04 LTS (Focal Fossa)
    CPU: (2) x64 Intel(R) Xeon(R) Platinum 8255C CPU @ 2.50GHz
    Memory: 2.00 GB / 3.84 GB
    Container: Yes
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 18.4.0 - /usr/bin/node
    npm: 8.13.1 - /usr/local/bin/npm

Additional context

No response

Validations

brc-dd commented 1 year ago

Can you share its code? Also please specify which VitePress version are you using.

NoiseFan commented 1 year ago

https://github.com/NoiseFan/mugeda_docs

1.0.0-alpha.19

NoiseFan commented 1 year ago

It can be reproduced in the production environment, but it is no problem in the development environment

NoiseFan commented 1 year ago

I just upgraded vitepress v1.0.0-alpha.29, but this problem still exists

brc-dd commented 1 year ago

Seems like an issue with the formatting of your markdown. If I format it to this, then everything work as expected:

Code `````md # 逻辑表达式 ## 概述 逻辑表达式可进行取值、运算、判断三个功能,更为重要的是满足较为复杂的判断场景。 ### 使用场景 1. 取值:例如在获取舞台上任意元素属性值到文本上 2. 运算:多个文本的累加计算 3. 判断:`提交表单`配合`本地数据`功能时来控制提交次数 4. 判断:制作接东西案例时判断目标物体和期望物体是否被接到 ## 取值 获取命名元素的属性,例如文本取值、位置、高度、颜色等属性 ### 基础语法 ```js {{ obj.text }} // {{物体名称.属性}} ``` ::: danger :heavy_exclamation_mark: 逻辑表达式必须使用英文符号 ::: #### 常用属性 | 语法 | 含义 | | ---------- | ---------------- | | `a.top` | a 物体上坐标 | | `a.left` | a 物体的左坐标 | | `a.height` | a 物体的高度 | | `a.width` | a 物体的宽度 | | `a.text` | a 物体的文本取值 | #### 其他属性 | 语法 | 含义 | | --------------- | --------------------------- | | `a.id` | a 物体的 ID | | `a.alpha` | a 物体的透明度 | | `a.background` | a 物体的背景颜色,rgba 数值 | | `a.rotate` | a 物体的 Z 轴旋转角度 | | `a.rotateX` | a 物体的 X 轴旋转角度 | | `a.rotateY` | a 物体的 Y 轴旋转角度 | | `a.scaleX` | a 物体的 X 轴缩放 | | `a.scaleY` | a 物体的 Y 轴缩放 | | `a.scrollSpeed` | a 段落的滚动速度 | | `a.src` | a(图、音、视频)的链接 URL | ::: info `a.scrollSpeed`必须开启段落的`文字超出时`滚动的选项 ::: ## 算术运算符 算术运算符主要是常见的基础运算符符号,更为复杂的运算符,例如位运算符需使用`JacaScript`进行书写 | 符号 | 含义 | | ---- | ------------ | | + | 加号 | | - | 减号 | | \* | 乘号 | | / | 除号 | | % | 取模(余数) | ### 示例 ```js // 数值和数值的运算 1 + 1 // 2 // 数值和数字的运算 1 + {{a.text}} // 1加上a的文本取值 // 数值和数字的运算 {{a.text}} + {{b.text}} // a的文本取值加上b的文本取值 // 拼接字符 {{a.text}}{{b.text}} // a的文本拼接b的文本 ``` ::: tip 在运算过程中以加法举例,数字+数字得到的结果是两数之和,数字加字符和字符加字符的结果是拼接字符 ::: ## 逻辑运算符 在逻辑表达式中核心就是逻辑运算符,通过逻辑运算符可以制作较为复杂逻辑判断,支持两个或多个值不同条件的判断,更为复杂的请期待[高级教程](/senior/)的介绍。 | 符号 | 含义 | | ---- | -------- | | == | 等于 | | !== | 不等于 | | != | 不等于 | | >= | 大于等于 | | <= | 小于等于 | | > | 大于 | | < | 小于 | | \|\| | 或 | | && | 并且 | ### 返回值 逻辑运算符返回值是`Boolean`类型,作用在行为的`执行条件 - 逻辑表达式`,或取值中使用 ```js // 例如 a = 1 b = 1 {{a.text}} == {{b.text}} // 返回值为true {{a.text}} !== {{b.text}} // 返回值为false ``` ### 基础逻辑运算示例 逻辑表达式支持变量与变量的判断,也同时支持变量与值进行判断 ```js // 等于逻辑运算 {{a.text}} == {{b.text}} // 变量与变量的判断 // 不等于逻辑运算 {{a.text}} !== 1 // 变量与值进行判断 // 小于逻辑运算 {{a.text}} < {{b.text}} // 大于等于逻辑运算 {{a.text}} >= {{b.text}} ``` ### 复合逻辑运算 支持两个或多个表达式同时进行判断 ```js // 或者逻辑运算 {{a.text}} == 1 || {{b.text}} == {{d.text}} // 满足任意条件即返回true // 并且逻辑运算 {{a.text}} == {{b.text}} && {{c.text}} == 3 // 满足全部条件即返回true ``` ## 实操案例 ### 移入移出案例 该案例是判断小球位置是否在指定区域内,通过分情况讨论的方式,将复杂的逻辑判断拆分多段表达式。尝试练习本次案例,相信你能更熟练的掌握逻辑表达式的使用方法 `````
NoiseFan commented 1 year ago

Thank you very much for your reply. I'll try

brc-dd commented 1 year ago

Seems like the main error was * being not escaped inside the table, which was messing up the parsing.

image

NoiseFan commented 1 year ago

I deleted the md file and the problem still exists after rebuilding.

NoiseFan commented 1 year ago

Please try this link

https://docs.mc6d.com/advanced/screenshot

brc-dd commented 1 year ago

Looks like you made the code private (or deleted the repo)? Have you tried formatting your docs/advanced/screenshot.md file? You can use prettier for that.

NoiseFan commented 1 year ago

I'll try again

NoiseFan commented 1 year ago

I delete all the pages and keep a new md file, which can still be reproduced

Take a look at the debugger branch

https://docs.mc6d.com/advanced/debugger

zRains commented 1 year ago

感觉这个问题很有趣,我发现多级的路由请求会产生这种问题,但结尾加个html后缀可解决:

https://docs.mc6d.com/advanced/debugger.html

待我探索一下:P

NoiseFan commented 1 year ago

能不能跟Nginx配置有关?

Can it be related to Nginx configuration?

NoiseFan commented 1 year ago

location / { root xxx/docs/.vitepress/dist/; index index.html; try_files $uri $uri/ /index.html; }

zRains commented 1 year ago

可能是这个cleanUrls参数引起,文档标注:

For it to work, your server must serve the generated page on requesting the URL (see above table) without a redirect.

try_files产生了重定向,导致页面出现了错误。这个是试验性功能,等稳定后看看。如有错误多多包涵。

yyx990803 commented 1 year ago

看起来是 cleanUrls 的问题,需要确保服务器配置正确。https://vitepress.dev/guide/routing#generating-clean-url