Skip to content

Commit

Permalink
Cadl Website Initial Setup (#935)
Browse files Browse the repository at this point in the history
  • Loading branch information
timotheeguerin committed Aug 29, 2022
1 parent 5e29ad9 commit 057c124
Show file tree
Hide file tree
Showing 34 changed files with 2,392 additions and 232 deletions.
1,958 changes: 1,728 additions & 230 deletions common/config/rush/pnpm-lock.yaml

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions eng/pipelines/ci.yml
Expand Up @@ -51,6 +51,15 @@ jobs:
containerName: "$web"
displayName: "Update playground"

- task: AzureFileCopy@4
inputs:
sourcePath: "packages/website/dist/*"
azureSubscription: "Azure SDK Playground"
destination: "AzureBlob"
storage: "cadlwebsite"
containerName: "$web"
displayName: "Update website"

- job: npm_dev
dependsOn: npm_stable
displayName: Npm publish dev version
Expand Down
12 changes: 11 additions & 1 deletion eng/pipelines/pr-tryit.yaml
Expand Up @@ -31,7 +31,17 @@ jobs:
storage: "cadlplayground"
blobPrefix: prs/$(System.PullRequest.PullRequestNumber)/
containerName: "$web"
displayName: "Update playground"
displayName: "Publish playground to PR endpoint"

- task: AzureFileCopy@4
inputs:
sourcePath: "packages/website/dist/*"
azureSubscription: "Azure SDK Playground"
destination: "AzureBlob"
storage: "cadlwebsite"
blobPrefix: prs/$(System.PullRequest.PullRequestNumber)/
containerName: "$web"
displayName: "Publish website to PR endpoint"

- script: node eng/scripts/create-tryit-comment.js
displayName: Check already commented
7 changes: 6 additions & 1 deletion eng/scripts/create-tryit-comment.js
Expand Up @@ -40,7 +40,12 @@ async function main() {
return;
}

const comment = `<!-- ${TRYID_COMMENT_IDENTIFIER} -->\nYou can try these changes at https://cadlplayground.z22.web.core.windows.net${folderName}/prs/${prNumber}/`;
const comment = [
`<!-- ${TRYID_COMMENT_IDENTIFIER} -->`,
`You can try these changes at https://cadlplayground.z22.web.core.windows.net${folderName}/prs/${prNumber}/`,
"",
`Check the website changes at https://cadlwebsite.z1.web.core.windows.net${folderName}/prs/${prNumber}/`,
].join("\n");
await writeComment(repo, prNumber, comment, ghAuth);
}

Expand Down
31 changes: 31 additions & 0 deletions packages/website/.eleventy.js
@@ -0,0 +1,31 @@
// @ts-check
const eleventyNavigationPlugin = require("@11ty/eleventy-navigation");
const syntaxhighlightPlugin = require("@11ty/eleventy-plugin-syntaxhighlight");
const cadlPrismDefinition = require("./cadl-prism-lang.js");

const prNumber = process.env["SYSTEM_PULLREQUEST_PULLREQUESTNUMBER"];

module.exports = (eleventyConfig) => {
eleventyConfig.addPassthroughCopy("css");
eleventyConfig.addPassthroughCopy({
"node_modules/prism-themes/themes/prism-one-light.css": "css/themes/prism-one-light.css",
});

eleventyConfig.addPlugin(eleventyNavigationPlugin);
eleventyConfig.addPlugin(syntaxhighlightPlugin, {
init: ({ Prism }) => {
Prism.languages.cadl = cadlPrismDefinition;
},
});

return {
markdownTemplateEngine: "njk",
dataTemplateEngine: "njk",
htmlTemplateEngine: "njk",
dir: {
input: "src",
output: "dist",
},
pathPrefix: prNumber ? `/prs/${prNumber}/` : "/",
};
};
2 changes: 2 additions & 0 deletions packages/website/.gitignore
@@ -0,0 +1,2 @@
#ignore output folder
/_website
53 changes: 53 additions & 0 deletions packages/website/README.md
@@ -0,0 +1,53 @@
# Cadl Website using 11Ty Static Website Generator

This repo contains the code for static web generator for Cadl project using Eleventy(11ty) static web generator. To get started with 11Ty visit https://www.11ty.dev.

Support libraries that enable the demo features are in the `packages/` directory. The demo code itself is in the `website/` directory.

## Instructions for editing or contributing to this website

### Running the website

To get started with the webiste, run the following npm commands

To build for production:

```bash
> npm run build
```

To run the site on the local server

```bash
> npm start
```

(Be careful, after starting the server, do not close it while building on the existing code. The server will help you while debugging as it shows any changes that is causing trouble in the code.)

### Adding an item on the navigation bar.

Items on the navigation bar are stored and maintained from the navbar.json file. To add or remove an item from the navigation bar, change the json from navbar.json. Check out where to find navbar.json file.

`.src/_data/navbar.json`

### Creating a new layout

There are some basic layout already developed in this repo. Check out some layouts, which are found in `.scr/_includes/layouts/`.

