Skip to content

Commit

Permalink
feat: copy Astro from POC repo to Lion repo
Browse files Browse the repository at this point in the history
  • Loading branch information
okadurin committed Oct 18, 2023
1 parent b28cfd4 commit c24e24d
Show file tree
Hide file tree
Showing 45 changed files with 13,989 additions and 27,188 deletions.
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
# build output
dist/
# generated types
.astro/

.astro

# generated __mdjs-stories.js files
public/mdjs-stories

## editors
/.idea
/.vscode
Expand Down
66 changes: 66 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,72 @@ They provide an unopinionated, white-label layer that can be extended to your ow
<a href="https://lion-web.netlify.app/guides/"><strong>Explore the Lion Guides&nbsp;&nbsp;▶</strong></a>
</p>

## Astro migration

### How to migrate a button component (overview.md page only at this moment)

- Copy `docs/components/button` to `src/content/docs/components`
- Create an emty file: `src/content/docs/components/button/info.md`
- At the very beginning of `src/content/docs/components/button/info.md` add the following:

```
---
component: button
title: Button title
description: Button Description
type: component-info
defaultSlug: web
---
```

where

- the `component` value should match the folder name
- `title` and `description` could be random
- `type` must be `component-info`
- `defaultSlug` must be `web`

- At the very beginning of `src/content/docs/components/button/overview.md` add the following:

```
---
component: button
category: development
platform: web
type: component-development
---
```

where

- the `component` value should match the folder name
- the rest of properties/values should always stay as in the example

- Delete (temporarily) other md files for a component:
- `src/content/docs/components/button/examples.md`
- `src/content/docs/components/button/extensions.md`
- `src/content/docs/components/button/index.md`
- `src/content/docs/components/button/use-cases.md`
- Temporarily get rid of `packages/*` as workspaces
- Remove `"packages/*",` from `"workspaces": [` in `package.json`. That is a temporary hack to make `require.resolve` fetch files from `node_modules/lion/ui` and not resolving `@lion/ui` as `packages/ui`. We need this until find out how to copy those files to `/public` programmatically
- Install `@lion/ui` as a dependency
- Remove imports related to `ing-web` in `src/utils/astrojs-integration/lion/lion-integration.mjs`
- Remove `ing-web` related `remarkPlugins` in `astro.config.mjs`

### TODO

- Add `packages/*` back to workspaces in `package.json`
- Make the rollup config copy the files from `packages/ui` into `/public`
- Uninstall `@lion/ui` as a dependency
- Write one time script for `Lion` migration which adds frontmatter to `md` files
- `index.md` is to be ignored
- `info.md` is to be added
- `rocket-preset-extend-lion-docs` should be updates
- `Rocket` name should gone
- Export methods: `remarkExtendLionDocsTransformJs`, `remarkUrlToLocal`, `generateExtendDocsConfig` so those could be used in
`src/utils/remark-plugings/copyMdjsStories/copyMdjsStories.js`
- See what `copy.sh` does in POC project to replicate the same here

## How to install

```bash
Expand Down
47 changes: 47 additions & 0 deletions astro.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { defineConfig } from "astro/config";
import lit from "@astrojs/lit";
import { mdjsParse, mdjsStoryParse, mdjsSetupCode } from '@mdjs/core';
import lionIntegration from './src/utils/astrojs-integration/lion/lion-integration.mjs'
import { copyMdjsStories } from './src/utils/remark-plugings/copyMdjsStories/index.js';

const mdjsSetupConfig = {
simulationSettings: {
simulatorUrl: '/simulator/',
languages: [
{ key: 'de-DE', name: 'German' },
{ key: 'en-GB', name: 'English (United Kingdom)' },
{ key: 'en-US', name: 'English (United States)' },
{ key: 'nl-NL', name: 'Dutch' },
],
},
};

// https://astro.build/config
export default defineConfig({
integrations: [lit(), lionIntegration()],
markdown: {
remarkPlugins: [mdjsParse, mdjsStoryParse, [mdjsSetupCode, mdjsSetupConfig], copyMdjsStories],
},
vite: {
// the fix is copied from https://github.com/withastro/astro/issues/5517#issuecomment-1337328843.
// This allows to import rocket-preset-extend-lion-docs. The following error pops up otherwise:
// ```
// [ERROR] Top-level await is not available in the configured target environment ("chrome87", "edge88", "es2020", "firefox78", "safari14" + 2 overrides)
// node_modules/rocket-preset-extend-lion-docs/src/getPublicApiOfPkg.js:6:0:
// 6 │ await init;
// ```
optimizeDeps: {
exclude: ['rocket-preset-extend-lion-docs']
},
// Fix taken from https://github.com/vitejs/vite/issues/6985#issuecomment-1044375490.
// It throws an error otherwise:
// ```
// astro-poc2/node_modules/vite/dist/node/chunks/dep-df561101.js:43799
// const err = new Error('The server is being restarted or closed. Request is outdated');
// ```
// Note, if this erorr is still present, as a workaround try adding 'esnext' to node_modules/vite/dist/node/constants.js -> ESBUILD_MODULES_TARGET
// build: {
// target: 'esnext'
// },
},
});
Loading

0 comments on commit c24e24d

Please sign in to comment.