Skip to content
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

refactor(theme-default): set theme data in client config (close #946) #1052

Closed
wants to merge 2 commits into from

Conversation

meteorlxy
Copy link
Member

@meteorlxy meteorlxy commented Aug 25, 2022

close vuepress/ecosystem#58

BREAKING CHANGE: now you should set default theme locales data in .vuepress/client.ts via defineThemeData
BREAKING CHANGE: now plugin-theme-data does not need options anymore

@meteorlxy meteorlxy force-pushed the client-config branch 3 times, most recently from c9f9d59 to fe5f4c5 Compare August 26, 2022 16:52
@devPRS
Copy link

devPRS commented Sep 10, 2022

@meteorlxy Anxiously waiting for this one to come through, will be an amazing change 💯

@devPaulRS
Copy link

@meteorlxy Any chance of this getting some love? It's been a few months.

@meteorlxy
Copy link
Member Author

Busy working these days. Will be back to this soon.

BREAKING CHANGE: now you should set default theme locales data in `.vuepress/client.ts` via `defineThemeData`
BREAKING CHANGE: now `plugin-theme-data` does not need options anymore
@Mister-Hope
Copy link
Member

Mister-Hope commented Dec 9, 2022

We shall not remove the old plugin as it's total reasonale to read the options both side.

Some options may related to temp file generating and assets handling.

Examples

Tree shakable

A simple example is editLink for @vuepress/theme-default, overriding it in pages is a rare case, and in most cases we are expecting users to set it globally.

So for a third party theme, it might drop frontmatter support, so that when users set editLink: false in options, the theme no longer need to append filePathRelative information to page data in extendsPage hook.

The above example is simple, but actions like this can improve "Tree shaking" ability and reduce the final output bundle size. Any global option controlling something all have a chance to do some "tree shakable" work, droping unneeded code.

Node based operations

Some features may related to node based api, and can not be handled at client side, for example, my theme vuepress-theme-hope has a feature called "Structured Sidebar", which generate sidebar from file structure automatically. in such cases, users options must be parsed into node side, then passed to client side after edited.


So I suggest @meteorlxy reconsidered plugin-theme-data rebuilt, old features and behaviors can be (and should be ) preserved when adding the new one.

@devPaulRS
Copy link

devPaulRS commented Dec 9, 2022

@Mister-Hope | @meteorlxy

All it needs to allow for that i need myself, is that if add a new MD file that it automatically picks it up, the navigation bar automatically updates and that it doesn't need a server restart for it.

I also get the files automatically tree into the navigation, but every time i do it required a restart to display on the menu, this does not make sense, it should be automatic and dynamic, as long as we can achieve that then i'm satisfied.

Ofcourse, however you guys decide to go about it, if it's part of a greater change, it would be very helpful.. it's desperately needed.

@devPaulRS
Copy link

devPaulRS commented Feb 22, 2023

@Mister-Hope I've been scratching my head at this for a while and I've tried a lot of ways to get past it, but it seems like i just can't get the navigation to be dynamic.

Do you have any suggestions that i can try to temporarily alleviate the problem, this wasn't a issue in webpack because of hot reload but in vite this is a problem because i can't access the hot reload in the config.

Even if it means that the server restarts after a new page at this point i have to manually do that, do you have any ideas that i can use besides re-making the entire navigation?

  1. Injecting navigation items and manually enforce this to occur
  2. Forcing server restart to occur (via script)

Watchers don't detect or should i say trigger the navigation to update in the config so i'm at a loss.

What i'm trying to do:

Adding a page should automatically be added to the navigation without restarting it, but if it does need a restart (for now) for it to be automatic.

@Mister-Hope
Copy link
Member

The problem is that pageRoutes can not be hmred, so if you add new page, a restart is expected.

@devPaulRS
Copy link

devPaulRS commented Feb 22, 2023

@Mister-Hope
What can i use to enforce a restart in this case then? e.g code calls function > tells server to restart/reload.

@Radiergummi
Copy link

@Mister-Hope I'm kind of facing the same problem, but even more basic. All I want to do is fetch pages from a CMS and add them to the navigation bar, but I can't find a way to modify the navbar programmatically. How did you go about this?

@devPaulRS
Copy link

@Radiergummi A alternative is to remake the navigation, i did so for mine and i use a json to fill the gap, json being generated by a listener.

But i agree, shouldn't be the case and VuePress should be able to do it Programatically even if i inject it.

@meteorlxy
Copy link
Member Author

meteorlxy commented Dec 3, 2023

Closing as we have migrated default theme into another repo

@meteorlxy meteorlxy closed this Dec 3, 2023
@meteorlxy meteorlxy deleted the client-config branch December 3, 2023 16:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature request] Client config
5 participants