{"id":22728209,"url":"https://github.com/nerdocs/vue-extensions","last_synced_at":"2025-04-13T21:44:07.314Z","repository":{"id":38006498,"uuid":"228103829","full_name":"nerdocs/vue-extensions","owner":"nerdocs","description":"Simple, but versatile Vue.js extension system","archived":false,"fork":false,"pushed_at":"2024-09-17T13:23:01.000Z","size":2663,"stargazers_count":10,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-09-17T16:39:52.053Z","etag":null,"topics":["extensions","hook","plugin","vue"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nerdocs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["nerdoc"],"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"lfx_crowdfunding":null,"polar":null,"buy_me_a_coffee":"nerdoc","custom":null}},"created_at":"2019-12-14T23:34:31.000Z","updated_at":"2024-09-17T13:22:29.000Z","dependencies_parsed_at":"2024-09-17T16:39:54.350Z","dependency_job_id":"697b7c46-3407-4f57-8279-6b7224536ab0","html_url":"https://github.com/nerdocs/vue-extensions","commit_stats":{"total_commits":73,"total_committers":2,"mean_commits":36.5,"dds":0.4246575342465754,"last_synced_commit":"6086320cfbceb56e80016f634a99a05995990d5a"},"previous_names":["nerdocs/vue-extensionpoints"],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nerdocs%2Fvue-extensions","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nerdocs%2Fvue-extensions/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nerdocs%2Fvue-extensions/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nerdocs%2Fvue-extensions/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nerdocs","download_url":"https://codeload.github.com/nerdocs/vue-extensions/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248788868,"owners_count":21161726,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["extensions","hook","plugin","vue"],"created_at":"2024-12-10T17:15:09.601Z","updated_at":"2025-04-13T21:44:07.283Z","avatar_url":"https://github.com/nerdocs.png","language":"JavaScript","funding_links":["https://github.com/sponsors/nerdoc","https://buymeacoffee.com/nerdoc"],"categories":[],"sub_categories":[],"readme":"# vue-extensions\n\nThis library is a Vue plugin providing a custom element which acts as extension point, with a named \"hook\". Plugins of your application then can provide \"extension\" components for this extensionpoint which are automatically found and rendered replacing the extensionpoint.\n\nThis is intended wherever you need to have a \"list\" of different looking components at one place each provided by a plugin.\n\nIf you just need a list of the same component, just with different data, don't use `vue-extensions` just use a `v-for` directive.\n\n## Install\n\nThe easiest way to install this library in your project is to use the corresponding Vue CLI plugin [extensions](https://github.com/nerdocs/vue-cli-plugin-extensions). It will do all magic for you:\n```bash\n# vue add extensions\n```\n\nThis adds everything you need automatically to your project. Just make sure that `runtimeCompiler: true` is enabled in `vue.config.js` - to use template strings in Vue.\n\nIf you choose to install everything manually, see [Manual install](manual-install.md).\n\n## Extensions\n\nExtensions are modules that export a default object with a `hooks` property, which is an array of objects, pointing to Vue components (with metadata). This seems complicated, but an example makes it much clearer:\n\n```javascript\n// extensions/FooExtension/index.js\nimport AComponent from './components/acomponent.vue'\nimport {FooElement, BazElement} from './components/othercomponents.vue'\n\nexport default {\n    hooks: {\n        \"my-list.element\": [{ component: AComponent }],\n        \"mycompany.hooks.ui.item\": [\n            { component: FooElement, weight: 2 },\n            { component: BazElement, weight: 3 }\n        ]\n    },\n    routes: [{\n      path: '/foo',\n      component: () =\u003e import('layouts/MyLayout.vue'),\n      children: [\n        { path: '', component: () =\u003e import('./pages/fooIndex.vue') }\n      ]\n    }]\n}\n```\n\n### Hooks\n\nHooks are strings that define an entry point for your extension components\nEach hook points to an array of objects which declare:\n\n* **component**: the Vue component to render.\n* **weight**: order of the component in a list. The higher the component's weight, the further it \"sinks\" down (or right) in the list.\n\nOne module can provide components for more than one hooks.\n\n### Extension points\nThere is an `\u003cextensionpoint\u003e` tag in your project available now:\n\n```html\n\u003ctemplate\u003e\n    \u003ch3\u003eExtensionpoints for \"my-list-element\" in a list:\u003c/h3\u003e\n    \u003cul\u003e\n        \u003cextensionpoint hook=\"my-list-element\"/\u003e\n    \u003c/ul\u003e\n\n    \u003ch3\u003eExtensionpoints for \"mycompany.hooks.ui.item\"\u003c/h3\u003e\n    \u003cextensionpoint hook=\"mycompany.hooks.ui.item\"/\u003e\n\u003c/template\u003e\n```\n\nThe *vue-extensions* plugin renders the hooked elements replacing the \u003cextensionpoint\u003e element, one after another. It's up to you what the extensions are rendering: One extension can render a simple `\u003cdiv\u003e` element with an image, the next extension (same hook!) can render a complicated component with variables, sub-components etc. The `\u003cextensionpoint\u003e` renders them one after another. You only have to make sure that your components do what they promise: in the sample case above, `FooListElement` should render a \\\u003cli\\\u003e element - because it will be rendered within an \\\u003cul\\\u003e element. But there are no constraints, you are free to choose.\n\n## Further usage\nThe extensions.js file (or how you choose to name it) is intended to be created automatically by a script of your choice - If you want to see a project that uses this, see my Django app [GDAPS](https://gdaps.readthedocs.io), which is a Django plugin system that can use Vue as frontend.\n\n## Development\n\nYou have an idea, improvement, found a bug? Don't hesitate to contact me. PRs and bug fixes are welcome.\n\n## License\n\n`vue-extensions` is licensed under the [MIT](https://opensource.org/licenses/mit-license.php) license\n\n#### Compiles and minifies library for production\n```\nnpm run build\n```\n\n#### Runs your tests\nCurrently there are no tests (yet), because of three important causes:\n\n* I'm lazy\n* tests are not necessary here\n* I'm lazy - did I say that already?\n\n```\nnpm run test\n```\n\n#### Lints and fixes files\n```\nnpm run lint\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnerdocs%2Fvue-extensions","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnerdocs%2Fvue-extensions","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnerdocs%2Fvue-extensions/lists"}