-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
docs: update examples to use SFCs #2174
Conversation
✅ Deploy Preview for vue-router ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot for this! I took the occasion to comment on some small improvements over the existing code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot for the great work!
* docs: update examples to use SFCs (vuejs#2174) * docs: rewrite the Named Routes page (vuejs#2176)
Objectives
<script setup>
.There are lots of other changes that might be desirable, but I've tried to stick to that scope as much as possible. For the most part, the order and flow of the existing docs has been retained.
These changes need making in one big jump to keep the guide consistent. Migrating one page at a time would just make the guide highly confusing.
I am aware that big changes like these are a burden for translators. I've tried to take that into account where possible.
General changes
In many cases, the change just involved switching an existing example to use SFC syntax.
In examples that needed a
<script>
section, both Composition API and Options API examples have been provided. This is using a VitePress code group. The source.md
file ends up looking much longer, but the code group keeps the examples relatively brief in the generated docs.Mentions of
$router
or$route
have been updated, where necessary. In the templates those are retained, but in the main text they are generally replaced withrouter
androute
respectively. In cases where it seems particularly necessary there is further explanation about what those variables are, though it is already covered in theGetting Started
page at the beginning of the guide.In parts of the docs that already mentioned the Composition API, it tended to be described as 'new', or presented as an exotic or alien alternative to the Options API. Those sections also tended to predate
<script setup>
and referenced the use of asetup
function. The wording of those sections has been updated to present the use of<script setup>
as a normal way to use Vue.Specific pages
composition-api.md
- Composition APIThis is a bit of a tricky page to update. I don't want to remove the page entirely, as that would need bigger changes elsewhere, but having a separate page for the Composition API does feel a bit unnatural when it's now being used in most of the other pages.
data-fetching.md
- Data FetchingI'm not sure what to do about the examples on this page. The first one was easily updated, but it isn't clear to me how useful that example is in isolation. It doesn't really demonstrate much from a Vue Router perspective.
The second example is much more enlightening, but it only works with the Options API. It could be written using the Composition API and
defineOptions
, but as discussed in #2131, that isn't necessarily the way to go in a docs example. But I don't know what to show instead. A future plan based on data loaders doesn't really help people reading the docs today.Perhaps that second section should include a warning box that explicitly notes the lack of a Composition API example? I think that would be better than the example being conspicuously absent without an explanation.
installation.md
- InstallationThe diff on GitHub is a bit difficult to follow. All I've done is swap the order of the sections. This brings it into line with the rest of the docs, which now assume build tools and SFCs.
index.md
- Getting StartedThis is probably the most important change in this PR.
This page has been almost entirely rewritten, though the overall objective and approach is similar to the old page.
I think the
Getting Started
page is primarily aimed at beginners. Experienced users are more likely to focus on the later pages, looking for details about the specific features they're using. While we'd obviously like all pages to be understandable by beginners, I think it makes sense for theGetting Started
page to be a little more explicit in its explanations and take things a bit slower.There are a few things I've done with that in mind:
Some parts of that were inspired by this feedback about the current page: #2068 (comment).