Skip to content

Commit

Permalink
[frameworks] Convert to TypeScript (vercel#5740)
Browse files Browse the repository at this point in the history
This PR converts the `frameworks.json` file to TypeScript, and extends the values with the detection logic from `@vercel/static-build`, so that it's publicly editable. You also don't need to do the type casting downstream anymore.

As a consequence, it also makes Zola a 1st-class framework, as it was previously missing from the `frameworks.json` file, but present in the static-build frameworks. An example has been included based on their "Getting Started" tutorial.

CH-3808
CH-18771
  • Loading branch information
TooTallNate authored Feb 9, 2021
1 parent d1fc729 commit ffa36c1
Show file tree
Hide file tree
Showing 23 changed files with 1,755 additions and 963 deletions.
5 changes: 5 additions & 0 deletions api/frameworks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ const frameworks = (_frameworks as Framework[])
...frameworkItem,
detectors: undefined,
sort: undefined,
dependency: undefined,
defaultRoutes: undefined,
cachePattern: undefined,
devCommand: undefined,
buildCommand: undefined,
};

if (framework.logo) {
Expand Down
2 changes: 1 addition & 1 deletion api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"description": "API for the vercel/vercel repo",
"main": "index.js",
"scripts": {
"build": "yarn --cwd .. && node ../utils/run.js build all"
"vercel-build": "yarn --cwd .. && node ../utils/run.js build all"
},
"dependencies": {
"@sentry/node": "5.11.1",
Expand Down
1 change: 1 addition & 0 deletions api/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"strict": false,
"forceConsistentCasingInFileNames": true,
"noEmit": true,
"noEmitOnError": true,
"esModuleInterop": true,
"module": "commonjs",
"moduleResolution": "node",
Expand Down
2 changes: 2 additions & 0 deletions examples/zola/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/public
/.vercel
16 changes: 16 additions & 0 deletions examples/zola/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# The URL the site will be built for
base_url = "/"

# Whether to automatically compile all Sass files in the sass directory
compile_sass = true

# Whether to build a search index to be used later on by a JavaScript library
build_search_index = false

[markdown]
# Whether to do syntax highlighting
# Theme can be customised by setting the `highlight_theme` variable to a theme supported by Zola
highlight_code = false

[extra]
# Put all your custom variables here
6 changes: 6 additions & 0 deletions examples/zola/content/blog/_index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
+++
title = "List of blog posts"
sort_by = "date"
template = "blog.html"
page_template = "blog-page.html"
+++
6 changes: 6 additions & 0 deletions examples/zola/content/blog/first.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
+++
title = "My first post"
date = 2019-11-27
+++

This is my first blog post.
6 changes: 6 additions & 0 deletions examples/zola/content/blog/second.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
+++
title = "My second post"
date = 2019-11-28
+++

This is my second blog post.
18 changes: 18 additions & 0 deletions examples/zola/templates/base.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="utf-8">
<title>MyBlog</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/css/bulma.min.css">
</head>

<body>
<section class="section">
<div class="container">
{% block content %} {% endblock %}
</div>
</section>
</body>

</html>
9 changes: 9 additions & 0 deletions examples/zola/templates/blog-page.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{% extends "base.html" %}

{% block content %}
<h1 class="title">
{{ page.title }}
</h1>
<p class="subtitle"><strong>{{ page.date }}</strong></p>
{{ page.content | safe }}
{% endblock content %}
12 changes: 12 additions & 0 deletions examples/zola/templates/blog.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{% extends "base.html" %}

{% block content %}
<h1 class="title">
{{ section.title }}
</h1>
<ul>
{% for page in section.pages %}
<li><a href="{{ page.permalink | safe }}">{{ page.title }}</a></li>
{% endfor %}
</ul>
{% endblock content %}
8 changes: 8 additions & 0 deletions examples/zola/templates/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{% extends "base.html" %}

{% block content %}
<h1 class="title">
This is my blog made with Zola.
</h1>
<p>Click <a href="/blog/">here</a> to see my posts.</p>
{% endblock content %}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"publish-from-github": "./utils/publish.sh",
"changelog": "node utils/changelog.js",
"build": "node utils/run.js build all",
"now-build": "mkdir -p public && echo '<a href=\"https://vercel.com/import\">Import</a>' > public/output.html",
"vercel-build": "mkdir -p public && echo '<a href=\"https://vercel.com/import\">Import</a>' > public/output.html",
"test-unit": "node utils/run.js test-unit",
"test-integration-cli": "node utils/run.js test-integration-cli",
"test-integration-once": "node utils/run.js test-integration-once",
Expand Down
Loading

0 comments on commit ffa36c1

Please sign in to comment.