Skip to content

Commit

Permalink
Change documentation website to docusaurus (#238)
Browse files Browse the repository at this point in the history
  • Loading branch information
markuspoerschke authored Apr 10, 2021
1 parent 7f97f19 commit a6f6919
Show file tree
Hide file tree
Showing 33 changed files with 7,673 additions and 1,449 deletions.
2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@
/README.md export-ignore
/tests export-ignore
/UPGRADE.md export-ignore
/website
/website export-ignore
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
/.couscous
/.idea
/.php_cs.cache
/.phpunit.result.cache
/build
/couscous.phar
/Makefile.local
/node_modules
/phpunit.xml
Expand Down
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
13
14
10 changes: 6 additions & 4 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
/.github
/build
/composer.lock
/vendor
/node_modules
/report
/build
/.couscous
/.github
/vendor
/website/.docusaurus
/website/build
/website/node_modules
16 changes: 3 additions & 13 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,12 @@
# Dockerfile for the project’s website
#

FROM node:13 AS build_frontend
FROM node:14 AS build

COPY website/ /app/website
WORKDIR /app/website
RUN yarn && yarn build

FROM php:7.4-alpine AS build

ADD https://github.com/CouscousPHP/Couscous/releases/download/1.8.0/couscous.phar /usr/local/bin/couscous
RUN chmod +x /usr/local/bin/couscous

COPY ./ /app
COPY --from=build_frontend /app/website/template/static /app/website/template/static
WORKDIR /app

RUN /usr/local/bin/couscous generate

FROM nginx
COPY --from=build /app/.couscous/generated /usr/share/nginx/html
COPY --from=build /app/website/build /usr/share/nginx/html
COPY ./website/default.nginx /etc/nginx/conf.d/default.conf
20 changes: 6 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -89,25 +89,17 @@ fix-prettier:
npx prettier --write .

.PHONY: docs
docs: docs-dependencies docs-frontend-build
php couscous.phar generate
docs: docs-dependencies
cd website && yarn build

.PHONY: docs-dependencies
docs-dependencies:
if [ ! -f couscous.phar ]; then php -r "copy('https://github.com/CouscousPHP/Couscous/releases/download/1.8.0/couscous.phar', 'couscous.phar');"; fi

.PHONY: docs-preview
docs-preview: docs-dependencies docs-frontend-build
php couscous.phar preview

.PHONY: docs-frontend-dependencies
docs-frontend-dependencies:
cd website && yarn

.PHONY: docs-frontend-build
docs-frontend-build: docs-frontend-dependencies
cd website && yarn build
.PHONY: docs-preview
docs-preview: docs-dependencies
cd website && yarn start

.PHONY: clean
clean:
rm -rf vendor .couscous website/node_modules website/template/static couscous.phar node_modules .phpunit.result.cache .php_cs.cache report
rm -rf vendor website/node_modules website/build website/.docusaurus couscous.phar node_modules .phpunit.result.cache .php_cs.cache report
20 changes: 19 additions & 1 deletion website/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,20 @@
# Dependencies
/node_modules
/template/static

# 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*
1 change: 0 additions & 1 deletion website/.nvmrc

This file was deleted.

33 changes: 33 additions & 0 deletions website/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

```console
yarn install
```

## Local Development

```console
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

```console
yarn build
```

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

## Deployment

```console
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.
3 changes: 3 additions & 0 deletions website/babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
presets: [require.resolve("@docusaurus/core/lib/babel/preset")],
};
23 changes: 23 additions & 0 deletions website/default.nginx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
server {
listen 80;
server_name localhost;
absolute_redirect off;

location / {
root /usr/share/nginx/html;
index index.html index.htm;

rewrite ^/$ /docs redirect;
rewrite ^/getting-started/installation.html$ /docs/installation permanent;
rewrite ^/components/event.html$ /docs/component-event permanent;
rewrite ^/components/calendar.html$ /docs/component-calendar permanent;
rewrite ^/components/timezone.html$ /docs/component-timezone permanent;
rewrite ^/advanced/custom-properties.html$ /docs/custom-properties permanent;
rewrite ^/advanced/maturity-matrix.html$ /docs/maturity-matrix permanent;
}

error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
---
currentMenu: components/calendar
title: Calendar Component
title: Calendar
---

# Calendar

The calendar is basically a collection of events.
A calendar can be represented as a `.ical` file.

Expand Down
7 changes: 2 additions & 5 deletions docs/components/event.md → website/docs/component-event.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
---
currentMenu: components/event
title: Event Component
title: Event
---

# Event

The event domain object `\Eluceo\iCal\Domain\Entity\Event` represents a scheduled amount of time on a calendar.
For example, it can be an one-hour lunch meeting from 12:00 to 13:00 on 24th of december.

## Create new instance

When creating a new instance with the static method `Event::create`, the optional parameter `$uniqueIdentifier` can be set.
When creating a new instance with the default construct method `new Event()`, the optional parameter `$uniqueIdentifier` can be set.
If it is not set, then a random, but unique identifier is created.

```php
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
---
currentMenu: components/timezone
title: Time Zone Component
title: Time Zone
---

# Time Zone

The time zone event domain object `\Eluceo\iCal\Domain\Entity\TimeZone` represents a definition of a time zone.
It contains the transitions of standard and daylight saving time and defines offsets to the UTC time.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
---
currentMenu: advanced/custom-properties
title: Custom Properties
---

# Custom Properties

The domain entities in these packages are equipped with the commonly needed properties.
In some cases these properties do not fully cover every use case.
In the following, a way how to add custom properties to the event entity and in result to the generated iCal file is described.
Expand Down
5 changes: 2 additions & 3 deletions docs/index.md → website/docs/index.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
---
currentMenu: home
title: Introduction
slug: /
---

# iCalendar Generator for PHP

The `eluceo/ical` package provides classes to generate `.ics` files.
The iCalendar specification is defined in [RFC 5545](https://tools.ietf.org/html/rfc5545) and allows sharing calendar information among different systems.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
---
currentMenu: getting-started/installation
title: Install
title: Installation
---

# Installation

The package can be installed using [Composer](http://getcomposer.org).

Either the package can be required through the command line, like this:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
---
currentMenu: advanced/maturity-matrix
title: Maturity Matrix
---

# Maturity Matrix

The generation of the `.ics` file follows the “Internet Calendaring and Scheduling Core Object
Specification” ([RFC 5545](https://tools.ietf.org/html/rfc5545)). The domain objects in this package do not fully
support all possibilities, that the specification provides. The following tables give an overview about the supported
Expand Down
88 changes: 88 additions & 0 deletions website/docusaurus.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
/** @type {import('@docusaurus/types').DocusaurusConfig} */
module.exports = {
title: "eluceo/ical",
tagline: "iCalendar Generator for PHP",
url: "https://ical.poerschke.nrw",
baseUrl: "/",
onBrokenLinks: "throw",
onBrokenMarkdownLinks: "warn",
favicon: "img/favicon.ico",
organizationName: "markuspoerschke", // Usually your GitHub org/user name.
projectName: "ical", // Usually your repo name.
themeConfig: {
navbar: {
title: "eluceo/ical",
items: [
{
to: "docs/",
activeBasePath: "docs",
label: "Docs",
position: "left",
},
{
href: "https://github.com/markuspoerschke/ical",
label: "GitHub",
position: "right",
},
],
},
footer: {
style: "dark",
links: [
{
title: "Docs",
items: [
{
label: "Getting Started",
to: "docs/",
},
],
},
{
title: "More",
items: [
{
label: "GitHub",
href: "https://github.com/markuspoerschke/ical",
},
{
label: "Imprint",
href: "https://markus.poerschke.nrw/imprint/",
},
],
},
],
copyright: `Copyright (c) 2012-2021 Markus Poerschke, Published under MIT License`,
},
prism: {
additionalLanguages: ["php"],
theme: require("prism-react-renderer/themes/nightOwlLight"),
darkTheme: require("prism-react-renderer/themes/oceanicNext"),
},
},
presets: [
[
"@docusaurus/preset-classic",
{
blog: false,
docs: {
sidebarPath: require.resolve("./sidebars.js"),
editUrl:
"https://github.com/markuspoerschke/ical/edit/2.x/website/",
},
theme: {
customCss: require.resolve("./src/css/custom.css"),
},
},
],
],
plugins: [
[
"docusaurus-plugin-ackee",
{
domainId: "23cbb93b-ce0b-4f58-bca4-6caa0bc939ee",
server: "https://ackee.poerschke.nrw",
},
],
],
};
Loading

0 comments on commit a6f6919

Please sign in to comment.