Skip to content

Commit 51cacae

Browse files
Adds Website with Documentation and Examples (#2)
TLDR; Adds a new website to the project, complete with documentation, API references, blog, and examples. What Does This Do? This pull request introduces a comprehensive website to showcase and document the dart_node project. It provides resources for users to understand, learn, and use the framework effectively. Brief Details? The website uses Eleventy, a static site generator. Includes documentation for the core packages. Generates API documentation from Dart code. Implements a blog for updates and announcements. Provides code examples and usage guides. Implements Github Actions workflow to deploy the website. Includes a pull request template. How Do The Tests Prove The Change Works? There are no explicit tests included in this pull request.
1 parent 844e6db commit 51cacae

36 files changed

Lines changed: 8304 additions & 0 deletions

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
## TLDR;
2+
3+
## What Does This Do?
4+
5+
## Brief Details?
6+
7+
## How Do The Tests Prove The Change Works?
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: Deploy Website to GitHub Pages
2+
3+
on:
4+
workflow_dispatch:
5+
6+
permissions:
7+
contents: write
8+
pages: write
9+
id-token: write
10+
11+
concurrency:
12+
group: pages
13+
cancel-in-progress: false
14+
15+
jobs:
16+
build:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: Checkout
20+
uses: actions/checkout@v4
21+
22+
- name: Setup Dart
23+
uses: dart-lang/setup-dart@v1
24+
with:
25+
sdk: stable
26+
27+
- name: Setup Node.js
28+
uses: actions/setup-node@v4
29+
with:
30+
node-version: '20'
31+
cache: 'npm'
32+
cache-dependency-path: website/package-lock.json
33+
34+
- name: Install website dependencies
35+
working-directory: website
36+
run: npm ci
37+
38+
- name: Generate API documentation
39+
working-directory: website
40+
run: ./scripts/generate-api-docs.sh
41+
42+
- name: Build website
43+
working-directory: website
44+
run: npx @11ty/eleventy
45+
46+
- name: Setup Pages
47+
uses: actions/configure-pages@v4
48+
49+
- name: Upload artifact
50+
uses: actions/upload-pages-artifact@v3
51+
with:
52+
path: website/_site
53+
54+
deploy:
55+
environment:
56+
name: github-pages
57+
url: ${{ steps.deployment.outputs.page_url }}
58+
runs-on: ubuntu-latest
59+
needs: build
60+
steps:
61+
- name: Deploy to GitHub Pages
62+
id: deployment
63+
uses: actions/deploy-pages@v4

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,8 @@ node_modules/
99
*.js.map
1010

1111
examples/mobile/rn/.expo/
12+
13+
# Website generated files
14+
website/_site/
15+
website/src/api/
16+
website/.dart-doc-temp/

website/eleventy.config.js

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
import syntaxHighlight from "@11ty/eleventy-plugin-syntaxhighlight";
2+
import pluginRss from "@11ty/eleventy-plugin-rss";
3+
import eleventyNavigationPlugin from "@11ty/eleventy-navigation";
4+
5+
export default function(eleventyConfig) {
6+
// Plugins
7+
eleventyConfig.addPlugin(syntaxHighlight);
8+
eleventyConfig.addPlugin(pluginRss);
9+
eleventyConfig.addPlugin(eleventyNavigationPlugin);
10+
11+
// Passthrough copy for assets
12+
eleventyConfig.addPassthroughCopy("src/assets");
13+
eleventyConfig.addPassthroughCopy("src/api");
14+
eleventyConfig.addPassthroughCopy("src/robots.txt");
15+
16+
// Watch targets
17+
eleventyConfig.addWatchTarget("src/assets/");
18+
19+
// Collections
20+
eleventyConfig.addCollection("posts", function(collectionApi) {
21+
return collectionApi.getFilteredByGlob("src/blog/*.md").sort((a, b) => {
22+
return b.date - a.date;
23+
});
24+
});
25+
26+
eleventyConfig.addCollection("docs", function(collectionApi) {
27+
return collectionApi.getFilteredByGlob("src/docs/**/*.md");
28+
});
29+
30+
// Tag collection - get all unique tags from blog posts
31+
eleventyConfig.addCollection("tagList", function(collectionApi) {
32+
const tagSet = new Set();
33+
collectionApi.getFilteredByGlob("src/blog/*.md").forEach(post => {
34+
(post.data.tags || []).forEach(tag => {
35+
tag !== 'post' && tag !== 'posts' && tagSet.add(tag);
36+
});
37+
});
38+
return [...tagSet].sort();
39+
});
40+
41+
// Category collection - get all unique categories from blog posts
42+
eleventyConfig.addCollection("categoryList", function(collectionApi) {
43+
const categorySet = new Set();
44+
collectionApi.getFilteredByGlob("src/blog/*.md").forEach(post => {
45+
post.data.category && categorySet.add(post.data.category);
46+
});
47+
return [...categorySet].sort();
48+
});
49+
50+
// Posts by tag - creates a collection for each tag
51+
eleventyConfig.addCollection("postsByTag", function(collectionApi) {
52+
const postsByTag = {};
53+
collectionApi.getFilteredByGlob("src/blog/*.md").forEach(post => {
54+
(post.data.tags || []).forEach(tag => {
55+
tag !== 'post' && tag !== 'posts' && (postsByTag[tag] = postsByTag[tag] || []).push(post);
56+
});
57+
});
58+
Object.keys(postsByTag).forEach(tag => {
59+
postsByTag[tag].sort((a, b) => b.date - a.date);
60+
});
61+
return postsByTag;
62+
});
63+
64+
// Posts by category - creates a collection for each category
65+
eleventyConfig.addCollection("postsByCategory", function(collectionApi) {
66+
const postsByCategory = {};
67+
collectionApi.getFilteredByGlob("src/blog/*.md").forEach(post => {
68+
post.data.category && (postsByCategory[post.data.category] = postsByCategory[post.data.category] || []).push(post);
69+
});
70+
Object.keys(postsByCategory).forEach(cat => {
71+
postsByCategory[cat].sort((a, b) => b.date - a.date);
72+
});
73+
return postsByCategory;
74+
});
75+
76+
// Filters
77+
eleventyConfig.addFilter("dateFormat", (dateObj) => {
78+
return new Date(dateObj).toLocaleDateString('en-US', {
79+
year: 'numeric',
80+
month: 'long',
81+
day: 'numeric'
82+
});
83+
});
84+
85+
eleventyConfig.addFilter("isoDate", (dateObj) => {
86+
return new Date(dateObj).toISOString();
87+
});
88+
89+
eleventyConfig.addFilter("limit", (arr, limit) => {
90+
return arr.slice(0, limit);
91+
});
92+
93+
eleventyConfig.addFilter("capitalize", (str) => {
94+
return str ? str.charAt(0).toUpperCase() + str.slice(1) : '';
95+
});
96+
97+
eleventyConfig.addFilter("slugify", (str) => {
98+
return str ? str.toLowerCase().replace(/\s+/g, '-').replace(/[^\w-]+/g, '') : '';
99+
});
100+
101+
// Shortcodes
102+
eleventyConfig.addShortcode("year", () => `${new Date().getFullYear()}`);
103+
104+
return {
105+
dir: {
106+
input: "src",
107+
output: "_site",
108+
includes: "_includes",
109+
data: "_data"
110+
},
111+
templateFormats: ["md", "njk", "html"],
112+
markdownTemplateEngine: "njk",
113+
htmlTemplateEngine: "njk"
114+
};
115+
}

0 commit comments

Comments
 (0)