mirror of
https://github.com/jambonz/next-static-site.git
synced 2025-12-19 04:47:44 +00:00
Adding ESLint config -- run yarn lint on prebuild
This commit is contained in:
3
.eslintignore
Normal file
3
.eslintignore
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
**/node_modules/*
|
||||||
|
**/out/*
|
||||||
|
**/.next/*
|
||||||
42
.eslintrc.json
Normal file
42
.eslintrc.json
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
{
|
||||||
|
"settings": {
|
||||||
|
"react": {
|
||||||
|
"version": "detect"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"env": {
|
||||||
|
"browser": true,
|
||||||
|
"es2021": true,
|
||||||
|
"node": true
|
||||||
|
},
|
||||||
|
"extends": [
|
||||||
|
"eslint:recommended",
|
||||||
|
"plugin:react/recommended"
|
||||||
|
],
|
||||||
|
"parserOptions": {
|
||||||
|
"ecmaFeatures": {
|
||||||
|
"jsx": true
|
||||||
|
},
|
||||||
|
"ecmaVersion": 12,
|
||||||
|
"sourceType": "module"
|
||||||
|
},
|
||||||
|
"plugins": [
|
||||||
|
"react"
|
||||||
|
],
|
||||||
|
"rules": {
|
||||||
|
"react/prop-types": "off",
|
||||||
|
"react/react-in-jsx-scope": "off",
|
||||||
|
"indent": [
|
||||||
|
"error",
|
||||||
|
2
|
||||||
|
],
|
||||||
|
"quotes": [
|
||||||
|
"error",
|
||||||
|
"single"
|
||||||
|
],
|
||||||
|
"semi": [
|
||||||
|
"error",
|
||||||
|
"always"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
7
.vscode/settings.json
vendored
Normal file
7
.vscode/settings.json
vendored
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"editor.tabSize": 2,
|
||||||
|
"editor.detectIndentation": false,
|
||||||
|
"eslint.options": {
|
||||||
|
"configFile": ".eslintrc.json"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -22,6 +22,10 @@ Clone this repository and install [yarn](https://yarnpkg.com/getting-started/ins
|
|||||||
- Installs node packages
|
- Installs node packages
|
||||||
- `yarn dev`
|
- `yarn dev`
|
||||||
- Serves local dev at [localhost:3000](http://localhost:3000)
|
- Serves local dev at [localhost:3000](http://localhost:3000)
|
||||||
|
- `yarn lint`
|
||||||
|
- Runs [ESLint](https://eslint.org/) validations on source JS
|
||||||
|
- ESLint errors will fail your builds so check your code before pushing
|
||||||
|
- Install the [ESLint plugin for Visual Studio Code](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint&ssr=false#overview)
|
||||||
- `yarn build && yarn start`
|
- `yarn build && yarn start`
|
||||||
- Create an optimized Next.js production build and serve it locally
|
- Create an optimized Next.js production build and serve it locally
|
||||||
- `yarn build && yarn export`
|
- `yarn build && yarn export`
|
||||||
|
|||||||
@@ -23,13 +23,13 @@ export default function Footer({ siteData }) {
|
|||||||
<div className="foot__navs">
|
<div className="foot__navs">
|
||||||
<ul className="foot__links">
|
<ul className="foot__links">
|
||||||
{siteData.footer.links.map((obj) => {
|
{siteData.footer.links.map((obj) => {
|
||||||
return <FooterItem key={nanoid()} obj={obj} />
|
return <FooterItem key={nanoid()} obj={obj} />;
|
||||||
})}
|
})}
|
||||||
</ul>
|
</ul>
|
||||||
<ul className="foot__links">
|
<ul className="foot__links">
|
||||||
<FooterItem key="home" obj={siteData.navi.home} />
|
<FooterItem key="home" obj={siteData.navi.home} />
|
||||||
{siteData.navi.links.map((obj) => {
|
{siteData.navi.links.map((obj) => {
|
||||||
return <FooterItem key={nanoid()} obj={obj} />
|
return <FooterItem key={nanoid()} obj={obj} />;
|
||||||
})}
|
})}
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ export function useMobileMedia() {
|
|||||||
|
|
||||||
return function cleanup() {
|
return function cleanup() {
|
||||||
mql.removeListener(handleMedia);
|
mql.removeListener(handleMedia);
|
||||||
}
|
};
|
||||||
}, [handleMedia, setMobile]);
|
}, [handleMedia, setMobile]);
|
||||||
|
|
||||||
return mobile;
|
return mobile;
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import Head from 'next/head';
|
|||||||
import Navi from './navi';
|
import Navi from './navi';
|
||||||
import Footer from './footer';
|
import Footer from './footer';
|
||||||
|
|
||||||
export default function Layout({ children, siteData, title = "jambonz" }) {
|
export default function Layout({ children, siteData, title = 'jambonz' }) {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Head>
|
<Head>
|
||||||
|
|||||||
@@ -49,12 +49,12 @@ function NaviMobile({ active, handler, siteData }) {
|
|||||||
<ul className="navi__mobile__links">
|
<ul className="navi__mobile__links">
|
||||||
<NaviItem key="home" obj={siteData.navi.home} />
|
<NaviItem key="home" obj={siteData.navi.home} />
|
||||||
{siteData.navi.links.map((obj) => {
|
{siteData.navi.links.map((obj) => {
|
||||||
return <NaviItem key={nanoid()} obj={obj} />
|
return <NaviItem key={nanoid()} obj={obj} />;
|
||||||
})}
|
})}
|
||||||
</ul>
|
</ul>
|
||||||
<ul className="navi__mobile__footer">
|
<ul className="navi__mobile__footer">
|
||||||
{siteData.footer.links.map((obj) => {
|
{siteData.footer.links.map((obj) => {
|
||||||
return <NaviItem key={nanoid()} obj={obj} />
|
return <NaviItem key={nanoid()} obj={obj} />;
|
||||||
})}
|
})}
|
||||||
</ul>
|
</ul>
|
||||||
<div className="navi__mobile__support">
|
<div className="navi__mobile__support">
|
||||||
@@ -89,7 +89,7 @@ export default function Navi({ siteData }) {
|
|||||||
</Link>
|
</Link>
|
||||||
<ul className="navi__links">
|
<ul className="navi__links">
|
||||||
{siteData.navi.links.map((obj) => {
|
{siteData.navi.links.map((obj) => {
|
||||||
return <NaviItem key={nanoid()} obj={obj} />
|
return <NaviItem key={nanoid()} obj={obj} />;
|
||||||
})}
|
})}
|
||||||
</ul>
|
</ul>
|
||||||
<div className="navi__icon" onClick={handleNavi}>
|
<div className="navi__icon" onClick={handleNavi}>
|
||||||
|
|||||||
14
lib/data.js
14
lib/data.js
@@ -30,9 +30,9 @@ export function getData(key) {
|
|||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
function _getCleanSlug(slug) {
|
function _getCleanSlug(slug) {
|
||||||
return slug
|
return slug
|
||||||
.replace(docsDir, '')
|
.replace(docsDir, '')
|
||||||
.replace(/^\/+|\/+$/, '')
|
.replace(/^\/+|\/+$/, '')
|
||||||
.split('/');
|
.split('/');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load Markdown and YAML front-matter to generate the static props for Next.js docs component
|
// Load Markdown and YAML front-matter to generate the static props for Next.js docs component
|
||||||
@@ -43,16 +43,16 @@ async function _getDocs(filePath) {
|
|||||||
|
|
||||||
// Use remark to convert markdown into HTML string
|
// Use remark to convert markdown into HTML string
|
||||||
const processedContent = await remark()
|
const processedContent = await remark()
|
||||||
.use(remarkGfm)
|
.use(remarkGfm)
|
||||||
.use(remarkHtml)
|
.use(remarkHtml)
|
||||||
.process(fileMatter.content);
|
.process(fileMatter.content);
|
||||||
const contentHtml = processedContent.toString();
|
const contentHtml = processedContent.toString();
|
||||||
|
|
||||||
// Combine the data with the slug and contentHtml
|
// Combine the data with the slug and contentHtml
|
||||||
return {
|
return {
|
||||||
contentHtml,
|
contentHtml,
|
||||||
frontMatter,
|
frontMatter,
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// Walk the pages/docs file tree to generate the static paths for Next.js docs pages
|
// Walk the pages/docs file tree to generate the static paths for Next.js docs pages
|
||||||
|
|||||||
@@ -6,8 +6,10 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "next",
|
"dev": "next",
|
||||||
"start": "next start",
|
"start": "next start",
|
||||||
|
"prebuild": "yarn lint",
|
||||||
"build": "next build",
|
"build": "next build",
|
||||||
"export": "next export"
|
"export": "next export",
|
||||||
|
"lint": "eslint ./ --ext js,jsx,ts,tsx"
|
||||||
},
|
},
|
||||||
"author": "Jambonz Developers",
|
"author": "Jambonz Developers",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
@@ -23,6 +25,8 @@
|
|||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"babel-plugin-prismjs": "^2.0.1",
|
"babel-plugin-prismjs": "^2.0.1",
|
||||||
"env-cmd": "^10.1.0",
|
"env-cmd": "^10.1.0",
|
||||||
|
"eslint": "^7.25.0",
|
||||||
|
"eslint-plugin-react": "^7.23.2",
|
||||||
"gray-matter": "^4.0.2",
|
"gray-matter": "^4.0.2",
|
||||||
"remark": "^13.0.0",
|
"remark": "^13.0.0",
|
||||||
"remark-gfm": "^1.0.0",
|
"remark-gfm": "^1.0.0",
|
||||||
|
|||||||
@@ -130,7 +130,7 @@ function BYO({data}) {
|
|||||||
</div>
|
</div>
|
||||||
<div className="byo__icons icons">
|
<div className="byo__icons icons">
|
||||||
{data.icons.map((icon) => {
|
{data.icons.map((icon) => {
|
||||||
return <Icon key={nanoid()} name={icon} style="fill" />
|
return <Icon key={nanoid()} name={icon} style="fill" />;
|
||||||
})}
|
})}
|
||||||
</div>
|
</div>
|
||||||
<div className="byo__comment">
|
<div className="byo__comment">
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ function Services({data}) {
|
|||||||
return (
|
return (
|
||||||
<div key={nanoid()} className="services__option">
|
<div key={nanoid()} className="services__option">
|
||||||
<P>
|
<P>
|
||||||
<a className="i" href={`${data.url}?subject=${service.title} Support`} target="_blank">
|
<a className="i" href={`${data.url}?subject=${service.title} Support`} target="_blank" rel="noreferrer">
|
||||||
<strong>{service.title}</strong>
|
<strong>{service.title}</strong>
|
||||||
<Icon name="ExternalLink" />
|
<Icon name="ExternalLink" />
|
||||||
</a>
|
</a>
|
||||||
|
|||||||
Reference in New Issue
Block a user