{"id":24978209,"url":"https://github.com/davidcreador/personal-blog","last_synced_at":"2025-03-29T09:15:29.978Z","repository":{"id":40843371,"uuid":"249807957","full_name":"Davidcreador/personal-blog","owner":"Davidcreador","description":null,"archived":false,"fork":false,"pushed_at":"2023-01-05T17:00:32.000Z","size":5004,"stargazers_count":1,"open_issues_count":13,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-03T23:51:40.671Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Davidcreador.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-03-24T20:13:36.000Z","updated_at":"2023-03-07T17:02:11.000Z","dependencies_parsed_at":"2023-02-04T08:01:51.529Z","dependency_job_id":null,"html_url":"https://github.com/Davidcreador/personal-blog","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Davidcreador%2Fpersonal-blog","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Davidcreador%2Fpersonal-blog/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Davidcreador%2Fpersonal-blog/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Davidcreador%2Fpersonal-blog/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Davidcreador","download_url":"https://codeload.github.com/Davidcreador/personal-blog/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246162150,"owners_count":20733357,"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":[],"created_at":"2025-02-03T23:51:45.105Z","updated_at":"2025-03-29T09:15:29.957Z","avatar_url":"https://github.com/Davidcreador.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# A statically generated blog example using Next.js and DatoCMS\n\nThis example showcases Next.js's [Static Generation](https://nextjs.org/docs/basic-features/pages) feature using [DatoCMS](https://www.datocms.com/) as the data source.\n\n## Demo\n\n[https://next-blog-datocms.now.sh/](https://next-blog-datocms.now.sh/)\n\n### Related examples\n\n- [Blog Starter](/examples/blog-starter)\n- [Sanity](/examples/cms-sanity)\n- [TakeShape](/examples/cms-takeshape)\n\n## How to use\n\n### Using `create-next-app`\n\nExecute [`create-next-app`](https://github.com/zeit/next.js/tree/canary/packages/create-next-app) with [npm](https://docs.npmjs.com/cli/init) or [Yarn](https://yarnpkg.com/lang/en/docs/cli/create/) to bootstrap the example:\n\n```bash\nnpm init next-app --example cms-datocms cms-datocms-app\n# or\nyarn create next-app --example cms-datocms cms-datocms-app\n```\n\n### Download manually\n\nDownload the example:\n\n```bash\ncurl https://codeload.github.com/zeit/next.js/tar.gz/canary | tar -xz --strip=2 next.js-canary/examples/cms-datocms\ncd cms-datocms\n```\n\n## Configuration\n\n### Step 1. Create an account and a project on DatoCMS\n\nFirst, [create an account on DatoCMS](https://datocms.com).\n\nAfter creating an account, create a **new project** from the dashboard. You can select a **Blank Project**.\n\n### Step 2. Create an `Author` model\n\nFrom the project setting page, create a new **Model**.\n\n- The name should be `Author`.\n\nNext, add these fields (you don't have to modify the settings):\n\n- `Name` - **Text** field (**Single-line String**)\n- `Picture` - **Media** field (**Single asset**)\n\n### Step 3. Create a `Post` model\n\nFrom the project setting page, create a new **Model**:\n\n- The name should be `Post`.\n- **Important:** From the \"Additional Settings\" tab, turn on **Enable draft/published system.** This lets you preview the content.\n\nNext, add these fields (you don't have to modify the settings unless specified):\n\n- `Title` - **Text** field (**Single-line String**)\n- `Content` - **Text** field (**Multiple-paragraph Text**)\n- `Excerpt` - **Text** field (**Single-line String**)\n- `Cover Image` - **Media** field (**Single asset**)\n- `Date` - **Date and time** field (**Date**)\n- `Author` - **Links** field (**Single link**) , and from the \"Validations\" tab under \"Accept only specified model\", select **Author**.\n- `Slug` - **SEO** field (**Slug**), and from the \"Validations\" tab under \"Reference field\" select **Title**.\n\n### Step 4. Populate Content\n\nFrom the **Content** menu at the top, select **Author** and create a new record.\n\n- You just need **1 Author record**.\n- Use dummy data for the text.\n- For the image, you can download one from [Unsplash](https://unsplash.com/).\n\nNext, select **Post** and create a new record.\n\n- We recommend creating at least **2 Post records**.\n- Use dummy data for the text.\n- You can write markdown for the **Content** field.\n- For the images, you can download ones from [Unsplash](https://unsplash.com/).\n- Pick the **Author** you created earlier.\n\n**Important:** For each post record, you need to click **Publish** after saving. If not, the post will be in the draft state.\n\n### Step 5. Set up environment variables\n\nGo to the **Settings** menu at the top and click **API tokens**.\n\nThen click **Read-only API token** and copy the token.\n\nNext, copy the `.env.example` file in this directory to `.env` (which will be ignored by Git):\n\n```bash\ncp .env.example .env\n```\n\nThen set each variable on `.env`:\n\n- `NEXT_EXAMPLE_CMS_DATOCMS_API_TOKEN` should be the API token you just copied.\n- `NEXT_EXAMPLE_CMS_DATOCMS_PREVIEW_SECRET` can be any random string (but avoid spaces), like `MY_SECRET` - this is used for [the Preview Mode](https://nextjs.org/docs/advanced-features/preview-mode).\n\nYour `.env` file should look like this:\n\n```bash\nNEXT_EXAMPLE_CMS_DATOCMS_API_TOKEN=...\nNEXT_EXAMPLE_CMS_DATOCMS_PREVIEW_SECRET=...\n```\n\n### Step 6. Run Next.js in development mode\n\n```bash\nnpm install\nnpm run dev\n\n# or\n\nyarn install\nyarn dev\n```\n\nYour blog should be up and running on [http://localhost:3000](http://localhost:3000)! If it doesn't work, post on [GitHub discussions](https://github.com/zeit/next.js/discussions).\n\n### Step 7. Try preview mode\n\nOn DatoCMS, go to one of the posts you've created and:\n\n- **Update the title**. For example, you can add `[Draft]` in front of the title.\n- Click **Save**, but **DO NOT** click **Publish**. By doing this, the post will be in the draft state.\n\n(If it doesn't become draft, you need to go to the model settings for `Post`, go to **Additional Settings**, and turn on **Enable draft/published system**.)\n\nNow, if you go to the post page on localhost, you won't see the updated title. However, if you use the **Preview Mode**, you'll be able to see the change ([Documentation](https://nextjs.org/docs/advanced-features/preview-mode)).\n\nTo enable the Preview Mode, go to this URL:\n\n```\nhttp://localhost:3000/api/preview?secret=\u003csecret\u003e\u0026slug=\u003cslug\u003e\n```\n\n- `\u003csecret\u003e` should be the string you entered for `NEXT_EXAMPLE_CMS_DATOCMS_PREVIEW_SECRET`.\n- `\u003cslug\u003e` should be the post's `slug` attribute (you can check on DatoCMS).\n\nYou should now be able to see the updated title. To exit the preview mode, you can click **Click here to exit preview mode** at the top.\n\n### Step 8. Deploy on ZEIT Now\n\nYou can deploy this app to the cloud with [ZEIT Now](https://zeit.co/import?filter=next.js\u0026utm_source=github\u0026utm_medium=readme\u0026utm_campaign=next-example) ([Documentation](https://nextjs.org/docs/deployment)).\n\nTo deploy on ZEIT Now, you need to set the environment variables with **Now Secrets** using [Now CLI](https://zeit.co/download) ([Documentation](https://zeit.co/docs/now-cli#commands/secrets)).\n\nInstall [Now CLI](https://zeit.co/download), log in to your account from the CLI, and run the following commands to add the environment variables. Replace `\u003cNEXT_EXAMPLE_CMS_DATOCMS_API_TOKEN\u003e` and `\u003cNEXT_EXAMPLE_CMS_DATOCMS_PREVIEW_SECRET\u003e` with the corresponding strings in `.env`.\n\n```\nnow secrets add next_example_cms_datocms_api_token \u003cNEXT_EXAMPLE_CMS_DATOCMS_API_TOKEN\u003e\nnow secrets add next_example_cms_datocms_preview_secret \u003cNEXT_EXAMPLE_CMS_DATOCMS_PREVIEW_SECRET\u003e\n```\n\nThen push the project to GitHub/GitLab/Bitbucket and [import to ZEIT Now](https://zeit.co/import?filter=next.js\u0026utm_source=github\u0026utm_medium=readme\u0026utm_campaign=next-example) to deploy.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdavidcreador%2Fpersonal-blog","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdavidcreador%2Fpersonal-blog","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdavidcreador%2Fpersonal-blog/lists"}