From 0661063d29c0e1dce108cac608be0ff754d2d4c1 Mon Sep 17 00:00:00 2001 From: Evan You Date: Sun, 13 Jun 2021 15:47:24 -0400 Subject: [PATCH] feat: more efficient `useData()` method that exposes all data BREAKING CHANGE: - Individual `useX()` data methods are removed. ```js // before import { useSiteDataByRoute, usePageData } from 'vitepress' const site = useSiteDataByRoute() const page = usePageData() const theme = computed(() => site.value.themeConfig) // after import { useData } from 'vitepress' const { site, page, theme } = useData() ``` All destructured values are computed refs injected from app root so they are created only once globally. - Global mixin properties (e.g. `$site`) are removed. Always use `useData()` to retrieve VitePress data. --- src/client/app/components/Debug.vue | 19 +- src/client/app/composables/frontmatter.ts | 9 - src/client/app/composables/pageData.ts | 11 - src/client/app/composables/siteData.ts | 22 - src/client/app/composables/siteDataByRoute.ts | 12 - src/client/app/data.ts | 70 + src/client/app/index.ts | 30 +- src/client/app/mixin.ts | 95 -- src/client/app/utils.ts | 5 + src/client/index.ts | 7 +- src/client/theme-default/Layout.vue | 177 +- .../components/AlgoliaSearchBox.vue | 21 +- .../theme-default/components/BuySellAds.vue | 12 +- .../theme-default/components/CarbonAds.vue | 8 +- .../theme-default/components/EditLink.vue | 14 +- src/client/theme-default/components/Home.vue | 12 +- .../theme-default/components/HomeFeatures.vue | 35 +- .../theme-default/components/HomeFooter.vue | 10 +- .../theme-default/components/HomeHero.vue | 73 +- .../theme-default/components/LastUpdated.vue | 23 +- .../theme-default/components/NavBar.vue | 18 +- .../theme-default/components/NavBarTitle.vue | 15 +- .../components/NavDropdownLink.vue | 30 +- .../components/NavDropdownLinkItem.vue | 20 +- .../theme-default/components/NavLink.vue | 16 +- .../theme-default/components/NavLinks.vue | 35 +- .../components/NextAndPrevLinks.vue | 21 +- src/client/theme-default/components/Page.vue | 10 +- .../theme-default/components/PageFooter.vue | 10 +- .../theme-default/components/SideBar.vue | 20 +- .../theme-default/components/SideBarLink.ts | 4 +- .../theme-default/components/SideBarLinks.vue | 12 +- .../components/ToggleSideBarButton.vue | 12 +- .../theme-default/composables/editLink.ts | 19 +- src/client/theme-default/composables/nav.ts | 4 +- .../theme-default/composables/navLink.ts | 6 +- .../composables/nextAndPrevLinks.ts | 11 +- src/client/theme-default/composables/repo.ts | 4 +- .../theme-default/composables/sideBar.ts | 4 +- src/client/theme-default/composables/url.ts | 13 - src/shared/config.ts | 5 +- yarn.lock | 1447 +++++++++-------- 42 files changed, 1153 insertions(+), 1248 deletions(-) delete mode 100644 src/client/app/composables/frontmatter.ts delete mode 100644 src/client/app/composables/pageData.ts delete mode 100644 src/client/app/composables/siteData.ts delete mode 100644 src/client/app/composables/siteDataByRoute.ts create mode 100644 src/client/app/data.ts delete mode 100644 src/client/app/mixin.ts delete mode 100644 src/client/theme-default/composables/url.ts diff --git a/src/client/app/components/Debug.vue b/src/client/app/components/Debug.vue index 1081e274..ce805cf3 100644 --- a/src/client/app/components/Debug.vue +++ b/src/client/app/components/Debug.vue @@ -1,16 +1,8 @@ - - + +