astro-tina 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +37 -0
- package/dist/client-tina.d.ts +3 -0
- package/dist/client-tina.js +12 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +12 -0
- package/package.json +33 -0
package/README.md
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# astro-tina
|
|
2
|
+
|
|
3
|
+
An Astro integration for Tina CMS.
|
|
4
|
+
|
|
5
|
+
At the moment, this integration only provides a client directive that only
|
|
6
|
+
hydrates React components in the Tina CMS visual editor. This allows websites
|
|
7
|
+
to support live editing without shipping React to the client.
|
|
8
|
+
|
|
9
|
+
```astro
|
|
10
|
+
<MyComponent client:tina {...props} />
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Setup
|
|
14
|
+
|
|
15
|
+
First, follow the [instructions](https://tina.io/docs/frameworks/astro) to set
|
|
16
|
+
up Tina in your Astro project.
|
|
17
|
+
|
|
18
|
+
Then, install the integration...
|
|
19
|
+
|
|
20
|
+
```
|
|
21
|
+
npm install github:dawaltconley/astro-tina
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
...and add it to your project config.
|
|
25
|
+
|
|
26
|
+
```mjs
|
|
27
|
+
import { defineConfig } from 'astro/config'
|
|
28
|
+
import react from '@astrojs/react'
|
|
29
|
+
import tina from 'astro-tina'
|
|
30
|
+
|
|
31
|
+
// https://astro.build/config
|
|
32
|
+
export default defineConfig({
|
|
33
|
+
integrations: [react(), tina()],
|
|
34
|
+
})
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
You can now hydrate components using the `client:tina` directive.
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
const clientTina = (load) => {
|
|
2
|
+
try {
|
|
3
|
+
const isEditor = window.frameElement && window.frameElement.id === 'tina-iframe';
|
|
4
|
+
if (isEditor) {
|
|
5
|
+
load().then((hydrate) => hydrate());
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
catch (e) {
|
|
9
|
+
console.error(e);
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
export default clientTina;
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
const { pathname: entrypoint } = new URL('./client-tina.js', import.meta.url);
|
|
2
|
+
export default () => ({
|
|
3
|
+
name: 'tina-cms',
|
|
4
|
+
hooks: {
|
|
5
|
+
'astro:config:setup': ({ addClientDirective }) => {
|
|
6
|
+
addClientDirective({
|
|
7
|
+
name: 'tina',
|
|
8
|
+
entrypoint,
|
|
9
|
+
});
|
|
10
|
+
},
|
|
11
|
+
},
|
|
12
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "astro-tina",
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "Support contextual editing with TinaCMS in static Astro sites.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist/**/*"
|
|
9
|
+
],
|
|
10
|
+
"scripts": {
|
|
11
|
+
"build": "npx tsc",
|
|
12
|
+
"test": "npm run build",
|
|
13
|
+
"prepublishOnly": "npm run build"
|
|
14
|
+
},
|
|
15
|
+
"keywords": [
|
|
16
|
+
"withastro",
|
|
17
|
+
"tina",
|
|
18
|
+
"tinacms",
|
|
19
|
+
"astro"
|
|
20
|
+
],
|
|
21
|
+
"author": "Dylan Awalt-Conley",
|
|
22
|
+
"license": "ISC",
|
|
23
|
+
"devDependencies": {
|
|
24
|
+
"@types/html-escaper": "^3.0.0",
|
|
25
|
+
"@types/node": "^20.5.6",
|
|
26
|
+
"astro": "^2.10.14",
|
|
27
|
+
"prettier": "^3.0.2",
|
|
28
|
+
"typescript": "^5.2.2"
|
|
29
|
+
},
|
|
30
|
+
"peerDependencies": {
|
|
31
|
+
"astro": "^2.6.0 || ^3.0.0"
|
|
32
|
+
}
|
|
33
|
+
}
|