-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Markdown Style on the Homepage does not work properly #800
Comments
Currently, this is intentional. Homepage has different layout system then docs page. When adding content into If we want to have extra section in homepage, the idea is to add predefined section component in Homepage feature. What is your use case? What kind of things are you trying to add? |
Yes, the DOM is the same. So you get Markdown parsing, but without styles. Because there's a good chance you want to have bigger
Thanks good to know! If we want to add such section, I think it's best to wrap it inside some kind of section component. Because for example in Homepage, the max width is set to 1152px but that's way too large for normal texting. We should take care such section in a way that it looks perfectly beautiful 👍 |
if user onily need If the user just wants to add some simple descriptive language and code blocks to the front page But now they have no style, which looks very much like a bug If a custom component is recommended, it will increase the cost of getting started for newcomers Users who do this generally expect their styles to remain theme defaults |
Thanks for your reply and look forward to the final results 😄😄 |
If there is a UI design for the final home page document, I can also contribute 🚀🙋🏻♀️ |
Yeah I don't have mocks 😅 But when I create one, I'll try to make them open as possible! |
For now, you can just wrap your markdown with |
@kiaking First, thank you for the work on Vitepress. It's very powerful!
I don't like this approach. With a tool like this I would expect to be able to just add markdown like any other page or layout and have it just work. If I am using VP I am likely trying to bootstrap a site with minimal effort and maximum output. That seems like the objective of such a tool. But when I can't just add markdown to the homepage without inserting custom styles this seems like an unnecessary roadblock. |
I very much agree, the first thing the get started tells you is to create an index.md (a markdown file) so literally the first thing I tried (writting markdown), didn't work as expected, (doesn't render as markdown) with no instructions on how to get such expected behavior. I think the index.md needs to have a decent out of the box styling (which seems to be the entire value of vp), else it should just have been an index.yml file with only the frontmatter. |
Seems like it would make sense to wrap the home layout specific frontmatter content in the wider width container, and print any additional content in the normal style of every other page. It definitely feels broken that this isn't the default behaviour (Especially given there's no mention of that in the docs) |
Did anyone find a way around this using a custom container? If so, an example would be really helpful. I see the first beta is out but the larger change is still only on the roadmap. It's the only piece of the puzzle missing from going ahead with the beta, was hoping to hack it together until the permanent fix. I must admit, I hadn't needed that feature initially, because I was looking just for a docs site, but after using it I realised it is far richer than just a docs site. If I can add some info to the home page about my product then it becomes a complete out of the box site solution. |
Apologies to subscribers of this thread for the double post. Here is an example made with the current Vite Press using a docs page that resembles what would be helpful for the I also wanted to share this example, as this type of blank page with formatting is also a big help, maybe worth documenting or adding a new
|
How would this work? I've attempted this: <div class="vp-doc">
## Heading
Text
</div> As I expected, markdown isn't rendered inside the HTML tags, I see the "##" characters. What am I missing? I'm using layout: home. EDIT: I've solved this, it was a matter of inserting line breaks before and after the HTML tags for markdown to be parsed. I couldn't find any documentation on this behaviour though. I'm glad markdown isn't supported only at top-level though. |
I faced the same issue and created a component <template>
<div class="vp-doc container">
<slot />
</div>
</template>
<style scoped>
.container {
margin: auto;
width: 100%;
max-width: 1280px;
padding: 0 24px;
}
@media (min-width: 640px) {
.container {
padding: 0 48px;
}
}
@media (min-width: 960px) {
.container {
width: 100%;
padding: 0 64px;
}
}
</style> |
Yeah, it's a bit of a pain in the butt to have to re-apply all the styles, especially since the styles are scoped. Causes a lot of duplication of code and makes it a very frustrating experience just to try and provide a consistent experience. If someone wants to provide overrides for specific styles on the homepage, it might be a better idea to provide a class of some sort that they can use to override styles specifically on the homepage (like But, ultimately, there's an enormous amount of work that has to go in to add anything other than the hero and features section to the homepage. At minimum, there should at least be an option added to enable the default styles to the lower half of the page. Ultimately, the path forward should be:
|
Today, a friend(@myzf) asked me if this problem has been solved? I read the issue from cover to cover. I then came up with the following code block, which should address general usage scenarios. hope can help youyou also can see commit: ATQQ/sugar-blog@1ae39e2 add style file .home-wrapper {
margin: 0 auto;
position: relative;
width: 100%;
padding: 32px 24px 96px;
}
@media (min-width: 960px) {
.home-wrapper {
max-width: 752px;
}
}
@media (min-width: 1280px) {
.home-wrapper {
order: 1;
min-width: 640px;
}
} use in ---
layout: home
# ...Omit other attributes
---
<style scoped>
@import './home-layout-wrapper.css';
</style>
<div class="vp-doc home-wrapper">
<!-- your markdown content -->
# Heading1
\\```ts
const hello = 'world'
\\```
## Heading2
hhhh...
</div>
in my site: https://theme.sugarat.top/#%E2%9A%A1-%E5%BF%AB%E9%80%9F%E5%BC%80%E5%A7%8B you can see below |
@ATQQ Thank you very much to this friend. I tried and it was okay。At the same time, I will also provide a detailed explanation of my process below for future generations to see and accumulate experience, so as to avoid taking detours |
I have used VuePress before, which allows writing styles directly in readme.md to take effect. At that time, using VitePress was ineffective. Later, under the comments of the older brother (Lukasberbuer )above, this simple method was used. Result writing is not work!!! npm create @sugarat/theme@latest yarn create @sugarat/theme pnpm create @sugarat/theme bun create @sugarat/theme ::: |
Later on, I found out that it just doesn't support packaged markdowns, it supports native markdowns, similar to this |
Because I used it in the form of modifying the vitepress source code, not through the vitepres cli method. After careful research, as the author team mentioned above, the main reason is that the HTML style of the parsed markup conflicts with the styles of VP home and VP doc, resulting in the homepage not being able to support markup. Perhaps the author's original intention was mainly to render the markup by jumping to it instead of rendering it as HTML on the homepage. But I still suggest that for the first time I use this, I will definitely test it in index.md before continuing to use it later. I suggest that the author team add a configuration to support markdown for components other than the VPhome component. I hope this can be helpful to others who have seen this post. I hope you can understand any unreasonable remarks |
Describe the bug
Markdown on the home page does not have the correct article style
Reproduction
Expected behavior
HomePage markdown have the right Style Like docs
System Info
Additional context
Validations
The text was updated successfully, but these errors were encountered: