Skip to content

Commit

Permalink
docs: update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
arianrhodsandlot committed Jul 24, 2024
1 parent 5630fc3 commit 20b3384
Show file tree
Hide file tree
Showing 5 changed files with 126 additions and 81 deletions.
5 changes: 5 additions & 0 deletions demo/demo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,11 @@ function getCurrentNostalgist() {

Nostalgist.configure({
style: { height: '600px', position: 'static', width: '800px' },

onLaunch(instance) {
// @ts-expect-error for debug usage
window.nostalgist = instance
},
})

document.body.addEventListener('click', async function listener({ target }) {
Expand Down
152 changes: 74 additions & 78 deletions docs/astro.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,37 +6,68 @@ const badge = { text: 'advanced' } as const
export default defineConfig({
integrations: [
starlight({
title: 'Nostialgist.js',
favicon: '/favicon.png',
logo: {
src: './src/assets/logo.png',
replacesTitle: true,
},
social: {
github: 'https://github.com/arianrhodsandlot/nostalgist',
components: {
PageTitle: './src/components/page-title.astro',
},
customCss: ['./src/styles/custom.css'],
editLink: {
baseUrl: 'https://github.com/arianrhodsandlot/nostalgist/edit/main/docs/',
},
tableOfContents: {
maxHeadingLevel: 6,
},
favicon: '/favicon.png',
head: [
{ attrs: { content: 'website', property: 'og:type' }, tag: 'meta' },
{ attrs: { content: 'https://nostalgist.js.org/', property: 'og:url' }, tag: 'meta' },
{ attrs: { content: 'Nostalgist.js', property: 'og:title' }, tag: 'meta' },
{
attrs: {
content:
'Nostalgist.js is a JavaScript library that allows you to run emulators of retro consoles within web browsers.',
property: 'og:description',
},
tag: 'meta',
},
{ attrs: { content: 'https://nostalgist.js.org/thumbnail.png', property: 'og:image' }, tag: 'meta' },

{ attrs: { content: 'summary_large_image', name: 'twitter:card' }, tag: 'meta' },
{ attrs: { content: 'https://nostalgist.js.org/', name: 'twitter:url' }, tag: 'meta' },
{ attrs: { content: 'Nostalgist.js', name: 'twitter:title' }, tag: 'meta' },
{
attrs: {
content:
'Nostalgist.js is a JavaScript library that allows you to run emulators of retro consoles within web browsers.',
name: 'twitter:description',
},
tag: 'meta',
},
{ attrs: { content: 'https://nostalgist.js.org/thumbnail.png', name: 'twitter:image' }, tag: 'meta' },
{ attrs: { content: '@arianrhodsand', name: 'twitter:site' }, tag: 'meta' },
{ attrs: { content: '@arianrhodsand', name: 'twitter:creator' }, tag: 'meta' },
{ attrs: { async: true, src: 'https://unpkg.com/nostalgist/dist/nostalgist.umd.js' }, tag: 'script' },
{ attrs: { async: true, src: 'https://www.googletagmanager.com/gtag/js?id=G-E6387HS8V0' }, tag: 'script' },
{
content: `
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-E6387HS8V0');
`.trim(),
tag: 'script',
},
],
logo: { replacesTitle: true, src: './src/assets/logo.png' },
sidebar: [
{
label: 'Guides',
items: [
{ label: 'Home', link: '/' },
{ label: 'Getting Started', link: '/guides/getting-started' },
{ label: 'Under the Hood', link: '/guides/under-the-hood' },
{ label: 'Related', link: '/guides/related' },
],
label: 'Guides',
},
{
label: 'APIs',
items: [
{
label: 'Static Methods',
items: [
{ label: 'launch', link: '/apis/launch' },
{ label: 'configure', link: '/apis/configure' },
Expand All @@ -46,89 +77,54 @@ export default defineConfig({
{ label: 'gb', link: '/apis/gb' },
{ label: 'gbc', link: '/apis/gbc' },
{ label: 'gba', link: '/apis/gba' },
{ label: 'resetToDefault', link: '/apis/reset-to-default', badge },
{ badge, label: 'resetToDefault', link: '/apis/reset-to-default' },
],
label: 'Static Methods',
},
{
label: 'Instance Methods',
items: [
{ label: 'saveState', link: '/apis/save-state' },

{ label: 'loadState', link: '/apis/load-state' },

{ label: 'restart', link: '/apis/restart' },

{ label: 'pause', link: '/apis/pause' },

{ label: 'resume', link: '/apis/resume' },

{ label: 'exit', link: '/apis/exit' },

{ label: 'resize', link: '/apis/resize' },

{ label: 'press', link: '/apis/press' },

{ label: 'screenshot', link: '/apis/screenshot' },
{ label: 'getCanvas', link: '/apis/get-canvas', badge },
{ label: 'launchEmulator', link: '/apis/launch-emulator', badge },
{ label: 'getEmscriptenModule', link: '/apis/get-emscripten-module', badge },
{ label: 'getEmscriptenFS', link: '/apis/get-emscripten-fs', badge },
{ label: 'getBrowserFS', link: '/apis/get-browser-fs', badge },
{ label: 'pressDown', link: '/apis/press-down', badge },
{ label: 'pressUp', link: '/apis/press-up', badge },
{ label: 'sendCommand', link: '/apis/send-command', badge },

{ badge, label: 'getBrowserFS', link: '/apis/get-browser-fs' },
{ badge, label: 'getCanvas', link: '/apis/get-canvas' },
{ badge, label: 'getEmscripten', link: '/apis/get-emscripten' },
{ badge, label: 'getEmscriptenAL', link: '/apis/get-emscripten-al' },
{ badge, label: 'getEmscriptenFS', link: '/apis/get-emscripten-fs' },
{ badge, label: 'getEmscriptenModule', link: '/apis/get-emscripten-module' },
{ badge, label: 'launchEmulator', link: '/apis/launch-emulator' },
{ badge, label: 'pressDown', link: '/apis/press-down' },
{ badge, label: 'pressUp', link: '/apis/press-up' },
{ badge, label: 'sendCommand', link: '/apis/send-command' },
],
label: 'Instance Methods',
},
],
label: 'APIs',
},
],
components: {
PageTitle: './src/components/page-title.astro',
social: {
github: 'https://github.com/arianrhodsandlot/nostalgist',
},
head: [
{ tag: 'meta', attrs: { property: 'og:type', content: 'website' } },
{ tag: 'meta', attrs: { property: 'og:url', content: 'https://nostalgist.js.org/' } },
{ tag: 'meta', attrs: { property: 'og:title', content: 'Nostalgist.js' } },
{
tag: 'meta',
attrs: {
property: 'og:description',
content:
'Nostalgist.js is a JavaScript library that allows you to run emulators of retro consoles within web browsers.',
},
},
{ tag: 'meta', attrs: { property: 'og:image', content: 'https://nostalgist.js.org/thumbnail.png' } },

{ tag: 'meta', attrs: { name: 'twitter:card', content: 'summary_large_image' } },
{ tag: 'meta', attrs: { name: 'twitter:url', content: 'https://nostalgist.js.org/' } },
{ tag: 'meta', attrs: { name: 'twitter:title', content: 'Nostalgist.js' } },
{
tag: 'meta',
attrs: {
name: 'twitter:description',
content:
'Nostalgist.js is a JavaScript library that allows you to run emulators of retro consoles within web browsers.',
},
},
{ tag: 'meta', attrs: { name: 'twitter:image', content: 'https://nostalgist.js.org/thumbnail.png' } },
{ tag: 'meta', attrs: { name: 'twitter:site', content: '@arianrhodsand' } },
{ tag: 'meta', attrs: { name: 'twitter:creator', content: '@arianrhodsand' } },
{
tag: 'script',
attrs: {
src: 'https://unpkg.com/nostalgist/dist/nostalgist.umd.js',
async: true,
},
},
{
tag: 'script',
attrs: {
src: 'https://www.googletagmanager.com/gtag/js?id=G-E6387HS8V0',
async: true,
},
},
{
tag: 'script',
content: `
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-E6387HS8V0');
`.trim(),
},
],
tableOfContents: {
maxHeadingLevel: 6,
},
title: 'Nostialgist.js',
}),
],
})
18 changes: 18 additions & 0 deletions docs/src/content/docs/apis/get-emscripten-al.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
title: getEmscriptenFS
---

Get the Emscripten `AL` object of the current running emulator.

See [FS object](https://emscripten.org/docs/api_reference/Filesystem-API.html#id2) for more information.

## Since
`0.10.0`

## Usage
```js
const nostalgist = await Nostalgist.nes('flappybird.nes')

const AL = nostalgist.getEmscriptenAL()
FS.readdir('/')
```
15 changes: 15 additions & 0 deletions docs/src/content/docs/apis/get-emscripten.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
title: getEmscriptenFS
---

Get the Emscripten object of the current running emulator.

## Since
`0.10.0`

## Usage
```js
const nostalgist = await Nostalgist.nes('flappybird.nes')

const { AL, Browser, exit, JSEvents, Module } = nostalgist.getEmscripten()
```
17 changes: 14 additions & 3 deletions docs/src/content/docs/apis/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,30 @@ title: API reference

## Instance methods
+ [`saveState`](/apis/save-state)

+ [`loadState`](/apis/load-state)

+ [`restart`](/apis/restart)

+ [`pause`](/apis/pause)

+ [`resume`](/apis/resume)

+ [`exit`](/apis/exit)

+ [`resize`](/apis/resize)

+ [`press`](/apis/press)

+ [`screenshot`](/apis/screenshot)

+ [`getBrowserFS`](/apis/get-browser-fs) (advanced)
+ [`getCanvas`](/apis/get-canvas) (advanced)
+ [`launchEmulator`](/apis/launch-emulator) (advanced)
+ [`getEmscriptenModule`](/apis/get-emscripten-module) (advanced)
+ [`getEmscripten`](/apis/get-emscripten) (advanced)
+ [`getEmscriptenAL`](/apis/get-emscripten-al) (advanced)
+ [`getEmscriptenFS`](/apis/get-emscripten-fs) (advanced)
+ [`getBrowserFS`](/apis/get-browser-fs) (advanced)
+ [`getEmscriptenModule`](/apis/get-emscripten-module) (advanced)
+ [`launchEmulator`](/apis/launch-emulator) (advanced)
+ [`pressDown`](/apis/press-down) (advanced)
+ [`pressUp`](/apis/press-up) (advanced)
+ [`sendCommand`](/apis/send-command) (advanced)

0 comments on commit 20b3384

Please sign in to comment.