Coder Social home page Coder Social logo

sanity-io / sanity-template-astro-clean Goto Github PK

View Code? Open in Web Editor NEW
86.0 15.0 27.0 933 KB

Clean starter template with Astro

Home Page: https://template-astro-clean.sanity.build/

JavaScript 15.61% Astro 62.46% TypeScript 21.93%
team-ecosystem astro astrojs sanity sanity-io typescript

sanity-template-astro-clean's Introduction

A minimal Astro site with Sanity Studio

This starter uses Astro for the front end and Sanity to handle its content.

Featuring

Prerequisites

Getting started

Run the following commands

  1. npm install to install dependencies

  2. npx sanity@latest init --env, this will:

    • ask you to select or create a Sanity project and dataset
    • output a .env file with appropriate variables
    • (or use sanity init --env if you have the CLI installed)
  3. Rename the variables in the .env file:

    • SANITY_STUDIO_PROJECT_ID → PUBLIC_SANITY_STUDIO_PROJECT_ID
    • SANITY_STUDIO_DATASET → PUBLIC_SANITY_STUDIO_DATASET
  4. npm run dev to start the development server

Your Astro app should now be running on http://localhost:4321/ and Studio on http://localhost:4321/admin.

Add content

  1. Visit the Studio and create and publish a new Post document
  2. Visit the homepage and refresh the page to see your content rendered on the page

The schema for the Post document is defined in the /schema folder. You can add more document types to the Studio to suit your needs.

Removing TypeScript

If you do not wish to use TypeScript, we've included a remove-typescript.mjs file in the root of this repository. You can run this file with node remove-typescript.mjs to strip all types from this project. Please run this before tampering with any code to ensure that all types are properly removed.

If you intend to use TypeScript, you can safely remove the remove-typescript.mjs file.

Removing the embedded Studio

If you wish to manage and host the Studio separately, you remove the studioBasePath property for the sanity configuration in astro.config.mjs. You can also remove the following dependencies:

  • output in astro.config.mjs
    • …and adapter in astro.config.mjs
  • react() in astro.config.mjs
  • @sanity/vision react react-dom @types/react @types/react-dom from package.json
  • schema folder (you might want to copy this to the new Studio location)
  • sanity.config.ts (you might want to copy this to the new Studio location)

Deployments

Feel free to deploy the App to whichever hosting provider you prefer (Vercel, Netlify, Cloudflare, etc). Remember to change the adapter in the astro.config.mjs file to match your hosting provider.

Deploying the Studio on *.sanity.studio

You can also deploy the Sanity Studio on its own URL by running npx sanity deploy, provided you have added a sanity.cli.ts configuration file:

// sanity.cli.ts
import { defineCliConfig } from "sanity/cli";

export default defineCliConfig({
  api: {
    projectId: "<your-project-id>",
    dataset: "<your-dataset-name>",
  },
});

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.