Skip to content

Instantly share code, notes, and snippets.

View nafeu's full-sized avatar
🕶️
In Virtual Reality

Nafeu Nasir nafeu

🕶️
In Virtual Reality
View GitHub Profile
{ outputPath: "./build/index.html" }
{ outputPath: "./build/about/index.html" }
/* Step 4: Build pages into .html files with appropriate paths */
for (const page of pages) {
const { path } = page;
let outputPath: string;
if (path === HOME_PATH) {
outputPath = `${buildPath}/index.html`;
} else {
outputPath = `${buildPath}${path}/index.html`;
/* Step 3: Generate templates for html content */
const isHomePath = (path: string) => path === HOME_PATH;
const getStylesheetHref = (path: string) => {
return isHomePath(path) ? STYLESHEET_PATH : `../${STYLESHEET_PATH}`;
}
const getFaviconSvg = (favicon: string) => `
<svg xmlns="http://www.w3.org/2000/svg">
<text y="32" font-size="32">${favicon ? favicon : '🦕'}</text>
const getHtmlByPage = ({ path, name, html }: Page) => `
<!DOCTYPE html>
<html>
<head>
<title>${name} | ${title}</title>
<link rel="stylesheet" href="${getStylesheetHref(path)}">
<link rel="icon" href="/favicon.svg">
</head>
<body>
<div id="title">
/* Step 3: Generate templates for html content */
const isHomePath = (path: string) => path === HOME_PATH;
const getStylesheetHref = (path: string) => {
return isHomePath(path) ? STYLESHEET_PATH : `../${STYLESHEET_PATH}`;
}
const getFaviconSvg = (favicon: string) => `
<svg xmlns="http://www.w3.org/2000/svg">
<text y="32" font-size="32">${favicon ? favicon : '🦕'}</text>
<div id="nav">
<a class="nav-item selected" href="/">Home</a>
<a class="nav-item" href="/about">About</a>
</div>
const getNavigation = (currentPath: string) => `
<div id="nav">
${pages.map(({ path, name }) => {
const href = path === HOME_PATH ? '/' : path;
const isSelectedPage = path === currentPath;
const classes = `nav-item ${isSelectedPage ? 'selected': ''}`;
return `<a class="${classes}" href=${href}>${name}</a>`;
}).join('\n')}
</div>
`;
/* Step 3: Generate templates for html content */
const isHomePath = (path: string) => path === HOME_PATH;
const getStylesheetHref = (path: string) => {
return isHomePath(path) ? STYLESHEET_PATH : `../${STYLESHEET_PATH}`;
}
const getFaviconSvg = (favicon: string) => `
<svg xmlns="http://www.w3.org/2000/svg">
<text y="32" font-size="32">${favicon ? favicon : '🦕'}</text>
/* Step 3: Generate templates for html content */
const isHomePath = (path: string) => path === HOME_PATH;
const getStylesheetHref = (path: string) => {
return isHomePath(path) ? STYLESHEET_PATH : `../${STYLESHEET_PATH}`;
}