Skip to content

Commit

Permalink
Implement TinaCms
Browse files Browse the repository at this point in the history
  • Loading branch information
eerison committed Nov 10, 2024
1 parent f7261af commit b2ec6ec
Show file tree
Hide file tree
Showing 13 changed files with 22,222 additions and 5,610 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,6 @@ pnpm-debug.log*
!.yarn/sdks
!.yarn/versions
.pnp.*

node_modules
.env
15 changes: 15 additions & 0 deletions astro.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,20 @@ import remarkCollapse from "remark-collapse";
import sitemap from "@astrojs/sitemap";
import { SITE } from "./src/config";

const tina = ({
directiveName = 'tina'
} = {}) => ({
name: 'tina-cms',
hooks: {
'astro:config:setup': ({ addClientDirective, opts }) => {

Check failure on line 14 in astro.config.ts

View workflow job for this annotation

GitHub Actions / Code standards & build (20.x)

'opts' is defined but never used
addClientDirective({
name: directiveName,
entrypoint: './client-directives/tina.ts',
})
}
}
})

// https://astro.build/config
export default defineConfig({
site: SITE.website,
Expand All @@ -15,6 +29,7 @@ export default defineConfig({
}),
react(),
sitemap(),
tina(),
],
markdown: {
remarkPlugins: [
Expand Down
17 changes: 17 additions & 0 deletions client-directives/tina.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/**
* source file: https://github.com/dawaltconley/tina-astro
*
* client-directives/tina.mjs
* @type {import('astro').ClientDirective}
*/
export default (load, opts, el) => {

Check failure on line 7 in client-directives/tina.ts

View workflow job for this annotation

GitHub Actions / Code standards & build (20.x)

'opts' is defined but never used

Check failure on line 7 in client-directives/tina.ts

View workflow job for this annotation

GitHub Actions / Code standards & build (20.x)

'el' is defined but never used
try {
const isEditor =
window.frameElement && window.frameElement.id === 'tina-iframe'
if (isEditor) {
load().then((hydrate) => hydrate())
}
} catch (e) {
console.error(e)
}
}
3 changes: 2 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ services:
image: node:20
ports:
- 4321:4321
- 4001:4001
working_dir: /app
command: npm run dev -- --host 0.0.0.0
command: npm run dev
volumes:
- ./:/app
Loading

0 comments on commit b2ec6ec

Please sign in to comment.