Skip to content

Commit

Permalink
Merge pull request #211 from inversify/chore/add-inversify-docs-site-…
Browse files Browse the repository at this point in the history
…package

Add inversify docs site package
  • Loading branch information
notaphplover authored Dec 25, 2024
2 parents b2a5f0c + f1dc443 commit 08153be
Show file tree
Hide file tree
Showing 29 changed files with 917 additions and 0 deletions.
20 changes: 20 additions & 0 deletions packages/docs/services/inversify-site/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Dependencies
/node_modules

# Production
/build

# Generated files
.docusaurus
.cache-loader

# Misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local

npm-debug.log*
yarn-debug.log*
yarn-error.log*
9 changes: 9 additions & 0 deletions packages/docs/services/inversify-site/.lintstagedrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"*.js": [
"prettier --write"
],
"*.ts": [
"prettier --write",
"eslint"
]
}
25 changes: 25 additions & 0 deletions packages/docs/services/inversify-site/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/.turbo
/coverage
/reports

**/*.spec.js
**/*.spec.js.map
**/*.ts
!lib/cjs/**/*.d.ts
lib/esm/**/*.d.ts.map
!lib/esm/index.d.ts
!lib/esm/index.d.ts.map

.lintstagedrc.json
eslint.config.mjs
jest.config.mjs
jest.config.stryker.mjs
jest.js.config.mjs
prettier.config.mjs
rollup.config.mjs
stryker.config.mjs
tsconfig.cjs.json
tsconfig.cjs.tsbuildinfo
tsconfig.esm.json
tsconfig.esm.tsbuildinfo
tsconfig.json
3 changes: 3 additions & 0 deletions packages/docs/services/inversify-site/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# @inversifyjs/inversify-docs-site

Inversify documentation site package.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
slug: welcome
title: Welcome
authors: [notaphplover]
tags: []
---

Welcome to the new documentation pages! We are rebuilding our docs on top of [Docusaurus](https://docusaurus.io/) to provide a better developer experience.

<!-- truncate -->

![Docusaurus Plushie](./docusaurus-plushie-banner.jpeg)

This docs will include the latest released version of `inversify`. Major Pre releases will be documented as well so you can learn about them and discuss then in the prerelease discussion thread.
8 changes: 8 additions & 0 deletions packages/docs/services/inversify-site/blog/authors.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
notaphplover:
name: Roberto Pintos López
title: InversifyJS maintainer
url: https://github.com/notaphplover
image_url: https://github.com/notaphplover.png
page: true
socials:
github: notaphplover
4 changes: 4 additions & 0 deletions packages/docs/services/inversify-site/blog/tags.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
releases:
label: Releases
permalink: /releases
description: InversifyJS releases related posts
12 changes: 12 additions & 0 deletions packages/docs/services/inversify-site/customLoaders.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
declare module '*.png' {
const src: string;
export default src;
}
declare module '*.jpg' {
const src: string;
export default src;
}
declare module '*.jpeg' {
const src: string;
export default src;
}
49 changes: 49 additions & 0 deletions packages/docs/services/inversify-site/docs/intro.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
---
sidebar_position: 1
---

# Getting started

Initialize your first container and add some bindings:

:::warning

[Experimental decorators](https://www.typescriptlang.org/tsconfig/#experimentalDecorators) and [Emit Decorator Metadata](https://www.typescriptlang.org/tsconfig/#emitDecoratorMetadata) options must be enabled in order to use this library.

:::

```ts
import { Container, injectable, inject } from 'inversify';

interface Weapon {
damage: number
}

@injectable()
class Katana {
public readonly damage: number = 10;
}

@injectable()
class Ninja {
constructor (
@inject(Katana)
public readonly weapon: Weapon
) {}
}

const container: Container = new Container();

container.bind(Ninja).toSelf();
container.bind(Katana).toSelf();

const ninja: Ninja = container.get(Ninja);

console.log(ninja.weapon.damage); // Prints 10
```

`@injectable` allows both `Katana` and `Ninja` classes to be used as container bindings. `@inject` provides metadata with `Ninja` dependencies so the container is aware a `Katana` should be provided as the first argument of `Ninja`'s constructor.

Bindings are provided through the `Container` API.

Whith these two steps, we are ready to initialize our very first ninja!
111 changes: 111 additions & 0 deletions packages/docs/services/inversify-site/docusaurus.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
import type * as Preset from '@docusaurus/preset-classic';
import type { Config } from '@docusaurus/types';
import { themes as prismThemes } from 'prism-react-renderer';

// This runs in Node.js - Don't use client-side code here (browser APIs, JSX...)

const config: Config = {
baseUrl: '/monorepo',
deploymentBranch: 'gh-pages',
favicon: 'img/favicon.ico',
i18n: {
defaultLocale: 'en',
locales: ['en'],
},
onBrokenLinks: 'throw',
onBrokenMarkdownLinks: 'warn',
organizationName: 'inversify',
presets: [
[
'classic',
{
blog: {
feedOptions: {
type: ['rss', 'atom'],
xslt: true,
},
onInlineAuthors: 'warn',
onInlineTags: 'warn',
onUntruncatedBlogPosts: 'warn',
showReadingTime: true,
},
docs: {
sidebarPath: './sidebars.ts',
},
theme: {
customCss: './src/css/custom.css',
},
} satisfies Preset.Options,
],
],
projectName: 'monorepo',
tagline:
'A powerful and lightweight inversion of control container for JavaScript & Node.js apps powered by TypeScript',
themeConfig: {
footer: {
links: [
{
items: [
{
label: 'Tutorial',
to: '/docs/intro',
},
],
title: 'Docs',
},
{
items: [
{
href: 'https://discord.gg/jXcMagAPnm',
label: 'Discord',
},
],
title: 'Community',
},
{
items: [
{
label: 'Blog',
to: '/blog',
},
{
href: 'https://github.com/inversify/monorepo',
label: 'GitHub',
},
],
title: 'More',
},
],
style: 'dark',
},
navbar: {
items: [
{
label: 'Tutorial',
position: 'left',
sidebarId: 'tutorialSidebar',
type: 'docSidebar',
},
{ label: 'Blog', position: 'left', to: '/blog' },
{
href: 'https://github.com/inversify/monorepo',
label: 'GitHub',
position: 'right',
},
],
logo: {
alt: 'InversifyJS',
src: 'img/logo.svg',
},
title: 'InversifyJS',
},
prism: {
darkTheme: prismThemes.dracula,
theme: prismThemes.github,
},
} satisfies Preset.ThemeConfig,
title: 'InversifyJS',
url: 'https://inversify.github.io',
};

export default config;
Loading

0 comments on commit 08153be

Please sign in to comment.