Closed Daandelange closed 3 years ago
Hi there, good idea in general.
Quick question, tho: How should kirbyup know, which base path @
should resolve to? A simple alias to ~
wouldn't do. It would have to guess something like kirby/panel/src
in the path, which then if someone uses just panel/src
could possibly not be related to Kirby's Panel source at all. I can't think of a clean way to provide this functionality yet.
I could think of executing kirby()->roots('kirby')
to get the kirby root, but that would mean relying on php... possible ? We still need to find kirby for this though.
Parsing kirby's config files might be a bit excessive and unreliable; otherwise recursively searching folders for the kirby dir (brute force), but that might break on some very specific setups...
And/Or assume we're in a classic installation (project/kirby and project/kirby/site/plugins/plugindir) and let users change their kirby root via a preferences file ?
Executing PHP for the Kirby root is unfortunately neither a semantic, nor practical way.
I honestly don't want to include an assumption-based logic. Many plugins written aren't part of an installation, but rather outsourced into their respective repo.
For your (edge?) case, I recommend just copying Kirby's panel
folder to the same level as your plugin's JS entry. We could then add @
as an alias to ~
, which would make Kirby's internal paths work.
Thanks, didn't think about that option, even better, creating a symlink to kirby files instead of copying them.
What about making @
point to plugin/kirby
, kirby
being an optional folder or alias one can use to point to Kirby.
Meanwhile I'm curious what the kirby team's position is about extending core components.
Symlink sounds great. I'm not a fan of some custom subfolder, since @/
is common as a root directory name alias (just like ~/
). Thus, I don't intend to break an expected behavior. Symlinking panel
will work just as well.
Added a secondary alias in https://github.com/johannschopplich/kirbyup/commit/d4c479c25242d16d0b2d5fed15130cf1b8bb28f8, available in kirbyup 0.20.0+.
Please open a separate issue over at the Kirby repo for your question on Panel source reusability within Panel plugins. Thanks!
Edit: I intend to add support for a custom kirbyup.config.js
, but that will have to wait a bit.
Just to report back: Custom aliases are working perfectly ! :) Thanks for your efforts on kirbyup, it's flawless to use.
Hello, Using kirbyup for a plugin I make, I tried to import files from
kirby/panel
, which doesn't seem to be supported. My use case is to import some props and extend some Kirby Vue components (a fields-section with tabs added to it).Some of them work using relative paths (
../
) but not those that depend on other kirby mixins (and../
is installation-specific too) :import FieldsSection from "~/../../../../kirby/panel/src/components/Sections/FieldsSection.vue";
Which fails at importing@/mixins/section/section.js
. (view source: FieldsSection.vue)Kirby seems to use the
@
sign to resolvekirby/panel/src/
, which doesn't seem to conflict with kirbyup's~
path-resolver.Do you think something like that could be added to kirbyup ? One could then do :
import FieldsSection from "@/panel/src/components/Sections/FieldsSection.vue";
It would give extensions access to more custom enhancements on almost any part of the panel.Which brings me to a related question : Are we allowed to extend Kirby's core panel components ? (ping: @bastianallgeier) If not, then something like allowing to extend sections like fields could solve my particular use case, but that's out of this repo's scope.