Skip to content

Commit

Permalink
feat(docs:) Add docs site
Browse files Browse the repository at this point in the history
  • Loading branch information
johnie committed Nov 25, 2023
1 parent ec863dc commit 293233c
Show file tree
Hide file tree
Showing 6 changed files with 528 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
## Installation

```console
$ curl -fsSL git.io/bryggeri | sh
$ /bin/bash -c "$(curl -fsSL https://brg.re/install.sh)"
```

All this installation script does is download the `bryggeri` script, make it an executable, and copy it to your `$PATH (/usr/local/bin)`. For copying to your `$PATH`, it may be required to enter your password. If there is a better way to do this, please send in a pull request.
Expand Down
15 changes: 15 additions & 0 deletions docs/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module bryggeri_web

go 1.21.4

require (
github.com/russross/blackfriday/v2 v2.1.0
github.com/sourcegraph/syntaxhighlight v0.0.0-20170531221838-bd320f5d308e
)

require (
github.com/alecthomas/chroma v0.10.0 // indirect
github.com/dlclark/regexp2 v1.4.0 // indirect
github.com/kr/pretty v0.3.1 // indirect
github.com/sourcegraph/annotate v0.0.0-20160123013949-f4cad6c6324d // indirect
)
25 changes: 25 additions & 0 deletions docs/go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
github.com/alecthomas/chroma v0.10.0 h1:7XDcGkCQopCNKjZHfYrNLraA+M7e0fMiJ/Mfikbfjek=
github.com/alecthomas/chroma v0.10.0/go.mod h1:jtJATyUxlIORhUOFNA9NZDWGAQ8wpxQQqNSB4rjA/1s=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dlclark/regexp2 v1.4.0 h1:F1rxgk7p4uKjwIQxBs9oAXe5CqrXlCduYEJvrF4u93E=
github.com/dlclark/regexp2 v1.4.0/go.mod h1:2pZnwuY/m+8K6iRw6wQdMtk+rH5tNGR1i55kozfMjCc=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8=
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/sourcegraph/annotate v0.0.0-20160123013949-f4cad6c6324d h1:yKm7XZV6j9Ev6lojP2XaIshpT4ymkqhMeSghO5Ps00E=
github.com/sourcegraph/annotate v0.0.0-20160123013949-f4cad6c6324d/go.mod h1:UdhH50NIW0fCiwBSr0co2m7BnFLdv4fQTgdqdJTHFeE=
github.com/sourcegraph/syntaxhighlight v0.0.0-20170531221838-bd320f5d308e h1:qpG93cPwA5f7s/ZPBJnGOYQNK/vKsaDaseuKT5Asee8=
github.com/sourcegraph/syntaxhighlight v0.0.0-20170531221838-bd320f5d308e/go.mod h1:HuIsMU8RRBOtsCgI77wP899iHVBQpCmg4ErYMZB+2IA=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
56 changes: 56 additions & 0 deletions docs/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package main

import (
"html/template"
"os"

"github.com/russross/blackfriday/v2"
)

func main() {
// Read the content of the readme.md file one level up
readmeContent, err := os.ReadFile("../readme.md")
if err != nil {
panic(err)
}

// Convert the Markdown content to HTML
htmlContent := blackfriday.Run(readmeContent, blackfriday.WithExtensions(
blackfriday.CommonExtensions|blackfriday.FencedCode|blackfriday.NoIntraEmphasis,
))

// Define the path to the HTML template file
templatePath := "templates/index.html"

// Read the HTML template from the template file
templateContent, err := os.ReadFile(templatePath)
if err != nil {
panic(err)
}

// Create an HTML template from the template content
tmpl, err := template.New("index").Parse(string(templateContent))
if err != nil {
panic(err)
}

// Define a data structure to pass the HTML content to the template
data := struct {
Content template.HTML
}{
Content: template.HTML(htmlContent),
}

// Create the index.html file one level up
outputFile, err := os.Create("../index.html")
if err != nil {
panic(err)
}
defer outputFile.Close()

// Execute the template and write the output to the index.html file
err = tmpl.Execute(outputFile, data)
if err != nil {
panic(err)
}
}
166 changes: 166 additions & 0 deletions docs/templates/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link href="https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;600;700&display=swap" rel="stylesheet" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/8.0.1/normalize.min.css" />

<style>
body {
font-family: 'JetBrains Mono', monospace;
font-size: 1rem;
line-height: 1.5;
margin: 0 auto;
max-width: 50rem;
padding: 2rem;
background-color: #363062;
color: #f5f5f5;
}

h1 {
font-size: 2rem;
font-weight: 700;
margin-bottom: 1rem;
}

h2 {
font-size: 1.5rem;
font-weight: 700;
margin-bottom: 1rem;
}

h3 {
font-size: 1.25rem;
font-weight: 700;
margin-bottom: 1rem;
}

pre {
background-color: #4d4c7d;
color: #eee;
padding: 1rem;
border-radius: 0.5rem;
overflow-x: auto;
font-size: 0.875rem;
position: relative;
box-sizing: border-box;
}

pre::-webkit-scrollbar {
height: 0.25rem;
}

pre::-webkit-scrollbar-track {
background: #242042;
}

pre::-webkit-scrollbar-thumb {
background: #f99417;
}

p code {
background-color: #4d4c7d;
color: #f5f5f5;
padding: 0.25rem 0.5rem;
border-radius: 0.25rem;
font-weight: bold;
}

blockquote {
border-left: 0.25rem solid #f99417;
padding-left: 1rem;
color: #eee;
margin: 1rem 0;
}

a,
a:visited {
color: #f99417;
}

a:hover {
color: #f99417;
text-decoration: underline;
}

.copy-button {
background-color: #363062;
border: 0;
border-radius: 0.25rem;
color: #f5f5f5;
cursor: pointer;
font-size: 0.875rem;
font-weight: 600;
padding: 0.5rem;
position: absolute;
right: 0.5rem;
top: 0.5rem;
transition: background-color 0.2s ease-in-out;
}

.copy-button:hover {
background-color: #f99417;
}

.copy-button:active {
background-color: #f99417;
}

.copy-button:focus {
outline: 0;
}

.copy-button svg {
display: inline-block;
height: 1rem;
width: 1rem;
vertical-align: middle;
}

.sr-only {
border: 0;
clip: rect(0 0 0 0);
height: 1px;
margin: -1px;
overflow: hidden;
padding: 0;
position: absolute;
width: 1px;
}
</style>

<title>🍼 Bryggeri – Bundle install useful packages with Homebrew</title>
</head>
<body>
<main>
<article>{{.Content}}</article>
</main>

<script>
const codeBlocks = document.querySelectorAll('pre');

codeBlocks.forEach((codeBlock) => {
const copyButton = document.createElement('button');
const copyButtonText = document.createElement('span');
const svg = `<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-copy"><rect width="14" height="14" x="8" y="8" rx="2" ry="2"/><path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"/></svg>`;
copyButton.classList.add('copy-button');
copyButton.insertAdjacentHTML('afterbegin', svg);
copyButtonText.textContent = 'Copy';
copyButtonText.classList.add('sr-only');
copyButton.appendChild(copyButtonText);
codeBlock.insertAdjacentElement('afterbegin', copyButton, codeBlock);

copyButton.addEventListener('click', () => {
let code = codeBlock.querySelector('code').textContent;
if (/\$/g.test(code) || code.match(/\$/g)) {
code = code.replace('$', '');
}
navigator.clipboard.writeText(code);
});
});
</script>
</body>
</html>
Loading

0 comments on commit 293233c

Please sign in to comment.