-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 8122f87
Showing
141 changed files
with
21,507 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
name: Node CI | ||
|
||
# Push tests pushes; PR tests merges | ||
on: [push, pull_request] | ||
|
||
defaults: | ||
run: | ||
shell: bash | ||
|
||
jobs: | ||
# Test the build | ||
build: | ||
# Setup | ||
runs-on: ubuntu-latest | ||
|
||
# Go | ||
steps: | ||
- name: Check out repo | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: 16 | ||
|
||
- name: Env | ||
run: | | ||
echo "Event name: ${{ github.event_name }}" | ||
echo "Git ref: ${{ github.ref }}" | ||
echo "GH actor: ${{ github.actor }}" | ||
echo "SHA: ${{ github.sha }}" | ||
VER=`node --version`; echo "Node ver: $VER" | ||
VER=`npm --version`; echo "npm ver: $VER" | ||
- name: Install | ||
run: npm install | ||
|
||
- name: Test | ||
run: npm test | ||
env: | ||
CI: true | ||
|
||
- name: Notify | ||
uses: homoluctus/slatify@master | ||
if: github.ref == 'refs/heads/main' && failure() | ||
with: | ||
type: ${{ job.status }} | ||
job_name: "*Build*" | ||
url: ${{ secrets.SLACK_NOTIFY }} | ||
commit: true | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
# Assuming all that went fine (and it's main): deploy! | ||
deploy: | ||
# Setup | ||
needs: build | ||
if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v') | ||
runs-on: ubuntu-latest | ||
|
||
# Go | ||
steps: | ||
- name: Check out repo | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: 16 | ||
|
||
- name: Install | ||
run: npm i | ||
|
||
- name: Staging Deploy | ||
if: github.ref == 'refs/heads/main' && github.repository == 'enhance-dev/enhance.dev' | ||
run: npx arc deploy --staging | ||
env: | ||
CI: true | ||
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | ||
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | ||
|
||
- name: Production Deploy | ||
if: startsWith(github.ref, 'refs/tags/v') && github.repository == 'enhance-dev/enhance.dev' | ||
|
||
run: npx arc deploy --production | ||
env: | ||
CI: true | ||
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | ||
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | ||
|
||
- name: Notify | ||
uses: homoluctus/slatify@master | ||
if: always() | ||
with: | ||
type: ${{ job.status }} | ||
job_name: "*Publish*" | ||
url: ${{ secrets.SLACK_NOTIFY }} | ||
commit: true | ||
token: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
node_modules | ||
|
||
.arc-env | ||
.env | ||
preferences.arc | ||
prefs.arc | ||
sam.json | ||
sam.yaml | ||
|
||
static.json | ||
public/css/styles.css | ||
public/bundles | ||
|
||
.DS_Store | ||
.vscode | ||
*-lock.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# Enhance.dev Website | ||
|
||
Powered by HTML ([Enhance](https://enhance.dev)), cloud functions ([Architect](https://arc.codes)), and Markdown ([Arcdown](https://github.coms/architect/arcdown)). | ||
|
||
## Writing docs | ||
|
||
All documentation content lives in `src/views/docs/md`. | ||
|
||
Navigation data is stored in `src/views/docs/nav-data.mjs`. | ||
|
||
## Development | ||
|
||
Recommended prefs.arc: | ||
|
||
```arc | ||
@sandbox | ||
livereload true | ||
``` | ||
|
||
### Main site | ||
|
||
Currently redirects to Enhance documentation at "/docs/". | ||
|
||
### Docs engine | ||
|
||
The main "/docs/*" HTTP function is `src/http/get-docs-catchall/index.mjs`. | ||
(`src/http/get-docs/` redirects "/docs" to "/docs/") | ||
|
||
This function uses the path (accounting for trailing slashes) to look up a .md document and render it to HTML with Arcdown. This HTML is combined with `nav-data` and then handed to `enhance-ssr` to render the full view. | ||
|
||
### Tutorial | ||
|
||
WIP `src/http/get-tutorial-catchall/` | ||
|
||
### Playground | ||
|
||
WIP `src/http/get-playground/` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
@app | ||
enhance-dev-new | ||
|
||
@static | ||
fingerprint true | ||
|
||
@plugins | ||
enhance/arc-plugin-enhance | ||
|
||
@enhance-styles | ||
filename css/styles.css | ||
config css-config.json | ||
|
||
@bundles | ||
mux-player 'node_modules/@mux/mux-player' | ||
|
||
@aws | ||
runtime nodejs16.x | ||
architecture arm64 | ||
region us-west-2 | ||
profile smallwins |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
export async function get() { | ||
return { | ||
statusCode: 302, | ||
location: 'https://discord.gg/J8bUSfKs8W', | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
export async function get() { | ||
return { | ||
statusCode: 301, | ||
location: '/docs/', | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
/* eslint-disable filenames/match-regex */ | ||
import { readFileSync } from 'fs' | ||
import { URL } from 'url' | ||
import { Arcdown } from 'arcdown' | ||
import arcStaticImg from 'markdown-it-arc-static-img' | ||
import navDataLoader, { | ||
unslug, | ||
other as otherLinks, | ||
} from '../../docs/nav-data.mjs' | ||
import HljsLineWrapper from '../../docs/hljs-line-wrapper.mjs' | ||
|
||
const arcdown = new Arcdown({ | ||
pluginOverrides: { | ||
markdownItToc: { | ||
containerClass: 'toc mb2 ml-2', | ||
listType: 'ul', | ||
}, | ||
}, | ||
plugins: [arcStaticImg], | ||
hljs: { | ||
sublanguages: { javascript: ['xml', 'css'] }, | ||
plugins: [new HljsLineWrapper({ className: 'code-line' })], | ||
}, | ||
}) | ||
|
||
/** @type {import('@enhance/types').EnhanceApiFn} */ | ||
export async function get(request) { | ||
const { path: activePath } = request | ||
let docPath = activePath.replace(/^\/?docs\//, '') || 'index' | ||
if (docPath.endsWith('/')) { | ||
docPath += 'index' // trailing slash == index.md file | ||
} | ||
|
||
const gacode = | ||
process.env.ARC_ENV === 'production' ? 'G-FQHNPN78V3' : 'G-0ES194BJQ6' | ||
|
||
const docURL = new URL(`../../docs/md/${docPath}.md`, import.meta.url) | ||
|
||
const sidebarData = navDataLoader('docs', activePath) | ||
|
||
let docMarkdown | ||
try { | ||
docMarkdown = readFileSync(docURL.pathname, 'utf-8') | ||
} catch (_err) { | ||
let searchTerm = null | ||
if (!docPath.endsWith('/index')) { | ||
const docPathParts = docPath.split('/') | ||
searchTerm = docPathParts.pop() | ||
searchTerm = unslug(searchTerm) | ||
} | ||
const initialState = { | ||
doc: { | ||
title: '404', | ||
path: docPath, | ||
term: searchTerm || '', | ||
}, | ||
otherLinks, | ||
sidebarData, | ||
searchTerm, | ||
gacode, | ||
} | ||
|
||
return { statusCode: 404, json: initialState } | ||
} | ||
const doc = await arcdown.render(docMarkdown) | ||
|
||
let gitHubLink = 'https://github.com/enhance-dev/enhance.dev/edit/main/src/' | ||
gitHubLink += `views/docs/md/${docPath}.md` | ||
|
||
const initialState = { | ||
doc, | ||
gitHubLink, | ||
otherLinks, | ||
sidebarData, | ||
gacode, | ||
} | ||
|
||
let cacheControl = | ||
process.env.ARC_ENV === 'production' | ||
? 'max-age=3600;' | ||
: 'no-cache, no-store, must-revalidate, max-age=0, s-maxage=0' | ||
|
||
return { | ||
cacheControl, | ||
json: initialState, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import data from '@begin/data' | ||
|
||
/** @type {import('@enhance/types').EnhanceApiFn} */ | ||
export async function post(req) { | ||
const email = req.body.email | ||
const timestamp = new Date(Date.now()).toISOString() | ||
await data.set({ table: 'email', email, timestamp }) | ||
return { | ||
statusCode: 303, | ||
location: '/email/thank', | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
export async function get() { | ||
return { | ||
statusCode: 302, | ||
location: '/docs/', | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* eslint-disable fp/no-class */ | ||
|
||
export default class { | ||
constructor(options) { | ||
this.className = options.className | ||
} | ||
|
||
'after:highlight'(result) { | ||
const tokens = [] | ||
|
||
const safelyTagged = result.value.replace( | ||
/(<span [^>]+>)|(<\/span>)|(\n)/g, | ||
(match) => { | ||
if (match === '\n') { | ||
return `${'</span>'.repeat(tokens.length)}\n${tokens.join('')}` | ||
} | ||
|
||
if (match === '</span>') { | ||
tokens.pop() | ||
} else { | ||
tokens.push(match) | ||
} | ||
|
||
return match | ||
} | ||
) | ||
|
||
result.value = safelyTagged | ||
.split('\n') | ||
.reduce((result, line, index, lines) => { | ||
const lastLine = index + 1 === lines.length | ||
if (!(lastLine && line.length === 0)) { | ||
result.push( | ||
`<span class="${this.className || 'hljs-line'}">${line}</span>` | ||
) | ||
} | ||
return result | ||
}, []) | ||
.join('\n') | ||
} | ||
} |
Oops, something went wrong.