Skip to content

Commit

Permalink
feat(v2): bootstrap bootstrap (heh) theme, preset, template (#2557)
Browse files Browse the repository at this point in the history
* feat(v2): Add bootstrap theme structure

* chore(v2): run prettier

* chore(v2): remove unused dependencies

* feat(v2): add bootstrap preset

* feat(v2): add bootstrap template

* remove unnecessary stuff

* --

Co-authored-by: Yangshun Tay <[email protected]>
  • Loading branch information
fanny and yangshun authored Apr 9, 2020
1 parent 8d384b0 commit 434da1d
Show file tree
Hide file tree
Showing 19 changed files with 729 additions and 1 deletion.
5 changes: 4 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,10 @@ module.exports = {
},
overrides: [
{
files: ['packages/docusaurus-init/templates/classic/**/*.js'],
files: [
'packages/docusaurus-init/templates/bootstrap/**/*.js',
'packages/docusaurus-init/templates/classic/**/*.js',
],
rules: {
'header/header': 'off',
},
Expand Down
20 changes: 20 additions & 0 deletions packages/docusaurus-init/templates/bootstrap/.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*
33 changes: 33 additions & 0 deletions packages/docusaurus-init/templates/bootstrap/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Website

This website is built using [Docusaurus 2](https://v2.docusaurus.io/), a modern static website generator.

### Installation

```
$ yarn
```

### Local Development

```
$ yarn start
```

This command starts a local development server and open up a browser window. Most changes are reflected live without having to restart the server.

### Build

```
$ yarn build
```

This command generates static content into the `build` directory and can be served using any static contents hosting service.

### Deployment

```
$ GIT_USER=<Your GitHub username> USE_SSH=true yarn deploy
```

If you are using GitHub pages for hosting, this command is a convenient way to build the website and push to the `gh-pages` branch.
58 changes: 58 additions & 0 deletions packages/docusaurus-init/templates/bootstrap/docusaurus.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
module.exports = {
title: 'My Site',
tagline: 'The tagline of my site',
url: 'https://your-docusaurus-test-site.com',
baseUrl: '/',
favicon: 'img/favicon.ico',
organizationName: 'facebook', // Usually your GitHub org/user name.
projectName: 'docusaurus', // Usually your repo name.
themeConfig: {
navbar: {
title: 'My Site',
logo: {
alt: 'My Site Logo',
src: 'img/logo.svg',
},
links: [
{
href: 'https://github.com/facebook/docusaurus',
label: 'GitHub',
position: 'right',
},
],
},
footer: {
style: 'dark',
links: [
{
title: 'Community',
items: [
{
label: 'Stack Overflow',
href: 'https://stackoverflow.com/questions/tagged/docusaurus',
},
{
label: 'Discord',
href: 'https://discordapp.com/invite/docusaurus',
},
],
},
{
title: 'Social',
items: [
{
label: 'GitHub',
href: 'https://github.com/facebook/docusaurus',
},
{
label: 'Twitter',
href: 'https://twitter.com/docusaurus',
},
],
},
],
copyright: `Copyright © ${new Date().getFullYear()} My Project, Inc. Built with Docusaurus.`,
},
},
presets: [['@docusaurus/preset-bootstrap', {}]],
};
30 changes: 30 additions & 0 deletions packages/docusaurus-init/templates/bootstrap/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"name": "docusaurus-2-bootstrap-template",
"version": "2.0.0-alpha.50",
"private": true,
"scripts": {
"start": "docusaurus start",
"build": "docusaurus build",
"swizzle": "docusaurus swizzle",
"deploy": "docusaurus deploy"
},
"dependencies": {
"@docusaurus/core": "^2.0.0-alpha.50",
"@docusaurus/preset-bootstrap": "^2.0.0-alpha.50",
"classnames": "^2.2.6",
"react": "^16.8.4",
"react-dom": "^16.8.4"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
97 changes: 97 additions & 0 deletions packages/docusaurus-init/templates/bootstrap/src/pages/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
import React from 'react';
import classnames from 'classnames';
import Layout from '@theme/Layout';
import Link from '@docusaurus/Link';
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
import useBaseUrl from '@docusaurus/useBaseUrl';
import styles from './styles.module.css';

const features = [
{
title: <>Easy to Use</>,
imageUrl: 'img/undraw_docusaurus_mountain.svg',
description: (
<>
Docusaurus was designed from the ground up to be easily installed and
used to get your website up and running quickly.
</>
),
},
{
title: <>Focus on What Matters</>,
imageUrl: 'img/undraw_docusaurus_tree.svg',
description: (
<>
Docusaurus lets you focus on your docs, and we&apos;ll do the chores. Go
ahead and move your docs into the <code>docs</code> directory.
</>
),
},
{
title: <>Powered by React</>,
imageUrl: 'img/undraw_docusaurus_react.svg',
description: (
<>
Extend or customize your website layout by reusing React. Docusaurus can
be extended while reusing the same header and footer.
</>
),
},
];

function Feature({imageUrl, title, description}) {
const imgUrl = useBaseUrl(imageUrl);
return (
<div className={classnames('col col--4', styles.feature)}>
{imgUrl && (
<div className="text--center">
<img className={styles.featureImage} src={imgUrl} alt={title} />
</div>
)}
<h3>{title}</h3>
<p>{description}</p>
</div>
);
}

function Home() {
const context = useDocusaurusContext();
const {siteConfig = {}} = context;
return (
<Layout
title={`Hello from ${siteConfig.title}`}
description="Description will go into a meta tag in <head />">
<header className={classnames('hero hero--primary', styles.heroBanner)}>
<div className="container">
<h1 className="hero__title">{siteConfig.title}</h1>
<p className="hero__subtitle">{siteConfig.tagline}</p>
<div className={styles.buttons}>
<Link
className={classnames(
'button button--outline button--secondary button--lg',
styles.getStarted,
)}
to={useBaseUrl('docs/doc1')}>
Get Started
</Link>
</div>
</div>
</header>
<main>
{features && features.length && (
<section className={styles.features}>
<div className="container">
<div className="row">
{features.map((props, idx) => (
<Feature key={idx} {...props} />
))}
</div>
</div>
</section>
)}
</main>
</Layout>
);
}

export default Home;
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/* stylelint-disable docusaurus/copyright-header */
/**
* CSS files with the .module.css suffix will be treated as CSS modules
* and scoped locally.
*/

.heroBanner {
padding: 4rem 0;
text-align: center;
position: relative;
overflow: hidden;
}

@media screen and (max-width: 966px) {
.heroBanner {
padding: 2rem;
}
}

.buttons {
display: flex;
align-items: center;
justify-content: center;
}

.features {
display: flex;
align-items: center;
padding: 2rem 0;
width: 100%;
}

.featureImage {
height: 200px;
width: 200px;
}
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 434da1d

Please sign in to comment.