> The `Base.njk` layout is the main layout that includes the navigation bar, and body content(empty content to be altered later) and the footer.
> The "container.njk" layout has the exact same content as the base layout, except that it designed for the container files that are not already included in the template folder `(/_include)`
> The `continer.njk` layout uses the container layout and create the layout for tutorial page/ container of the website.
To create a new layout, add a new file in the \_include folder, and build from existing layouts or create whole new layout.

### Adding pictures or other folders to the source folder.

Checkout the file `.eleventy.js` in the source folder `.src/`. After creating the desired folders in the src folder, add the following line the file.

```bash
module.exports = (eleventyConfig) => {
eleventyConfig.addPassthroughCopy("folderName"); //change folderName with the name of your folder
}
```
58 changes: 58 additions & 0 deletions packages/website/cadl-prism-lang.js
@@ -0,0 +1,58 @@
module.exports = {
comment: [
{
// multiline comments eg /* ASDF */
pattern: /(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/,
lookbehind: true,
greedy: true,
},
{
// singleline comments eg // ASDF
pattern: /(^|[^\\:])\/\/.*/,
lookbehind: true,
greedy: true,
},
],

directives: { pattern: /#.*/g, greedy: true, alias: "comment" },

decorator: {
pattern: /@[$\w\xA0-\uFFFF]+/,
inside: {
at: {
pattern: /^@/,
alias: "operator",
},
function: /^[\s\S]+/,
},
},

property: {
pattern: /((?:^|[,{])[ \t]*)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*:)/m,
lookbehind: true,
alias: "property",
},

string: [
{
pattern: /"""[^"][\s\S]*?"""/,
greedy: true,
},
{
pattern: /(^|[^\\"])"(?:\\.|\$(?!\{)|[^"\\\r\n$])*"/,
lookbehind: true,
greedy: true,
},
],

boolean: /\b(?:false|true)\b/,
keyword:
/\b(?:import|model|namespace|op|interface|union|using|is|extends|enum|alias|return|void|never|if|else|projection)\b/,

function: /\b[a-z_]\w*(?=[ \t]*\()/i,

number: /(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:E[+-]?\d+)?/i,
operator:
/--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]/,
punctuation: /[{}[\];(),.:]/,
};
39 changes: 39 additions & 0 deletions packages/website/css/doc.css
@@ -0,0 +1,39 @@
.cadl-doc-container {
display: flex;
}

.cadl-doc-container > .cadl-doc-nav {
flex: 0 0 200px;
border-right: 1px solid #f3f3f3;
}

.cadl-doc-container > .cadl-doc-content {
flex: 1 auto;
min-width: 0;
max-width: 100%;
margin: 0 24px;
}

.cadl-doc-toc ul {
padding-left: 10px;
}

.cadl-doc-toc ul li {
list-style-type: none;
padding: 0;
}

.cadl-doc-toc ul li a {
border: none;
padding: 6px 0;
transition: color 0.3s;
color: #717171;
}

.cadl-doc-toc ul li a:hover {
color: var(--main-color);
}

.cadl-doc-toc ul li.cadl-toc-active > a {
color: var(--main-color);
}
4 changes: 4 additions & 0 deletions packages/website/css/footer.css
@@ -0,0 +1,4 @@
footer {
text-align: center;
color: #717171;
}
78 changes: 78 additions & 0 deletions packages/website/css/global.css
@@ -0,0 +1,78 @@
* {
box-sizing: border-box;
}

body {
margin: 0;
padding: 0;
font-family: var(--font-family);
color: var(--text-color);
overflow: auto;
}

.app_version {
background: var(--version_bar-color);
color: var(--text-in-main-color);
text-align: center;
}

html {
height: 100%;
}

a {
text-decoration: none;
text-decoration-line: none;
text-decoration-thickness: initial;
text-decoration-style: initial;
text-decoration-color: initial;
color: #1064a8;
}

a:hover {
color: var(--main-color);
}

code {
background-color: hsl(230, 1%, 98%);
border-radius: 3px;
color: inherit;
font-family: SFMono-Regular, Menlo, Monaco, Consolas, Liberation Mono, Courier New, monospace;
font-size: 85%;
margin: 0;
padding: 3.2px 6.4px;
}

pre {
padding: 16px;
border-radius: 3px;
background-color: hsl(230, 1%, 98%);
}
pre > code {
display: block;
}

/* Extra small devices (phones, 600px and down) */

@media only screen and (max-width: 600px) {
}

/* Small devices (portrait tablets and large phones, 600px and up) */

@media only screen and (min-width: 600px) {
}

/* Medium devices (landscape tablets, 768px and up) */

@media only screen and (min-width: 768px) {
}

/* Large devices (laptops/desktops, 992px and up) */

@media only screen and (min-width: 992px) {
}

/* Extra large devices (large laptops and desktops, 1200px and up) */

@media only screen and (min-width: 1200px) {
}
9 changes: 9 additions & 0 deletions packages/website/css/layout.css
@@ -0,0 +1,9 @@
.root-container {
display: flex;
flex-direction: column;
min-height: 100vh;
}

main {
flex-grow: 1;
}
5 changes: 5 additions & 0 deletions packages/website/css/main-content.css
@@ -0,0 +1,5 @@
.main-content {
margin: 0 auto;
max-width: 1024px;
padding: 0.5rem 1.5rem;
}

0 comments on commit 057c124

Please sign in to comment.