From 40ce7f688d45bd13f31b3e2e7874425f7a8e535b Mon Sep 17 00:00:00 2001 From: Matthias Andrasch <777278+mandrasch@users.noreply.github.com> Date: Thu, 24 Oct 2024 10:12:39 +0200 Subject: [PATCH 1/8] add drupal infos for Vite article --- src/content/blog/working-with-vite-in-ddev.md | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/content/blog/working-with-vite-in-ddev.md b/src/content/blog/working-with-vite-in-ddev.md index ebd315d5..d9620207 100644 --- a/src/content/blog/working-with-vite-in-ddev.md +++ b/src/content/blog/working-with-vite-in-ddev.md @@ -449,11 +449,25 @@ Example repositories: #### Drupal -I found this module: +[Andrew Morton](https://github.com/mortona42) gave some information about the current state: -- https://www.drupal.org/project/vite +Vite module: https://www.drupal.org/project/vite -But I could not find more info regarding DDEV usage. Happy to update this section with a better link / suggestion! +This uses Vite's manifest.json to map enabled Drupal library files to the compiled versions in /dist, or to the vite server in dev mode. + +Here is a theme I contributed, with instructions for how to set it up with DDEV in the readme files. I'm trying to detail all the configuration possibilities we might need, with defaults that should work out of the box. + +https://www.drupal.org/project/unocss_starter. (uses Vite) + +I'm blogging about the process here: https://www.drupalarchitect.info/projects/unocss-starter-theme + +There are a handful of devs working on using Vite to bundle assets multiple modules/themes in Drupal. Looks like Vite and Foxy are becoming the leading solutions. + +https://www.drupal.org/project/foxy + +Working POC: https://github.com/darvanen/drupal-js + +I think we'll be seeing a lot of new things in this area over the next year #### Laravel From 48dca2d5a29147b390f8357c447a96bd07583200 Mon Sep 17 00:00:00 2001 From: Matthias Andrasch <777278+mandrasch@users.noreply.github.com> Date: Thu, 24 Oct 2024 10:16:08 +0200 Subject: [PATCH 2/8] use blockquote, update modified date --- src/content/blog/working-with-vite-in-ddev.md | 41 ++++++++++--------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/src/content/blog/working-with-vite-in-ddev.md b/src/content/blog/working-with-vite-in-ddev.md index d9620207..ac19a30c 100644 --- a/src/content/blog/working-with-vite-in-ddev.md +++ b/src/content/blog/working-with-vite-in-ddev.md @@ -1,7 +1,7 @@ --- title: "Working with Vite in DDEV - an introduction" pubDate: 2023-11-08 -modifiedDate: 2024-06-10 +modifiedDate: 2024-24-10 summary: Working with Vite in DDEV author: Matthias Andrasch featureImage: @@ -449,25 +449,26 @@ Example repositories: #### Drupal -[Andrew Morton](https://github.com/mortona42) gave some information about the current state: - -Vite module: https://www.drupal.org/project/vite - -This uses Vite's manifest.json to map enabled Drupal library files to the compiled versions in /dist, or to the vite server in dev mode. - -Here is a theme I contributed, with instructions for how to set it up with DDEV in the readme files. I'm trying to detail all the configuration possibilities we might need, with defaults that should work out of the box. - -https://www.drupal.org/project/unocss_starter. (uses Vite) - -I'm blogging about the process here: https://www.drupalarchitect.info/projects/unocss-starter-theme - -There are a handful of devs working on using Vite to bundle assets multiple modules/themes in Drupal. Looks like Vite and Foxy are becoming the leading solutions. - -https://www.drupal.org/project/foxy - -Working POC: https://github.com/darvanen/drupal-js - -I think we'll be seeing a lot of new things in this area over the next year +[Andrew Morton](https://github.com/mortona42) gave some information about the current state, thanks very much! + +> Vite module: https://www.drupal.org/project/vite +> +> This uses Vite's manifest.json to map enabled Drupal library files to the compiled versions in /dist, or to the vite server in dev mode. +> +> Here is a theme I contributed, with instructions for how to set it up with DDEV in the readme files. I'm trying to detail all the configuration possibilities we might need, with defaults that should work out of the box +> +> https://www.drupal.org/project/unocss_starter. (uses Vite) +> +> I'm blogging about the process here: https://www.drupalarchitect.info/projects/unocss-starter-theme +> +> There are a handful of devs working on using Vite to bundle assets multiple modules/themes in Drupal. Looks like Vite and Foxy are becoming the leading solutions. +> +> https://www.drupal.org/project/foxy +> +> Working POC: https://github.com/darvanen/drupal-js +> +> I think we'll be seeing a lot of new things in +this area over the next year. #### Laravel From 2f053455f6acae82322e30b9b5b80db51f66ea58 Mon Sep 17 00:00:00 2001 From: Matthias Andrasch <777278+mandrasch@users.noreply.github.com> Date: Thu, 24 Oct 2024 10:35:09 +0200 Subject: [PATCH 3/8] update drupal section (fix linting) --- src/content/blog/working-with-vite-in-ddev.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/content/blog/working-with-vite-in-ddev.md b/src/content/blog/working-with-vite-in-ddev.md index ac19a30c..9615e930 100644 --- a/src/content/blog/working-with-vite-in-ddev.md +++ b/src/content/blog/working-with-vite-in-ddev.md @@ -455,9 +455,9 @@ Example repositories: > > This uses Vite's manifest.json to map enabled Drupal library files to the compiled versions in /dist, or to the vite server in dev mode. > -> Here is a theme I contributed, with instructions for how to set it up with DDEV in the readme files. I'm trying to detail all the configuration possibilities we might need, with defaults that should work out of the box +> Here is a theme I contributed, with instructions for how to set it up with DDEV in the readme files. I'm trying to detail all the configuration possibilities we might need, with defaults that should work out of the box. > -> https://www.drupal.org/project/unocss_starter. (uses Vite) +> https://www.drupal.org/project/unocss_starter (uses Vite) > > I'm blogging about the process here: https://www.drupalarchitect.info/projects/unocss-starter-theme > From 567e16d31b9750d6ce9ead0d730ddaa59bb20589 Mon Sep 17 00:00:00 2001 From: Matthias Andrasch <777278+mandrasch@users.noreply.github.com> Date: Thu, 24 Oct 2024 10:46:30 +0200 Subject: [PATCH 4/8] remove blockquote since textlint does not recognize urls in there --- src/content/blog/working-with-vite-in-ddev.md | 34 +++++++++---------- 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/src/content/blog/working-with-vite-in-ddev.md b/src/content/blog/working-with-vite-in-ddev.md index 9615e930..184ddafb 100644 --- a/src/content/blog/working-with-vite-in-ddev.md +++ b/src/content/blog/working-with-vite-in-ddev.md @@ -451,24 +451,22 @@ Example repositories: [Andrew Morton](https://github.com/mortona42) gave some information about the current state, thanks very much! -> Vite module: https://www.drupal.org/project/vite -> -> This uses Vite's manifest.json to map enabled Drupal library files to the compiled versions in /dist, or to the vite server in dev mode. -> -> Here is a theme I contributed, with instructions for how to set it up with DDEV in the readme files. I'm trying to detail all the configuration possibilities we might need, with defaults that should work out of the box. -> -> https://www.drupal.org/project/unocss_starter (uses Vite) -> -> I'm blogging about the process here: https://www.drupalarchitect.info/projects/unocss-starter-theme -> -> There are a handful of devs working on using Vite to bundle assets multiple modules/themes in Drupal. Looks like Vite and Foxy are becoming the leading solutions. -> -> https://www.drupal.org/project/foxy -> -> Working POC: https://github.com/darvanen/drupal-js -> -> I think we'll be seeing a lot of new things in -this area over the next year. +- Vite module: https://www.drupal.org/project/vite + +This uses Vite's manifest.json to map enabled Drupal library files to the compiled versions in /dist, or to the vite server in dev mode. + +Here is a theme I contributed, with instructions for how to set it up with DDEV in the readme files. I'm trying to detail all the configuration possibilities we might need, with defaults that should work out of the box. + +- https://www.drupal.org/project/unocss_starter (uses Vite) + +I'm blogging about the process here: https://www.drupalarchitect.info/projects/unocss-starter-theme + +There are a handful of devs working on using Vite to bundle assets multiple modules/themes in Drupal. Looks like Vite and Foxy are becoming the leading solutions. + +- https://www.drupal.org/project/foxy +- Working POC: https://github.com/darvanen/drupal-js + +I think we'll be seeing a lot of new things in this area over the next year. #### Laravel From 17a1479d0f7282ff84dcd47fc956621aefc247f9 Mon Sep 17 00:00:00 2001 From: Matthias Andrasch <777278+mandrasch@users.noreply.github.com> Date: Thu, 24 Oct 2024 10:49:22 +0200 Subject: [PATCH 5/8] re-add blockquote, add real markdown links for textlint --- src/content/blog/working-with-vite-in-ddev.md | 34 ++++++++++--------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/src/content/blog/working-with-vite-in-ddev.md b/src/content/blog/working-with-vite-in-ddev.md index 184ddafb..db72696a 100644 --- a/src/content/blog/working-with-vite-in-ddev.md +++ b/src/content/blog/working-with-vite-in-ddev.md @@ -451,22 +451,24 @@ Example repositories: [Andrew Morton](https://github.com/mortona42) gave some information about the current state, thanks very much! -- Vite module: https://www.drupal.org/project/vite - -This uses Vite's manifest.json to map enabled Drupal library files to the compiled versions in /dist, or to the vite server in dev mode. - -Here is a theme I contributed, with instructions for how to set it up with DDEV in the readme files. I'm trying to detail all the configuration possibilities we might need, with defaults that should work out of the box. - -- https://www.drupal.org/project/unocss_starter (uses Vite) - -I'm blogging about the process here: https://www.drupalarchitect.info/projects/unocss-starter-theme - -There are a handful of devs working on using Vite to bundle assets multiple modules/themes in Drupal. Looks like Vite and Foxy are becoming the leading solutions. - -- https://www.drupal.org/project/foxy -- Working POC: https://github.com/darvanen/drupal-js - -I think we'll be seeing a lot of new things in this area over the next year. +> Vite module: [https://www.drupal.org/project/vite](https://www.drupal.org/project/vite) +> +> This uses Vite's manifest.json to map enabled Drupal library files to the compiled versions in /dist, or to the vite server in dev mode. +> +> Here is a theme I contributed, with instructions for how to set it up with DDEV in the readme files. I'm trying to detail all the configuration possibilities we might need, with defaults that should work out of the box. +> +> [https://www.drupal.org/project/unocss_starter](https://www.drupal.org/project/unocss_starter) (uses Vite) +> +> I'm blogging about the process here: [https://www.drupalarchitect.info/projects/unocss-starter-theme](https://www.drupalarchitect.info/projects/unocss-starter-theme) +> +> There are a handful of devs working on using Vite to bundle assets multiple modules/themes in Drupal. Looks like Vite and Foxy are becoming the leading solutions. +> +> [https://www.drupal.org/project/foxy](https://www.drupal.org/project/foxy) +> +> Working POC: [https://github.com/darvanen/drupal-js](https://github.com/darvanen/drupal-js) +> +> I think we'll be seeing a lot of new things in +this area over the next year. #### Laravel From d63992c2f5d79b882f5f085504d15a9350cfdb65 Mon Sep 17 00:00:00 2001 From: Matthias Andrasch <777278+mandrasch@users.noreply.github.com> Date: Thu, 24 Oct 2024 10:54:48 +0200 Subject: [PATCH 6/8] fix textlint by disabling it for the line in question --- src/content/blog/working-with-vite-in-ddev.md | 1 + 1 file changed, 1 insertion(+) diff --git a/src/content/blog/working-with-vite-in-ddev.md b/src/content/blog/working-with-vite-in-ddev.md index db72696a..9679366d 100644 --- a/src/content/blog/working-with-vite-in-ddev.md +++ b/src/content/blog/working-with-vite-in-ddev.md @@ -459,6 +459,7 @@ Example repositories: > > [https://www.drupal.org/project/unocss_starter](https://www.drupal.org/project/unocss_starter) (uses Vite) > + > I'm blogging about the process here: [https://www.drupalarchitect.info/projects/unocss-starter-theme](https://www.drupalarchitect.info/projects/unocss-starter-theme) > > There are a handful of devs working on using Vite to bundle assets multiple modules/themes in Drupal. Looks like Vite and Foxy are becoming the leading solutions. From d162b35d25cdb8ceca34a34d159e6a978848bd6d Mon Sep 17 00:00:00 2001 From: Matthias Andrasch <777278+mandrasch@users.noreply.github.com> Date: Fri, 25 Oct 2024 17:06:48 +0200 Subject: [PATCH 7/8] add githubTokenIsSet as const to api.ts --- src/lib/api.ts | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/src/lib/api.ts b/src/lib/api.ts index 571d03d6..fc6cb0ed 100644 --- a/src/lib/api.ts +++ b/src/lib/api.ts @@ -15,6 +15,18 @@ dotenv.config() const DEVELOPMENT_CACHE_DIR = 'cache' let octokitInstance: Octokit; +// Define variable if GITHUB_TOKEN is set and not empty +const githubTokenIsSet: boolean = (() => { + if(process.env.hasOwnProperty('GITHUB_TOKEN') === false || process.env.GITHUB_TOKEN === ''){ + // add warning for production builds + if(import.meta.env.MODE === 'production'){ + console.warn('GITHUB_TOKEN not set or empty. You can ignore this warning for local development.'); + } + return false; + } + return true; +})(); + /** * Returns an instance of Octokit, which uses the `GITHUB_TOKEN` environment * variable for authentication. @@ -56,6 +68,11 @@ export function getCategoryUrl(name: string) { * @returns response data */ export async function getSponsors() { + + if(!githubTokenIsSet){ + return []; + } + const cacheFilename = 'sponsors.json' const cachedData = getCache(cacheFilename); @@ -121,6 +138,11 @@ export async function getSponsors() { * @returns response data */ export async function getContributors(includeAnonymous = false) { + + if(!githubTokenIsSet){ + return []; + } + const cacheFilename = 'contributors.json' const cachedData = getCache(cacheFilename); @@ -155,6 +177,11 @@ export async function getContributors(includeAnonymous = false) { * @returns response data */ export async function getRepoDetails(name: string) { + + if(!githubTokenIsSet){ + return []; + } + const slug = name.replace('/', '-') const cacheFilename = `repository-${slug}.json`; const cachedData = getCache(cacheFilename); @@ -178,6 +205,11 @@ export async function getRepoDetails(name: string) { * @returns tag name */ export async function getLatestReleaseVersion(stable = true) { + + if(!githubTokenIsSet){ + return []; + } + let data = await getReleases() if (stable) { @@ -190,6 +222,11 @@ export async function getLatestReleaseVersion(stable = true) { } export async function getReleases() { + + if(!githubTokenIsSet){ + return []; + } + const cacheFilename = 'releases.json' const cachedData = getCache(cacheFilename); From 2fe2edf5519dc48e3dba8f80d19ec9abba18ae08 Mon Sep 17 00:00:00 2001 From: Matthias Andrasch <777278+mandrasch@users.noreply.github.com> Date: Fri, 25 Oct 2024 17:07:03 +0200 Subject: [PATCH 8/8] update readme to indicate GITHUB_TOKEN is optional for local dev / PRs --- README.md | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index b824ed15..4c3991e3 100644 --- a/README.md +++ b/README.md @@ -57,10 +57,6 @@ All commands are run from the root of the project, from a terminal: ### Local Development Setup -1. Run `cp .env.example .env` to create a `.env` file for environment variables. (Don’t check this in!) -2. Create a [classic GitHub access token](https://github.com/settings/tokens) with these scopes: `repo`, `read:org`, `read:user`, and `read:project`. -3. Paste the GitHub token after `.env`’s `GITHUB_TOKEN=`. - #### DDEV setup DDEV already has all the dependencies included. @@ -82,6 +78,17 @@ Check out the project in your favorite Node.js environment, ideally running [`nv To generate a static copy of the site, run `npm run build`. The contents of the `dist/` folder are exactly what get [deployed to Cloudflare Pages](#build--deployment). You can preview locally by running `npm run preview` or using a tool like [`serve`](https://www.npmjs.com/package/serve). +#### GitHub Token + +This step is not required if you just want to contribute a blog post to ddev.com. + +Contributors, sponsors, releases and more data about DDEV is retrieved dynamically from the GitHub API. To test this, please follow these steps: + +1. Run `cp .env.example .env` to create a `.env` file for environment variables. (Don’t check this in!) +2. Create a [classic GitHub access token](https://github.com/settings/tokens) with these scopes: `repo`, `read:org`, `read:user`, and `read:project`. +3. Paste the GitHub token after `.env`’s `GITHUB_TOKEN=`. + +There is a local `cache/` to reduce API calls. #### Switching from Without DDEV to with DDEV