{"id":13805235,"url":"https://github.com/hotmeteor/inertia-statamic","last_synced_at":"2025-05-13T19:30:34.268Z","repository":{"id":41231138,"uuid":"363693242","full_name":"hotmeteor/inertia-statamic","owner":"hotmeteor","description":"An Inertia.js adapter for Statamic.","archived":true,"fork":false,"pushed_at":"2022-10-24T12:20:41.000Z","size":39,"stargazers_count":55,"open_issues_count":6,"forks_count":9,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-08-04T01:04:39.384Z","etag":null,"topics":["inertiajs","inertiajs-adapter","laravel","statamic","statamic-addon"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hotmeteor.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-05-02T16:10:19.000Z","updated_at":"2024-05-31T08:58:43.000Z","dependencies_parsed_at":"2022-07-09T19:46:07.874Z","dependency_job_id":null,"html_url":"https://github.com/hotmeteor/inertia-statamic","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hotmeteor%2Finertia-statamic","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hotmeteor%2Finertia-statamic/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hotmeteor%2Finertia-statamic/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hotmeteor%2Finertia-statamic/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hotmeteor","download_url":"https://codeload.github.com/hotmeteor/inertia-statamic/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225254286,"owners_count":17445159,"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":["inertiajs","inertiajs-adapter","laravel","statamic","statamic-addon"],"created_at":"2024-08-04T01:00:58.959Z","updated_at":"2024-11-18T21:30:56.542Z","avatar_url":"https://github.com/hotmeteor.png","language":"PHP","funding_links":[],"categories":["Adapters"],"sub_categories":["Server-side"],"readme":"# Inertia.js adapter for Statamic\n\n[Statamic](https://statamic.com) server side adapter for [Inertia.js](https://inertiajs.com) to build single-page apps, without building an API.\n\n[![Latest Stable Version](https://poser.pugx.org/hotmeteor/inertia-statamic/v)](//packagist.org/packages/hotmeteor/inertia-statamic)\n\n## Installation\n\nYou can install the package through Composer.\n\n```bash\ncomposer require hotmeteor/inertia-statamic\n```\n\n## Usage\n\n### Setup\n\nThe Inertia adapter works for any page or entry content available through Statamic Collections.\n\nBy default, all Inertia-enabled pages will be expecting an `app` template, which should be located at `resources/views/app.blade.php`. This is the base page that any Inertia app is looking for, and should contain the `@inertia` directive. The template can be defined either at the collection or page level, but it must be `app`.\n\n```blade\n\u003c!DOCTYPE html\u003e\n\u003chtml\u003e\n  \u003chead\u003e\n    \u003cmeta charset=\"utf-8\" /\u003e\n    \u003cmeta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, maximum-scale=1.0\" /\u003e\n    \u003clink href=\"{{ mix('/css/app.css') }}\" rel=\"stylesheet\" /\u003e\n    \u003cscript src=\"{{ mix('/js/app.js') }}\" defer\u003e\u003c/script\u003e\n  \u003c/head\u003e\n  \u003cbody\u003e\n    @inertia\n  \u003c/body\u003e\n\u003c/html\u003e\n```\n\nIn your `app.js` file you must set up your Inertia app and reference where your Vue pages will live:\n```js\n// app.js\n\nimport { createApp, h } from 'vue'\nimport { App, plugin } from '@inertiajs/inertia-vue3'\n\nconst el = document.getElementById('app')\n\ncreateApp({\n  render: () =\u003e h(App, {\n    initialPage: JSON.parse(el.dataset.page),\n    resolveComponent: name =\u003e require(`./Pages/${name}`).default,\n  })\n}).use(plugin).mount(el)\n```\n\nFinally, you need to create a `Pages` folder in `resources/js`. This is where your app will be looking for Vue components that match the resolved naming of your Statamic pages.\n\n```sh\n|_ resources\n    |_ js\n        |_ Pages\n            |_ About\n                |_ Team.vue\n            |_ Home.vue             \n```\n\nBoth [server-side setup](https://inertiajs.com/server-side-setup) and [client-side setup](https://inertiajs.com/client-side-setup) full instructions are available on Inertia's website.\n\n### Component Naming\n\nAs you can see in the folder structure above, your Vue component naming and location must match the Statamic collection hierarchy + page slug combo for any Inertia-enabled pages. The adapter will automatically build these paths based on the page's URL and slug.\n\nHere are some examples of what this looks like:\n\nStatamic Collection | Statamic Page | Slug | URL | Component Name\n------------ | ------------- | ------------- | ------------- | -------------\nHome | Home | `home` | / | `Home.vue`\nMarketing | Overview | `overview` | /marketing/ | `Marketing/Overview.vue`\nMarketing | Logos and Colors | `logos-and-colors` | /marketing/logos | `Marketing/LogosAndColors.vue`\n\n### Props\n\nAll the typical data passed to a Statamic page as objects will now be available to your page as `props`. The `props` will contain all of the expected attributes and data. For example, the Inertia response's `props` object could look like:\n\n```php\nInertia\\Response {#2587 ▼\n  #component: \"Marketing/Overview\"\n  #props: array:22 [▼\n    \"amp_url\" =\u003e null\n    \"api_url\" =\u003e null\n    \"collection\" =\u003e array:3 [▶]\n    \"content\" =\u003e array:4 [▶]\n    \"date\" =\u003e Illuminate\\Support\\Carbon @1617827556 {#2478 ▶}\n    \"edit_url\" =\u003e \"http://mysite.test/cp/collections/marketing/entries/f854a1cf-0dcf-404b-8418-a74662ba77e7/overview\"\n    \"id\" =\u003e \"f854a1cf-0dcf-404b-8418-a74662ba77e7\"\n    \"is_entry\" =\u003e true\n    \"last_modified\" =\u003e Illuminate\\Support\\Carbon @1617827556 {#2477 ▶}\n    \"mount\" =\u003e null\n    \"order\" =\u003e null\n    \"parent\" =\u003e null\n    \"permalink\" =\u003e \"http://mysite.test/marketing\"\n    \"private\" =\u003e false\n    \"published\" =\u003e true\n    \"slug\" =\u003e \"overview\"\n    \"template\" =\u003e \"app\"\n    \"title\" =\u003e \"Overview\"\n    \"updated_at\" =\u003e Illuminate\\Support\\Carbon @1617827556 {#2523 ▶}\n    \"updated_by\" =\u003e array:4 [▶]\n    \"uri\" =\u003e \"/marketing\"\n    \"url\" =\u003e \"/marketing\"\n  ]\n  #rootView: \"app\"\n  #version: \"\"\n  #viewData: []\n}\n```\n\n## Credits\n\n- [Adam Campbell](https://github.com/hotmeteor)\n- [Statamic](https://statamic.com)\n- [The amazing Inertia.js libraries](https://github.com/inertiajs)\n- [All Contributors](../../contributors)\n\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhotmeteor%2Finertia-statamic","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhotmeteor%2Finertia-statamic","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhotmeteor%2Finertia-statamic/lists"}