mirror of
https://github.com/wassname/template.git
synced 2026-07-13 17:46:00 +08:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| f933920421 | |||
| cdfa045a36 | |||
| 5d83dbfd61 | |||
| 94510ee10b |
@@ -37,6 +37,7 @@ const options = { runScripts: 'outside-only', QuerySelector: true, virtualConsol
|
|||||||
JSDOM.fromFile(program.inputPath, options).then(dom => {
|
JSDOM.fromFile(program.inputPath, options).then(dom => {
|
||||||
const window = dom.window;
|
const window = dom.window;
|
||||||
const document = window.document;
|
const document = window.document;
|
||||||
|
const HTMLElement = window.HTMLElement;
|
||||||
|
|
||||||
const data = new transforms.FrontMatter;
|
const data = new transforms.FrontMatter;
|
||||||
data.inputHTMLPath = program.inputPath; // may be needed to resolve relative links!
|
data.inputHTMLPath = program.inputPath; // may be needed to resolve relative links!
|
||||||
|
|||||||
Generated
+1780
-1413
File diff suppressed because it is too large
Load Diff
+5
-4
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "distill-template",
|
"name": "distill-template",
|
||||||
"version": "2.4.1",
|
"version": "2.4.2",
|
||||||
"description": "Template for creating Distill articles.",
|
"description": "Template for creating Distill articles.",
|
||||||
"main": "dist/template.v2.js",
|
"main": "dist/template.v2.js",
|
||||||
"bin": {
|
"bin": {
|
||||||
@@ -13,7 +13,7 @@
|
|||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "rollup -c rollup.config.dev.js -w",
|
"dev": "rollup -c rollup.config.dev.js -w",
|
||||||
"serve": "python3 -m http.server --bind 127.0.0.1 8888",
|
"serve": "http-server",
|
||||||
"test": "mocha",
|
"test": "mocha",
|
||||||
"lint": "eslint",
|
"lint": "eslint",
|
||||||
"build": "rollup -c rollup.config.js",
|
"build": "rollup -c rollup.config.js",
|
||||||
@@ -28,11 +28,12 @@
|
|||||||
"chai": "^3.5.0",
|
"chai": "^3.5.0",
|
||||||
"eslint": "^4.3.0",
|
"eslint": "^4.3.0",
|
||||||
"eslint-config-google": "^0.9.1",
|
"eslint-config-google": "^0.9.1",
|
||||||
|
"http-server": "^0.11.1",
|
||||||
"js-yaml": "^3.7.0",
|
"js-yaml": "^3.7.0",
|
||||||
"jsdom": "11.3.0",
|
"jsdom": "11.3.0",
|
||||||
"jsdom-global": "3.0.2",
|
"jsdom-global": "3.0.2",
|
||||||
"marked": "^0.3.6",
|
"marked": "^0.6.0",
|
||||||
"mocha": "^3.5.3",
|
"mocha": "^5.2.0",
|
||||||
"prismjs": "^1.6.0",
|
"prismjs": "^1.6.0",
|
||||||
"rollup": "^0.50.0",
|
"rollup": "^0.50.0",
|
||||||
"rollup-plugin-babili": "^3.1.0",
|
"rollup-plugin-babili": "^3.1.0",
|
||||||
|
|||||||
@@ -0,0 +1,74 @@
|
|||||||
|
import logo from '../assets/distill-logo.svg';
|
||||||
|
|
||||||
|
export const footerTemplate = `
|
||||||
|
<style>
|
||||||
|
|
||||||
|
:host {
|
||||||
|
color: rgba(255, 255, 255, 0.5);
|
||||||
|
font-weight: 300;
|
||||||
|
padding: 2rem 0;
|
||||||
|
border-top: 1px solid rgba(0, 0, 0, 0.1);
|
||||||
|
background-color: hsl(180, 5%, 15%); /*hsl(200, 60%, 15%);*/
|
||||||
|
text-align: left;
|
||||||
|
contain: content;
|
||||||
|
}
|
||||||
|
|
||||||
|
.logo svg {
|
||||||
|
width: 24px;
|
||||||
|
position: relative;
|
||||||
|
top: 4px;
|
||||||
|
margin-right: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.logo svg path {
|
||||||
|
fill: none;
|
||||||
|
stroke: rgba(255, 255, 255, 0.8);
|
||||||
|
stroke-width: 3px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.logo {
|
||||||
|
font-size: 17px;
|
||||||
|
font-weight: 200;
|
||||||
|
color: rgba(255, 255, 255, 0.8);
|
||||||
|
text-decoration: none;
|
||||||
|
margin-right: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.container {
|
||||||
|
grid-column: text;
|
||||||
|
}
|
||||||
|
|
||||||
|
.nav {
|
||||||
|
font-size: 0.9em;
|
||||||
|
margin-top: 1.5em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.nav a {
|
||||||
|
color: rgba(255, 255, 255, 0.8);
|
||||||
|
margin-right: 6px;
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<div class='container'>
|
||||||
|
|
||||||
|
<a href="/" class="logo">
|
||||||
|
${logo}
|
||||||
|
Distill
|
||||||
|
</a> is dedicated to clear explanations of machine learning
|
||||||
|
|
||||||
|
<div class="nav">
|
||||||
|
<a href="https://distill.pub/about/">About</a>
|
||||||
|
<a href="https://distill.pub/journal/">Submit</a>
|
||||||
|
<a href="https://distill.pub/prize/">Prize</a>
|
||||||
|
<a href="https://distill.pub/archive/">Archive</a>
|
||||||
|
<a href="https://distill.pub/rss.xml">RSS</a>
|
||||||
|
<a href="https://github.com/distillpub">GitHub</a>
|
||||||
|
<a href="https://twitter.com/distillpub">Twitter</a>
|
||||||
|
ISSN 2476-0757
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
`;
|
||||||
@@ -13,80 +13,10 @@
|
|||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
import { Template } from '../mixins/template';
|
import { Template } from '../mixins/template';
|
||||||
import logo from '../assets/distill-logo.svg';
|
|
||||||
|
|
||||||
const T = Template('distill-footer', `
|
import {footerTemplate} from './distill-footer-template';
|
||||||
<style>
|
|
||||||
|
|
||||||
:host {
|
const T = Template('distill-footer', footerTemplate);
|
||||||
color: rgba(255, 255, 255, 0.5);
|
|
||||||
font-weight: 300;
|
|
||||||
padding: 2rem 0;
|
|
||||||
border-top: 1px solid rgba(0, 0, 0, 0.1);
|
|
||||||
background-color: hsl(180, 5%, 15%); /*hsl(200, 60%, 15%);*/
|
|
||||||
text-align: left;
|
|
||||||
contain: content;
|
|
||||||
}
|
|
||||||
|
|
||||||
.logo svg {
|
|
||||||
width: 24px;
|
|
||||||
position: relative;
|
|
||||||
top: 4px;
|
|
||||||
margin-right: 2px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.logo svg path {
|
|
||||||
fill: none;
|
|
||||||
stroke: rgba(255, 255, 255, 0.8);
|
|
||||||
stroke-width: 3px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.logo {
|
|
||||||
font-size: 17px;
|
|
||||||
font-weight: 200;
|
|
||||||
color: rgba(255, 255, 255, 0.8);
|
|
||||||
text-decoration: none;
|
|
||||||
margin-right: 6px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.container {
|
|
||||||
grid-column: text;
|
|
||||||
}
|
|
||||||
|
|
||||||
.nav {
|
|
||||||
font-size: 0.9em;
|
|
||||||
margin-top: 1.5em;
|
|
||||||
}
|
|
||||||
|
|
||||||
.nav a {
|
|
||||||
color: rgba(255, 255, 255, 0.8);
|
|
||||||
margin-right: 6px;
|
|
||||||
text-decoration: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
</style>
|
|
||||||
|
|
||||||
<div class='container'>
|
|
||||||
|
|
||||||
<a href="/" class="logo">
|
|
||||||
${logo}
|
|
||||||
Distill
|
|
||||||
</a> is dedicated to clear explanations of machine learning
|
|
||||||
|
|
||||||
<div class="nav">
|
|
||||||
<a href="https://distill.pub/about/">About</a>
|
|
||||||
<a href="https://distill.pub/journal/">Submit</a>
|
|
||||||
<a href="https://distill.pub/prize/">Prize</a>
|
|
||||||
<a href="https://distill.pub/archive/">Archive</a>
|
|
||||||
<a href="https://distill.pub/rss.xml">RSS</a>
|
|
||||||
<a href="https://github.com/distillpub">GitHub</a>
|
|
||||||
<a href="https://twitter.com/distillpub">Twitter</a>
|
|
||||||
ISSN 2476-0757
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
`);
|
|
||||||
|
|
||||||
export class DistillFooter extends T(HTMLElement) {
|
export class DistillFooter extends T(HTMLElement) {
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,79 @@
|
|||||||
|
import logo from '../assets/distill-logo.svg';
|
||||||
|
|
||||||
|
export const headerTemplate = `
|
||||||
|
<style>
|
||||||
|
distill-header {
|
||||||
|
position: relative;
|
||||||
|
height: 60px;
|
||||||
|
background-color: hsl(200, 60%, 15%);
|
||||||
|
width: 100%;
|
||||||
|
box-sizing: border-box;
|
||||||
|
z-index: 2;
|
||||||
|
color: rgba(0, 0, 0, 0.8);
|
||||||
|
border-bottom: 1px solid rgba(0, 0, 0, 0.08);
|
||||||
|
box-shadow: 0 1px 6px rgba(0, 0, 0, 0.05);
|
||||||
|
}
|
||||||
|
distill-header .content {
|
||||||
|
height: 70px;
|
||||||
|
grid-column: page;
|
||||||
|
}
|
||||||
|
distill-header a {
|
||||||
|
font-size: 16px;
|
||||||
|
height: 60px;
|
||||||
|
line-height: 60px;
|
||||||
|
text-decoration: none;
|
||||||
|
color: rgba(255, 255, 255, 0.8);
|
||||||
|
padding: 22px 0;
|
||||||
|
}
|
||||||
|
distill-header a:hover {
|
||||||
|
color: rgba(255, 255, 255, 1);
|
||||||
|
}
|
||||||
|
distill-header svg {
|
||||||
|
width: 24px;
|
||||||
|
position: relative;
|
||||||
|
top: 4px;
|
||||||
|
margin-right: 2px;
|
||||||
|
}
|
||||||
|
@media(min-width: 1080px) {
|
||||||
|
distill-header {
|
||||||
|
height: 70px;
|
||||||
|
}
|
||||||
|
distill-header a {
|
||||||
|
height: 70px;
|
||||||
|
line-height: 70px;
|
||||||
|
padding: 28px 0;
|
||||||
|
}
|
||||||
|
distill-header .logo {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
distill-header svg path {
|
||||||
|
fill: none;
|
||||||
|
stroke: rgba(255, 255, 255, 0.8);
|
||||||
|
stroke-width: 3px;
|
||||||
|
}
|
||||||
|
distill-header .logo {
|
||||||
|
font-size: 17px;
|
||||||
|
font-weight: 200;
|
||||||
|
}
|
||||||
|
distill-header .nav {
|
||||||
|
float: right;
|
||||||
|
font-weight: 300;
|
||||||
|
}
|
||||||
|
distill-header .nav a {
|
||||||
|
font-size: 12px;
|
||||||
|
margin-left: 24px;
|
||||||
|
text-transform: uppercase;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<div class="content">
|
||||||
|
<a href="/" class="logo">
|
||||||
|
${logo}
|
||||||
|
Distill
|
||||||
|
</a>
|
||||||
|
<nav class="nav">
|
||||||
|
<a href="/about/">About</a>
|
||||||
|
<a href="/prize/">Prize</a>
|
||||||
|
<a href="/journal/">Submit</a>
|
||||||
|
</nav>
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
@@ -14,86 +14,9 @@
|
|||||||
|
|
||||||
import { Template } from '../mixins/template';
|
import { Template } from '../mixins/template';
|
||||||
|
|
||||||
import logo from '../assets/distill-logo.svg';
|
import {headerTemplate} from './distill-header-template';
|
||||||
|
|
||||||
const T = Template('distill-header', `
|
|
||||||
<style>
|
|
||||||
distill-header {
|
|
||||||
position: relative;
|
|
||||||
height: 60px;
|
|
||||||
background-color: hsl(200, 60%, 15%);
|
|
||||||
width: 100%;
|
|
||||||
box-sizing: border-box;
|
|
||||||
z-index: 2;
|
|
||||||
color: rgba(0, 0, 0, 0.8);
|
|
||||||
border-bottom: 1px solid rgba(0, 0, 0, 0.08);
|
|
||||||
box-shadow: 0 1px 6px rgba(0, 0, 0, 0.05);
|
|
||||||
}
|
|
||||||
distill-header .content {
|
|
||||||
height: 70px;
|
|
||||||
grid-column: page;
|
|
||||||
}
|
|
||||||
distill-header a {
|
|
||||||
font-size: 16px;
|
|
||||||
height: 60px;
|
|
||||||
line-height: 60px;
|
|
||||||
text-decoration: none;
|
|
||||||
color: rgba(255, 255, 255, 0.8);
|
|
||||||
padding: 22px 0;
|
|
||||||
}
|
|
||||||
distill-header a:hover {
|
|
||||||
color: rgba(255, 255, 255, 1);
|
|
||||||
}
|
|
||||||
distill-header svg {
|
|
||||||
width: 24px;
|
|
||||||
position: relative;
|
|
||||||
top: 4px;
|
|
||||||
margin-right: 2px;
|
|
||||||
}
|
|
||||||
@media(min-width: 1080px) {
|
|
||||||
distill-header {
|
|
||||||
height: 70px;
|
|
||||||
}
|
|
||||||
distill-header a {
|
|
||||||
height: 70px;
|
|
||||||
line-height: 70px;
|
|
||||||
padding: 28px 0;
|
|
||||||
}
|
|
||||||
distill-header .logo {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
distill-header svg path {
|
|
||||||
fill: none;
|
|
||||||
stroke: rgba(255, 255, 255, 0.8);
|
|
||||||
stroke-width: 3px;
|
|
||||||
}
|
|
||||||
distill-header .logo {
|
|
||||||
font-size: 17px;
|
|
||||||
font-weight: 200;
|
|
||||||
}
|
|
||||||
distill-header .nav {
|
|
||||||
float: right;
|
|
||||||
font-weight: 300;
|
|
||||||
}
|
|
||||||
distill-header .nav a {
|
|
||||||
font-size: 12px;
|
|
||||||
margin-left: 24px;
|
|
||||||
text-transform: uppercase;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
<div class="content">
|
|
||||||
<a href="/" class="logo">
|
|
||||||
${logo}
|
|
||||||
Distill
|
|
||||||
</a>
|
|
||||||
<nav class="nav">
|
|
||||||
<a href="/about/">About</a>
|
|
||||||
<a href="/prize/">Prize</a>
|
|
||||||
<a href="/journal/">Submit</a>
|
|
||||||
</nav>
|
|
||||||
</div>
|
|
||||||
`, false);
|
|
||||||
|
|
||||||
|
const T = Template('distill-header', headerTemplate, false);
|
||||||
|
|
||||||
export class DistillHeader extends T(HTMLElement) {
|
export class DistillHeader extends T(HTMLElement) {
|
||||||
|
|
||||||
|
|||||||
@@ -12,10 +12,13 @@
|
|||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
|
import { footerTemplate } from '../distill-components/distill-footer-template';
|
||||||
|
|
||||||
export default function(dom) {
|
export default function(dom) {
|
||||||
const footerTag = dom.querySelector('distill-footer');
|
const footerTag = dom.querySelector('distill-footer');
|
||||||
if(!footerTag) {
|
if(!footerTag) {
|
||||||
const footer = dom.createElement('distill-footer');
|
const footer = dom.createElement('distill-footer');
|
||||||
|
footer.innerHTML = footerTemplate;
|
||||||
const body = dom.querySelector('body');
|
const body = dom.querySelector('body');
|
||||||
body.appendChild(footer);
|
body.appendChild(footer);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,10 +12,15 @@
|
|||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
export default function(dom) {
|
|
||||||
|
import { headerTemplate } from '../distill-components/distill-header-template';
|
||||||
|
|
||||||
|
export default function(dom, data) {
|
||||||
const headerTag = dom.querySelector('distill-header');
|
const headerTag = dom.querySelector('distill-header');
|
||||||
if (!headerTag) {
|
if (!headerTag) {
|
||||||
const header = dom.createElement('distill-header');
|
const header = dom.createElement('distill-header');
|
||||||
|
header.innerHTML = headerTemplate;
|
||||||
|
header.setAttribute('distill-prerendered', "");
|
||||||
const body = dom.querySelector('body');
|
const body = dom.querySelector('body');
|
||||||
body.insertBefore(header, body.firstChild);
|
body.insertBefore(header, body.firstChild);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,6 +40,9 @@ export const Template = (name, templateString, useShadow = true) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
connectedCallback() {
|
connectedCallback() {
|
||||||
|
if (this.hasAttribute('distill-prerendered')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (useShadow) {
|
if (useShadow) {
|
||||||
if ('ShadyCSS' in window) {
|
if ('ShadyCSS' in window) {
|
||||||
ShadyCSS.styleElement(this);
|
ShadyCSS.styleElement(this);
|
||||||
|
|||||||
Reference in New Issue
Block a user