You've already forked AstralRinth
forked from didirus/AstralRinth
Refactor folder structure
This commit is contained in:
@@ -10,7 +10,7 @@ Requires Node v16.5+.
|
|||||||
|
|
||||||
## Developing
|
## Developing
|
||||||
|
|
||||||
The library lives in the `src/package` folder, and the documentation lives in the `src/routes` folder.
|
The library lives in the `package/` folder, and the documentation lives in the `docs/` folder.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
pnpm install # Install dependencies
|
pnpm install # Install dependencies
|
||||||
@@ -21,12 +21,12 @@ pnpm dev # Run dev server
|
|||||||
|
|
||||||
> Replace `ComponentName` with your component name in the steps below
|
> Replace `ComponentName` with your component name in the steps below
|
||||||
|
|
||||||
1. Create a `ComponentName.svelte` file in `src/package/components`
|
1. Create a `ComponentName.svelte` file in `package/components`
|
||||||
2. Add an export for your component in [./src/package/index.ts](./src/package/index.ts)
|
2. Add an export for your component in [./package/index.ts](./package/index.ts)
|
||||||
```
|
```
|
||||||
export { default as ComponentName } from './components/ComponentName.svelte'
|
export { default as ComponentName } from './components/ComponentName.svelte'
|
||||||
```
|
```
|
||||||
3. Create a `ComponentName.md` file for documentation in `src/routes/components`
|
3. Create a `ComponentName.md` file for documentation in `docs/routes/components`
|
||||||
4. Add an example of your component in your `ComponentName.md` file, like so:
|
4. Add an example of your component in your `ComponentName.md` file, like so:
|
||||||
|
|
||||||
````md
|
````md
|
||||||
|
|||||||
0
src/app.d.ts → docs/app.d.ts
vendored
0
src/app.d.ts → docs/app.d.ts
vendored
|
Before Width: | Height: | Size: 747 B After Width: | Height: | Size: 747 B |
@@ -3,12 +3,12 @@
|
|||||||
|
|
||||||
import IconMenu from 'virtual:icons/lucide/menu'
|
import IconMenu from 'virtual:icons/lucide/menu'
|
||||||
|
|
||||||
const components = Object.keys(import.meta.glob('../../routes/components/**'))
|
const components = Object.keys(import.meta.glob('../routes/components/**'))
|
||||||
.map((it) => it.replace('../../routes/components/', '').replace('.md', ''))
|
.map((it) => it.replace('../routes/components/', '').replace('.md', ''))
|
||||||
.sort()
|
.sort()
|
||||||
|
|
||||||
const classes = Object.keys(import.meta.glob('../../routes/classes/**'))
|
const classes = Object.keys(import.meta.glob('../routes/classes/**'))
|
||||||
.map((it) => it.replace('../../routes/classes/', '').replace('.md', ''))
|
.map((it) => it.replace('../routes/classes/', '').replace('.md', ''))
|
||||||
.sort()
|
.sort()
|
||||||
|
|
||||||
let slideIn = false
|
let slideIn = false
|
||||||
0
src/global.d.ts → docs/global.d.ts
vendored
0
src/global.d.ts → docs/global.d.ts
vendored
@@ -12,14 +12,14 @@
|
|||||||
|
|
||||||
export let description = 'Learn about Omorphia, the component & style library'
|
export let description = 'Learn about Omorphia, the component & style library'
|
||||||
|
|
||||||
let editUrl = `https://github.com/modrinth/omorphia/edit/main/src/routes/${
|
let editUrl = `https://github.com/modrinth/omorphia/edit/main/docs/routes/${
|
||||||
$page.url.pathname.replace('/', '') || 'index'
|
$page.url.pathname.replace('/', '') || 'index'
|
||||||
}.md`
|
}.md`
|
||||||
|
|
||||||
let api
|
let api
|
||||||
if ($page.url.pathname.includes('components')) {
|
if ($page.url.pathname.includes('components')) {
|
||||||
if (import.meta.env.DEV) {
|
if (import.meta.env.DEV) {
|
||||||
import(`../../package/components/${title}.svelte?raw&sveld`).then(
|
import(`../../src/components/${title}.svelte?raw&sveld`).then(
|
||||||
(output) => (api = output.default)
|
(output) => (api = output.default)
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
@@ -2,7 +2,7 @@ import { ComponentParser } from 'sveld'
|
|||||||
import * as svelte from 'svelte/compiler'
|
import * as svelte from 'svelte/compiler'
|
||||||
import fs from 'fs/promises'
|
import fs from 'fs/promises'
|
||||||
import path from 'path'
|
import path from 'path'
|
||||||
import { preprocess } from '../src/package/config/svelte.config.js'
|
import { preprocess } from '../../src/config/svelte.config.js'
|
||||||
|
|
||||||
export default function sveld() {
|
export default function sveld() {
|
||||||
return {
|
return {
|
||||||
@@ -23,21 +23,21 @@ export default function sveld() {
|
|||||||
async buildStart() {
|
async buildStart() {
|
||||||
const output = {}
|
const output = {}
|
||||||
|
|
||||||
const componentFiles = await fs.readdir(path.resolve('./src/package/components'))
|
const componentFiles = await fs.readdir(path.resolve('./src/components'))
|
||||||
|
|
||||||
for (const fileName of componentFiles.filter((name) => name.endsWith('.svelte'))) {
|
for (const fileName of componentFiles.filter((name) => name.endsWith('.svelte'))) {
|
||||||
const filePath = path.resolve('./src/package/components', fileName)
|
const filePath = path.resolve('./src/components', fileName)
|
||||||
const raw = (await fs.readFile(filePath)).toString()
|
const raw = (await fs.readFile(filePath)).toString()
|
||||||
output[fileName] = await parseRaw(raw, filePath)
|
output[fileName] = await parseRaw(raw, filePath)
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await fs.mkdir(path.resolve('./src/generated'))
|
await fs.mkdir(path.resolve('./generated'))
|
||||||
} catch {
|
} catch {
|
||||||
// Do nothing, directory already exists
|
// Do nothing, directory already exists
|
||||||
}
|
}
|
||||||
|
|
||||||
await fs.writeFile(path.resolve('./src/generated/COMPONENT_API.json'), JSON.stringify(output))
|
await fs.writeFile(path.resolve('./generated/COMPONENT_API.json'), JSON.stringify(output))
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -9,11 +9,11 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import '$package/styles.postcss'
|
import 'omorphia/styles.postcss'
|
||||||
import '../docs/styles/prism-one-dark.css'
|
import '../styles/prism-one-dark.css'
|
||||||
import '../docs/styles/gh-markdown.postcss'
|
import '../styles/gh-markdown.postcss'
|
||||||
import Sidebar from '../docs/components/Sidebar.svelte'
|
import Sidebar from '../components/Sidebar.svelte'
|
||||||
import Header from '../docs/components/Header.svelte'
|
import Header from '../components/Header.svelte'
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="app theme-light">
|
<div class="app theme-light">
|
||||||
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
@@ -14,7 +14,7 @@ const config = defineConfig({
|
|||||||
examples,
|
examples,
|
||||||
{
|
{
|
||||||
defaults: {
|
defaults: {
|
||||||
Wrapper: path.resolve('./src/docs/components/Example.svelte'),
|
Wrapper: path.resolve('./docs/components/Example.svelte'),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
@@ -22,7 +22,7 @@ const config = defineConfig({
|
|||||||
rehypePlugins: [],
|
rehypePlugins: [],
|
||||||
|
|
||||||
layout: {
|
layout: {
|
||||||
_: './src/docs/layout/page.svelte',
|
_: './docs/layout/page.svelte',
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
module.exports = require('./src/package/config/postcss.config.cjs')
|
module.exports = require('./src/config/postcss.config.cjs')
|
||||||
|
|||||||
@@ -22,16 +22,6 @@ export default function Generator(options) {
|
|||||||
} catch {
|
} catch {
|
||||||
// File doesn't exist, create folder
|
// File doesn't exist, create folder
|
||||||
await fs.mkdir('./generated', { recursive: true })
|
await fs.mkdir('./generated', { recursive: true })
|
||||||
await fs.writeFile(
|
|
||||||
'./generated/state.json',
|
|
||||||
JSON.stringify(
|
|
||||||
{
|
|
||||||
options,
|
|
||||||
},
|
|
||||||
null,
|
|
||||||
2
|
|
||||||
)
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Don't generate if the last generation was less than TTL and the options are the same
|
// Don't generate if the last generation was less than TTL and the options are the same
|
||||||
@@ -43,16 +33,16 @@ export default function Generator(options) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options.tags) await tags(API_URL)
|
|
||||||
if (options.landingPage) await landingPage(API_URL)
|
|
||||||
if (options.gameVersions) await gameVersions(API_URL)
|
|
||||||
if (options.projectColors) await projectColors(API_URL)
|
|
||||||
|
|
||||||
// Write new state
|
// Write new state
|
||||||
state.lastGenerated = new Date().toISOString()
|
state.lastGenerated = new Date().toISOString()
|
||||||
state.options = options
|
state.options = options
|
||||||
|
|
||||||
await fs.writeFile('./generated/state.json', JSON.stringify(state, null, 2))
|
await fs.writeFile('./generated/state.json', JSON.stringify(state, null, 2))
|
||||||
|
|
||||||
|
if (options.tags) await tags(API_URL)
|
||||||
|
if (options.landingPage) await landingPage(API_URL)
|
||||||
|
if (options.gameVersions) await gameVersions(API_URL)
|
||||||
|
if (options.projectColors) await projectColors(API_URL)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user