Skip to content

Commit

Permalink
Merge branch 'h-enk:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
OCram85 authored Oct 6, 2021
2 parents db8715e + 0cf93c9 commit bcfce0b
Show file tree
Hide file tree
Showing 92 changed files with 4,538 additions and 5,589 deletions.
12 changes: 12 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# These are supported funding model platforms

github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
patreon: # Replace with a single Patreon username
open_collective: doks # Replace with a single Open Collective username
ko_fi: # Replace with a single Ko-fi username
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: # Replace with a single Liberapay username
issuehunt: # Replace with a single IssueHunt username
otechie: # Replace with a single Otechie username
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
bin
node_modules
public
resources
Expand Down
27 changes: 27 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,35 @@ All notable changes to this project will be documented in this file. Dates are d

Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).

#### [v0.3.5](https://github.com/h-enk/doks/compare/v0.3.4...v0.3.5)

- feat: add versioning setup [`#478`](https://github.com/h-enk/doks/pull/478)
- feat: adjust latex svg image to dark theme [`#460`](https://github.com/h-enk/doks/pull/460)
- fix: edit-page multi-language support [`#459`](https://github.com/h-enk/doks/pull/459)
- feat: add docsRepoBranch config [`#458`](https://github.com/h-enk/doks/pull/458)
- feat: image max width [`#457`](https://github.com/h-enk/doks/pull/457)
- fix: docs url [`#456`](https://github.com/h-enk/doks/pull/456)
- chore(deps-dev): bump @babel/cli from 7.15.4 to 7.15.7 [`#463`](https://github.com/h-enk/doks/pull/463)
- feat: add multilingual support [`#454`](https://github.com/h-enk/doks/pull/454)
- deps: bump versions to latest [`94bacd3`](https://github.com/h-enk/doks/commit/94bacd3492e7b4d1e46aef13f86e5924ac645f4e)
- deps: bump @babel/cli from 7.15.4 to 7.15.7 [`130a13b`](https://github.com/h-enk/doks/commit/130a13bd9d3891d995e7373cc9a64fa527b4ce26)
- deps: bump versions to latest [`2503f5a`](https://github.com/h-enk/doks/commit/2503f5adf6d2650b82928a8770c2a1ccdc368a0c)

#### [v0.3.4](https://github.com/h-enk/doks/compare/v0.3.3...v0.3.4)

> 7 September 2021
- chore: update edit page default branch from master to main [`#426`](https://github.com/h-enk/doks/pull/426)
- Update index.js [`#417`](https://github.com/h-enk/doks/pull/417)
- Make id unique collapsible sidebar [`#378`](https://github.com/h-enk/doks/pull/378)
- deps: bump versions to latest [`8a98716`](https://github.com/h-enk/doks/commit/8a9871654e03b79082cfd9ebdf49a0a8ce7e21eb)
- deps: bump version to latest [`23d9dd7`](https://github.com/h-enk/doks/commit/23d9dd75c381b0440f4db717d63bea61baa0c584)
- deps: bump versions to latest [`700e566`](https://github.com/h-enk/doks/commit/700e56611d3a83f33e786f51a191728db7267248)

#### [v0.3.3](https://github.com/h-enk/doks/compare/v0.3.2...v0.3.3)

> 5 July 2021
- Add Mermaid support [`#369`](https://github.com/h-enk/doks/pull/369)
- Fix lint tests on Linux. [`#373`](https://github.com/h-enk/doks/pull/373)
- feat: add mermaid [`f1fa5c5`](https://github.com/h-enk/doks/commit/f1fa5c5936558ff0b62d8a150bf303629bf50840)
Expand Down
29 changes: 26 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
</h1>

<h3 align="center">
Modern documentation theme
Modern Documentation Theme
</h3>

<p align="center">
Doks is a Hugo theme helping you build modern documentation websites that are secure, fast, and SEO-ready — by default.
Doks is a Hugo theme for building secure, fast, and SEO-ready documentation websites, which you can easily update and customize.
</p>

<p align="center">
Expand All @@ -23,6 +23,9 @@
<a href="https://github.com/h-enk/doks/releases">
<img src="https://img.shields.io/github/v/release/h-enk/doks?include_prereleases&style=flat-square"alt="GitHub release (latest SemVer including pre-releases)">
</a>
<a href="https://www.npmjs.com/package/@hyas/doks">
<img src="https://img.shields.io/npm/v/@hyas/doks?style=flat-square" alt="npm (scoped)">
</a>
<a href="https://github.com/h-enk/doks/actions?query=workflow%3A%22Hyas+CI%22">
<img src="https://img.shields.io/github/workflow/status/h-enk/doks/Hyas%20CI/master?style=flat-square" alt="GitHub Workflow Status (branch)">
</a>
Expand All @@ -39,7 +42,7 @@

## Why Doks?

Nine reasons why you should use Doks:
Nine main reasons why you should use Doks:

1. __Security aware__. Get A+ scores on [Mozilla Observatory](https://observatory.mozilla.org/analyze/doks.netlify.app) out of the box. Easily change the default Security Headers to suit your needs.

Expand All @@ -59,6 +62,14 @@ Nine reasons why you should use Doks:

9. __Dark mode__. Switch to a low-light UI with the click of a button. Change colors with variables to match your branding.

### Other features

- __Multilingual and i18n__ support
- __Versioning__ documentation support
- __KaTeX__ math typesetting
- __Mermaid__ diagrams and visualization
- __highlight.js__ syntax highlighting

## Requirements

Doks uses npm to centralize dependency management, making it [easy to update](https://getdoks.org/docs/help/how-to-update/) resources, build tooling, plugins, and build scripts:
Expand Down Expand Up @@ -117,3 +128,15 @@ Doks comes with [commands](https://getdoks.org/docs/prologue/commands/) for comm
- [Netlify Community](https://community.netlify.com/)
- [Hugo Forums](https://discourse.gohugo.io/)
- [Doks Discussions](https://github.com/h-enk/doks/discussions)

## Sponsors

Support this project by becoming a sponsor. Your logo will show up here with a link to your website.

[![OC sponsor 0](https://opencollective.com/doks/sponsor/0/avatar.svg)](https://opencollective.com/doks/sponsor/0/website)

## Backers

Support this project by becoming a backer. Your avatar will show up here.

[![Backers](https://opencollective.com/doks/backers.svg)](https://opencollective.com/doks)
7 changes: 7 additions & 0 deletions SECURITY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Reporting Security Issues

The Doks team and community take security issues in Doks seriously. We appreciate your efforts to responsibly disclose your findings, and will make every effort to acknowledge your contributions.

To report a security issue, email [security@getdoks.org](mailto:security@getdoks.org) and include the word "SECURITY" in the subject line.

We'll endeavor to respond quickly, and will keep you updated throughout the process.
17 changes: 17 additions & 0 deletions assets/js/alert.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
var announcement = document.getElementById('announcement');

if (announcement !== null) {

if (localStorage.getItem('announcement') === null ) {

announcement.classList.remove('d-none');

}

announcement.addEventListener('closed.bs.alert', () => {

localStorage.setItem('announcement', 'closed');

});

}
21 changes: 21 additions & 0 deletions assets/js/darkmode-init.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
const globalDark = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches;
const localMode = localStorage.getItem('theme');

if (globalDark && (localMode === null)) {

localStorage.setItem('theme', 'dark');
document.documentElement.setAttribute('data-dark-mode', '');

}

if (globalDark && (localMode === 'dark')) {

document.documentElement.setAttribute('data-dark-mode', '');

}

if (localMode === 'dark') {

document.documentElement.setAttribute('data-dark-mode', '');

}
38 changes: 32 additions & 6 deletions assets/js/darkmode.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,38 @@
document.getElementById('mode').addEventListener('click', () => {
const mode = document.getElementById('mode');

document.body.classList.toggle('dark');
localStorage.setItem('theme', document.body.classList.contains('dark') ? 'dark' : 'light');
if (mode !== null) {

});
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', event => {

if (localStorage.getItem('theme') === 'dark') {
if (event.matches) {

document.body.classList.add('dark');
localStorage.setItem('theme', 'dark');
document.documentElement.setAttribute('data-dark-mode', '');

} else {

localStorage.setItem('theme', 'light');
document.documentElement.removeAttribute('data-dark-mode');

}

})

mode.addEventListener('click', () => {

document.documentElement.toggleAttribute('data-dark-mode');
localStorage.setItem('theme', document.documentElement.hasAttribute('data-dark-mode') ? 'dark' : 'light');

});

if (localStorage.getItem('theme') === 'dark') {

document.documentElement.setAttribute('data-dark-mode', '');

} else {

document.documentElement.removeAttribute('data-dark-mode');

}

}
73 changes: 35 additions & 38 deletions assets/js/index.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
var suggestions = document.getElementById('suggestions');
var userinput = document.getElementById('userinput');
var search = document.getElementById('search');

document.addEventListener('keydown', inputFocus);
if (search !== null) {
document.addEventListener('keydown', inputFocus);
}

function inputFocus(e) {

if (e.keyCode === 191 ) {
if (e.ctrlKey && e.key === '/' ) {
e.preventDefault();
userinput.focus();
search.focus();
}

if (e.keyCode === 27 ) {
userinput.blur();
if (e.key === 'Escape' ) {
search.blur();
suggestions.classList.add('d-none');
}

}

document.addEventListener('click', function(event) {
Expand All @@ -40,22 +39,23 @@ function suggestionFocus(e){
const focusable= [...focusableSuggestions];
const index = focusable.indexOf(document.activeElement);

const keyDefault = suggestions.classList.contains('d-none');

let nextIndex = 0;

if (e.keyCode === 38) {
if ((e.keyCode === 38) && (!keyDefault)) {
e.preventDefault();
nextIndex= index > 0 ? index-1 : 0;
focusableSuggestions[nextIndex].focus();
}
else if (e.keyCode === 40) {
else if ((e.keyCode === 40) && (!keyDefault)) {
e.preventDefault();
nextIndex= index+1 < focusable.length ? index+1 : index;
focusableSuggestions[nextIndex].focus();
}

}


/*
Source:
- https://github.com/nextapps-de/flexsearch#index-documents-field-search
Expand Down Expand Up @@ -102,7 +102,7 @@ Source:
{{ range $index, $element := $list -}}
{
id: {{ $index }},
href: "{{ .Permalink }}",
href: "{{ .RelPermalink }}",
title: {{ .Title | jsonify }},
description: {{ .Params.description | jsonify }},
content: {{ .Content | jsonify }}
Expand All @@ -113,43 +113,40 @@ Source:
{{ end -}}
;

userinput.addEventListener('input', show_results, true);
search.addEventListener('input', show_results, true);
suggestions.addEventListener('click', accept_suggestion, true);

function show_results(){
const maxResult = 5;

var value = this.value;
var results = index.search(value, { limit: 5, index: ["content"], enrich: true });
var entry, childs = suggestions.childNodes;
var i = 0, len = results.length;
var results = index.search(value, {limit: maxResult, enrich: true});

suggestions.classList.remove('d-none');
suggestions.innerHTML = "";

//flatSearch now returns results for each index field. create a single list
const flatResults = {}; //keyed by href to dedupe results
results.forEach(result=>{
result.result.forEach(r=>{
flatResults[r.doc.href] = r.doc;
});
});

results.forEach(function(results) {

entry = document.createElement('div');

entry.innerHTML = '<a href><span></span><span></span></a>';

a = entry.querySelector('a'),
t = entry.querySelector('span:first-child'),
d = entry.querySelector('span:nth-child(2)');

// console.log(results);

a.href = results.result[i].doc.href;
t.textContent = results.result[i].doc.title;
d.textContent = results.result[i].doc.description;

suggestions.appendChild(entry);
//construct a list of suggestions list
for(const href in flatResults) {
const doc = flatResults[href];

});
const entry = document.createElement('div');
entry.innerHTML = '<a href><span></span><span></span></a>';

while(childs.length > len){
entry.querySelector('a').href = href;
entry.querySelector('span:first-child').textContent = doc.title;
entry.querySelector('span:nth-child(2)').textContent = doc.description;

suggestions.removeChild(childs[i])
suggestions.appendChild(entry);
if(suggestions.childElementCount == maxResult) break;
}

}

function accept_suggestion(){
Expand Down
Loading

0 comments on commit bcfce0b

Please sign in to comment.