Skip to content

Commit

Permalink
Added support for modern docfx template (#13)
Browse files Browse the repository at this point in the history
* Started work of supporting new modern template

* Updated styles for modern material design. Pending: update documentation and release notes.

* Completed support for docfx's modern template
  • Loading branch information
ovasquez committed Jun 8, 2023
1 parent 662f093 commit 9538188
Show file tree
Hide file tree
Showing 14 changed files with 403 additions and 79 deletions.
90 changes: 71 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,39 +1,91 @@
# DocFX Material

A simple material theme for [DocFX](https://dotnet.github.io/docfx/). This is an
override of the default template so you need to enable both in the `docfx.json`.
override of the **modern** template so you need to enable both in the `docfx.json`.
The design was inspired by https://m3.material.io/.

The colors were chosen using <https://material.io/tools/color>.
If you are looking for the previous version of docfx-material that doesn't use the
modern template you can still get it as [material-classic](./docs/classic.md).

![DocFX Material Site](./docs/images/index/docfx-screenshot.png)
![DocFX Material Site](./images/docfx-screenshot.png)

## Install

1. Download the source or the zipped file from the [releases](https://github.com/ovasquez/docfx-material/releases).
2. Create a `templates` folder in the root of your DocFX directory.
3. Copy the `material` folder to the `templates` folder.
4. Update the `docfx.json` configuration to include the material template:
```json
{
"template": [
"default",
"templates/material"
],
}
```
```json
{
"template": [
"default",
"modern",
"templates/material"
],
}
```

## Color customization

You can easily customize the color of the header bar and the links by updating
the following variables in the `material/styles/main.css` file.
DocFX's modern template is based on Bootstrap 5 (version 5.3 at the time of writing)
so you can use [Bootstrap's CSS variables](https://getbootstrap.com/docs/5.3/customize/css-variables/)
to customize a lot of the colors.

Here are some of the most common customizations that can be made in the template's
CSS file `material/public/main.css`, like updating the header color, changing the font,


```css
/* COLOR VARIABLES*/
/* Changing the navbar color only for the light theme */
[data-bs-theme='light'] nav.navbar {
background-color: var(--bs-primary-bg-subtle);
}

/* Change active navlink color */
.navbar-nav .nav-link.active,
.navbar-nav .nav-link.show {
color: var(--bs-link-hover-color);
}

/* Changing the site font */
@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@100;400;700&display=swap');

:root {
--header-bg-color: #0d47a1;
--header-ft-color: #fff;
--highlight-light: #5e92f3;
--highlight-dark: #003c8f;
--font-color: #34393e;
...
--bs-font-sans-serif: 'Roboto';
...
}

```

## Markdown extras

For more reference about markdown support in DocFX check the
[official documentation.](https://dotnet.github.io/docfx/docs/markdown.html)

> [!NOTE]
> This is a note which needs your attention, but it's not super important.
>
> [!WARNING]
> This is a warning containing some important message.
>
> [!CAUTION]
> This is a warning containing some **very** important message.
## DocFX tips

### Enable search

To enable search in DocFX it's not enough to set the configuration parameter to `true`:

```json
"globalMetadata": {
"_enableSearch": "true"
}
```

You also have to indicate in the `docfx.json` the post processor that generates the index for the searches:

```json
"postProcessors": ["ExtractSearchIndex"],
```
14 changes: 12 additions & 2 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Changelog

## Version 1.0.0 - June 7th 2023

- Added support for the [modern docfx template](https://dotnet.github.io/docfx/docs/template.html?tabs=modern), including:
- Light and dark mode.
- Simplified color customization.
- Improved hover effects.
- Updated styles to new material theme: https://m3.material.io/get-started.
- Previous material template renamed to [material-classic](./classic.md).
- Removed the need for the `head.tmlp.partial` in material-classic, now only the `main.css` is needed.

## Version 0.5.1 - June 5th 2023

- Fixed `head.tmlp.partial` to work with updated default template.
Expand All @@ -13,12 +23,12 @@

- Usability improvements and minor style changes in textboxes.

<img src="./images/index/docfx-search.gif" alt="Search highlights" class="small-image"/>
<img src="./images/classic/docfx-search.gif" alt="Search highlights" class="small-image"/>

<br/>
<br/>

<img src="./images/index/docfx-filter.gif" alt="Filter highlights" class="small-image"/>
<img src="./images/classic/docfx-filter.gif" alt="Filter highlights" class="small-image"/>


## Version 0.3.1 - January 13th 2020
Expand Down
71 changes: 71 additions & 0 deletions docs/classic.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# DocFX Material

A simple material theme for [DocFX](https://dotnet.github.io/docfx/). This is an
override of the **default** template so you need to enable both in the `docfx.json`.

The colors were chosen using <https://material.io/tools/color>.

![DocFX Material Site](./images/classic/docfx-screenshot.png)

## Install

1. Download the source or the zipped file from the [releases](https://github.com/ovasquez/docfx-material/releases).
2. Create a `templates` folder in the root of your DocFX directory.
3. Copy the `material-classic` folder to the `templates` folder.
4. Update the `docfx.json` configuration to include the material template:
```json
{
"template": [
"default",
"templates/material-classic"
],
}
```

## Color customization

You can easily customize the color of the header bar and the links by updating
the following variables in the `material-classic/styles/main.css` file.

```css
/* COLOR VARIABLES*/
:root {
--header-bg-color: #0d47a1;
--header-ft-color: #fff;
--highlight-light: #5e92f3;
--highlight-dark: #003c8f;
--font-color: #34393e;
}
```

## Markdown extras

For more reference about markdown support in DocFX check the
[official documentation.](https://dotnet.github.io/docfx/spec/docfx_flavored_markdown.html?tabs=tabid-1%2Ctabid-a#note-warningtipimportant)

> [!NOTE]
> This is a note which needs your attention, but it's not super important.
>
> [!WARNING]
> This is a warning containing some important message.
>
> [!CAUTION]
> This is a warning containing some **very** important message.
## DocFX tips

### Enable search

To enable search in DocFX it's not enough to set the configuration parameter to `true`:

```json
"globalMetadata": {
"_enableSearch": "true"
}
```

You also have to indicate in the `docfx.json` the post processor that generates the index for the searches:

```json
"postProcessors": ["ExtractSearchIndex"],
```
19 changes: 7 additions & 12 deletions docs/docfx.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,20 @@
],
"resource": [
{
"files": [
"images/**"
]
"files": ["images/**"]
}
],
"markdownEngineName": "markdig",
"dest": "_site",
"globalMetadataFiles": [],
"fileMetadataFiles": [],
"template": [
"default",
"../material"
],
"postProcessors": [
"ExtractSearchIndex"
],
"template": ["default", "modern", "../material"],
"postProcessors": ["ExtractSearchIndex"],
"globalMetadata": {
"_appFooter": "<span>Copyright © 2019 Oscar Vasquez<br>Generated with <strong>DocFX</strong></span>",
"_appFooter": "<span>Copyright © 2023 Oscar Vasquez. Generated with <a href=\"https://dotnet.github.io/docfx\">DocFX</a></span>",
"_appTitle": "DocFX Material",
"_appLogoPath": "images/code.svg",
"_appFaviconPath": "images/code.svg",
"_enableSearch": "true",
"_gitContribute": {
"repo": "https://github.com/ovasquez/docfx-material"
Expand All @@ -44,4 +39,4 @@
"cleanupCacheHistory": false,
"disableGitFeatures": false
}
}
}
File renamed without changes
File renamed without changes
File renamed without changes
8 changes: 8 additions & 0 deletions docs/images/code.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/docfx-screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
60 changes: 40 additions & 20 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -1,47 +1,67 @@
# DocFX Material

A simple material theme for [DocFX](https://dotnet.github.io/docfx/). This is an
override of the default template so you need to enable both in the `docfx.json`.
override of the **modern** template so you need to enable both in the `docfx.json`.
The design was inspired by https://m3.material.io/.

The colors were chosen using <https://material.io/tools/color>.
If you are looking for the previous version of docfx-material that doesn't use the
modern template you can still get it as [material-classic](./classic.md).

![DocFX Material Site](./images/index/docfx-screenshot.png)
![DocFX Material Site](./images/docfx-screenshot.png)

## Install

1. Download the source or the zipped file from the [releases](https://github.com/ovasquez/docfx-material/releases).
2. Create a `templates` folder in the root of your DocFX directory.
3. Copy the `material` folder to the `templates` folder.
4. Update the `docfx.json` configuration to include the material template:
```json
{
"template": [
"default",
"templates/material"
],
}
```
```json
{
"template": [
"default",
"modern",
"templates/material"
],
}
```

## Color customization

You can easily customize the color of the header bar and the links by updating
the following variables in the `material/styles/main.css` file.
DocFX's modern template is based on Bootstrap 5 (version 5.3 at the time of writing)
so you can use [Bootstrap's CSS variables](https://getbootstrap.com/docs/5.3/customize/css-variables/)
to customize a lot of the colors.

Here are some of the most common customizations that can be made in the template's
CSS file `material/public/main.css`, like updating the header color, changing the font,


```css
/* COLOR VARIABLES*/
/* Changing the navbar color only for the light theme */
[data-bs-theme='light'] nav.navbar {
background-color: var(--bs-primary-bg-subtle);
}

/* Change active navlink color */
.navbar-nav .nav-link.active,
.navbar-nav .nav-link.show {
color: var(--bs-link-hover-color);
}

/* Changing the site font */
@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@100;400;700&display=swap');

:root {
--header-bg-color: #0d47a1;
--header-ft-color: #fff;
--highlight-light: #5e92f3;
--highlight-dark: #003c8f;
--font-color: #34393e;
...
--bs-font-sans-serif: 'Roboto';
...
}

```

## Markdown extras

For more reference about markdown support in DocFX check the
[official documentation.](https://dotnet.github.io/docfx/spec/docfx_flavored_markdown.html?tabs=tabid-1%2Ctabid-a#note-warningtipimportant)
[official documentation.](https://dotnet.github.io/docfx/docs/markdown.html)

> [!NOTE]
> This is a note which needs your attention, but it's not super important.
Expand Down
4 changes: 4 additions & 0 deletions docs/toc.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
- name: Material
href: index.md
- name: Material classic
href: classic.md
- name: Changelog
href: CHANGELOG.md
- name: Sample Articles
Expand Down
Loading

0 comments on commit 9538188

Please sign in to comment.