Skip to content

omarashzeinhom/Astro.js-Sanity-CMS-Blog.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 

Repository files navigation

Astrojs Blog In typescript & react

-Built With astro.build

Setup

  • Front End
  • Add Your Own Sanity Project ID. in astro.config.mjs
export default defineConfig({
  integrations: [
    sanity({
      projectId: "", //add your sanity project id here
      dataset: "production",
      apiVersion: "2021-03-25",
      useCdn: true,
    }),
    [react()],
    tailwind(),
  ],
  markdown: {
    smartypants: false,
    gfm: false,
    remarkPlugins: [],
    rehypePlugins: [],
    //syntaxHighlight: 'shiki',
  },
  components: {
    types: {
      unknown: "./src/pages/article/[...slug].astro",
    },
  },
});
  • Back End
  • Add Your Own Sanity Project ID. in sanity.config.ts
import { defineConfig } from "sanity";
import { deskTool } from "sanity/desk";
import { visionTool } from "@sanity/vision";
import { schemaTypes } from "./schemas";
import { markdownSchema } from "sanity-plugin-markdown";

export default defineConfig({
  name: "default",
  title: "astroBackEnd",

  projectId: "", // Add Project ID Here
  dataset: "production",

  plugins: [deskTool(), visionTool(), markdownSchema()],

  schema: {
    types: schemaTypes,
  },
});
  • Also in sanity.cli.ts
import { defineCliConfig } from "sanity/cli";

export default defineCliConfig({
  api: {
    projectId: "",
    dataset: "production",
  },
});

Front End

  • Start by
yarn run dev
  • Deploy by bash yarn build and upload ./dist/ directory to netlify

Back End

  • Start by
yarn run dev
  • Deployed Already on Sanity Just Make Sure to Make it production and also add the url of the website you deployed as authenticated to use.

References