Commit 3d0c771a authored by 吕祺's avatar 吕祺 ⛹🏽

compile

parent d84e5eb3
{
"presets": ["next/babel"],
"plugins": ["transform-remove-strict-mode"]
}
\ No newline at end of file
node_modules/
.next/
out/
\ No newline at end of file
module.exports = {
root: true,
env: {
browser: true,
node: true
},
parserOptions: {
parser: 'babel-eslint',
ecmaVersion: 6,
sourceType: "module",
ecmaFeatures:{
"jsx":true,
"experimentalObjectRestSpread":true,
"modules":true
}
},
extends: [
'plugin:prettier/recommended',
'prettier'
],
plugins: [
'prettier'
],
// add your custom rules here
rules: {
'nuxt/no-cjs-in-config': 'off',
"import/no-dynamic-require": 0,
"global-require": 0,
"prefer-rest-params": 0,
"no-unused-vars": [2, { "args": "none" }],
"import/no-extraneous-dependencies": 0,
"no-nested-ternary": 0,
"no-restricted-syntax": 0,
"indent": ["error", 2, { "SwitchCase": 1 }],
"no-plusplus": [2, { "allowForLoopAfterthoughts": true }],
"arrow-parens": [2, "always", { "requireForBlockBody": true }],
// "comma-dangle": [1, "never"],
"func-names": 0,
// "strict": [2, "global"],
"new-cap": [2, { "capIsNew": false, "newIsCapExceptions": ["connection", "message"] }],
// "no-console": 2,
"no-debugger": 2,
"no-underscore-dangle": 0,
"camelcase": 2,
"no-param-reassign": 0,
"no-bitwise": 0,
"dot-notation": [2, { "allowPattern": "^([a-z]+(_[a-z]+)+)|([_A-Z]+)$" }],
"array-bracket-spacing": 1,
"arrow-spacing": [2, { "before": true, "after": true }],
"generator-star-spacing": [2, "after"],
// "space-before-function-paren": [2, { "anonymous": "always", "named": "never" }],
"no-mixed-operators": [
"error",
{
"groups": [
["&", "|", "^", "~", "<<", ">>", ">>>"],
["==", "!=", "===", "!==", ">", ">=", "<", "<="],
["&&", "||"],
["in", "instanceof"]
]
}
],
"import/prefer-default-export": 0,
"class-methods-use-this": 0,
"no-template-curly-in-string": 0,
"no-empty": 0,
"no-global-assign": ["error", { "exceptions": ["onmessage"] }]
}
}
.next/
node_modules/
/npm-debug.log
.DS_Store
out/
.python-version
\ No newline at end of file
...@@ -2,22 +2,11 @@ stages: ...@@ -2,22 +2,11 @@ stages:
- build - build
# - deploy # - deploy
# cache: cache:
# paths: paths:
# - out - out
# - node_modules/ - node_modules/
# compile_articles:
# stage: build
# # when: manual
# environment:
# name: release
# only:
# - master
# script:
# - yarn
# - node utils/articleAggregate.js
# - sh utils/commit.sh
# compress_images: # compress_images:
# stage: build # stage: build
......
{
"semi": false,
"singleQuote": true,
"arrowParens": always
}
const withCss = require('@zeit/next-css')
const RemoveStrictPlugin = require('remove-strict-webpack-plugin')
// const StringReplacePlugin = require('string-replace-webpack-plugin')
// const exec = require('child_process').exec
module.exports = withCss({
webpack: (cfg) => {
cfg.module.rules.push({
test: /\.md$/,
use: 'frontmatter-markdown-loader'
})
// breaks sourcemap
// cfg.plugins.push(new RemoveStrictPlugin())
// cfg.plugins.push({
// apply: (compiler) => {
// compiler.hooks.afterEmit.tap('AfterEmitPlugin', (compilation) => {
// exec(
// './removeStrict.sh',
// (err, stdout, stderr) => {
// if (stdout) process.stdout.write(stdout)
// if (stderr) process.stderr.write(stderr)
// }
// )
// })
// }
// })
// cfg.module.rules.push({
// test: /\.js$/,
// loader: StringReplacePlugin.replace({
// replacements: [
// {
// pattern: /"use strict"/gi,
// replacement: function(match, p1, offset, string) {
// console.log(match)
// return ''
// }
// }
// ]
// }),
// include: /node_modules\\*/
// })
return cfg
}
})
{
"name": "awesome-kitties",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"dev": "next",
"build": "next build",
"start": "next start",
"exportwatch": "nodemon -e js,css,json,md,png,jpg,svg --exec \"npm run export\" --ignore .next/ --ignore out/",
"export": "npm run build && next export",
"lintfix": "eslint --fix --ext .js,.vue --ignore-path .gitignore ."
},
"keywords": [],
"author": "",
"license": "ISC",
"browserslist": [
"> 0.001%"
],
"dependencies": {
"@babel/plugin-proposal-decorators": "^7.4.4",
"@zeit/next-css": "^1.0.1",
"@zeit/next-less": "^1.0.1",
"classnames": "^2.2.6",
"core-decorators": "^0.20.0",
"digit-roll-react": "^1.1.0",
"js-yaml": "^4.0.0",
"less": "^3.9.0",
"marked": "^0.7.0",
"next": "^9.0.3",
"overflowbox": "^1.0.1",
"qrcode.react": "^0.9.3",
"react": "^16.8.6",
"react-dom": "^16.8.6",
"react-fastclick": "^3.0.2",
"react-tap-event-plugin": "^3.0.3",
"react-transition-group": "^4.2.2",
"respond.js": "^1.4.2",
"string-replace-webpack-plugin": "^0.1.3"
},
"devDependencies": {
"autoprefixer": "^9.6.1",
"babel-plugin-transform-remove-strict-mode": "^0.0.2",
"babel-preset-react-app": "^9.0.0",
"eruda": "^1.5.8",
"eslint": "^6.0.1",
"eslint-config-prettier": "^6.0.0",
"eslint-plugin-prettier": "^3.1.0",
"frontmatter-markdown-loader": "^1.7.0",
"images": "^3.0.2",
"postcss-adaptive": "^0.5.0",
"postcss-px2rem": "^0.3.0",
"prettier": "^1.18.2",
"remove-strict-webpack-plugin": "^0.1.2",
"string-replace-loader": "^2.2.0"
},
"nodemonConfig": {
"watch": [
"pages/",
"static/",
"content/",
"common/"
],
"ignore": [
"out/*",
".next/*"
]
}
}
@import "./base.css";
@media screen and (min-width: 540px) {
.post-wrapper img.center {
width: 50%;
margin: 1em auto;
display: block;
}
}
.post-page {
line-height: 1.6;
letter-spacing: .034em;
}
.post-page p {
font-size: 16px; /* px */
line-height: 180%;
color: #444;
font-weight: 400;
}
.post-page li {
font-size: 16px; /* px */
}
.post-page blockquote {
padding-left: 16px; /* px */
border-left: 3px solid #dbdbdb;
color: rgba(0,0,0,0.5);
font-size: 15px; /* px */
margin: 1em 0; /* px */
}
@media screen and (max-width: 540px) {
.post-page blockquote {
padding-left: 12px; /* px */
border-left: 3px solid #f0f0f0;
}
}
.post-outline-wrapper {
width: 100%;
box-sizing: border-box;
padding: 40px 0; /* px */
position: relative;
overflow: hidden;
}
.post-top {
margin: 0px 96px 60px 96px; /* px */
position: relative;
}
.post-source {
font-size: 14px; /* px */
color: #A25641;
font-weight: 500;
line-height: 24px;
}
.post-top .post-search-wrapper {
position: absolute;
right: 0;
bottom: 0;
}
.post-back {
font-size: 16px; /* px */
font-weight: 500;
color: #201714;
margin:35px auto; /* px */
width: 90%;
max-width: 824px; /* px */
}
.post-back-img {
width: 16px; /* px */
height: 13px; /* px */
margin-right: 8px; /* px */
display: inline-block;
background-image: url('/static/img/arrow-left.svg');
background-size: cover;
}
.post-wrapper {
background: white;
margin: 0 auto; /* px */
width: 90%;
box-sizing: border-box;
max-width: 824px; /* px */
padding: 40px 4%; /* px */
}
.post-wrapper img, .post-wrapper video {
width: 100%;
}
.post-wrapper .title {
line-height: 150%;
}
.post-title {
font-size: 32px; /* px */
line-height: 150%;
color: #201714;
}
.post-content {
text-align: justify;
padding-bottom: 8px; /* px */
}
/* .en .post-content {
text-align: left;
} */
.post-content a {
color: #A25641;
text-decoration: underline;
}
.post-dateshare-wrapper {
margin: 8px 0 24px; /* px */
height: 20px; /* px */
position: relative;
}
.post-date {
font-size: 14px; /* px */
color: #B3B3B3;
float: left;
font-weight: 400;
}
.post-share-wrapper {
float:right;
height: 16px; /* px */
}
.post-share-icon {
width: 16px; /* px */
height: 16px; /* px */
background-size: cover;
cursor:pointer;
float: right;
margin-left: 24px; /* px */
}
.post-share-mail {
background-image: url('/static/img/email.svg');
}
.post-share-wechat {
background-image: url('/static/img/wechat.svg');
}
.post-share-weibo {
background-image: url('/static/img/weibo.svg');
}
.post-share-qrcode {
opacity: 0;
transition: opacity .4s ease;
pointer-events: none;
background: #fff;
padding: 10px; /* px */
width: 128px; /* px */
height: 128px; /* px */
margin-top: 32px; /* px */
margin-left: -64px; /* px */
box-shadow: 0 4px 8px rgba(0,0,0,.2);
}
.post-share-wechat:hover .post-share-qrcode {
opacity: 1;
}
.post-end {
width: 16px; /* px */
height: 16px; /* px */
}
import React from 'react'
import marked from 'marked'
import newsList from '../content/newsList.md'
import Head from 'next/head'
import { Title } from '../components/Title'
/* eslint-enable no-unused-vars */
import { yymmdd } from '../utils/date'
import './post.css'
export default class PostPage extends React.Component {
constructor(props) {
super(props)
this.state = {
type: null,
article: [],
mounted: false
}
}
componentDidMount() {
let date = document.location.href.match(/d=[^=&]*/)
let type = document.location.href.match(/t=[^=&]*/)
if (!date || date.length === 0 || !type || type.length === 0) {
return null
}
date = date[0].slice(2)
type = type[0].slice(2)
const {
attributes: { news }
} = newsList
let article = []
let origin = type === 'news' ? news : articles
origin.map((n) => {
const curDate = n.createDate.replace(/[^\d]/g, '')
if (curDate === date) {
article.push(n)
}
})
this.setState({
article,
type,
mounted: true
})
}
render() {
const { article, mounted } = this.state
if (!article || !mounted) return null
if (article.length === 0) {
return <div>not found</div>
}
const post = article[0]
// console.log(post.content)
return (
<div className="post-page">
<Head>
<title>
{en === null ? '' : en ? post.titleEN : post.title}
</title>
</Head>
<div className="post-outline-wrapper">
<div className="bg"></div>
<div className="post-wrapper">
{post.type && (
<div className="post-source">
{en === null ? '' : en ? post.typeEN : post.type}
</div>
)}
<Title en={en}>
{en === null ? '' : en ? post.titleEN : post.title}
</Title>
<div className="post-dateshare-wrapper">
<div className="post-date">
{yymmdd(new Date(post.createDate)).join('/')}
</div>
</div>
<div
className="post-content"
dangerouslySetInnerHTML={(() => {
if (post.content) {
return { __html: marked(post.content) }
} else {
return { __html: '暂无内容' }
}
})()}
></div>
<div className="post-end">
<img src="/static/img/logo-yellow.svg" />
</div>
</div>
</div>
</div>
)
}
}
const config = require('./package.json')
module.exports = (ctx) => {
const plugins = {
autoprefixer: {
Browserslist: config.browserslist, // ['not ie < 8'],
flexbox: 'no-2009'
},
'postcss-px2rem': {
remUnit: 38,
baseDpr: 1
}
}
return { plugins }
}
// 'postcss-adaptive': {
// autoRem: true,
// remUnit: 144,
// baseDpr: 1,
// remPrecision: 9,
// hairlineClase: 'hairline'
// }
export const yymmdd = (date) => [
date.getFullYear(),
date.getMonth() + 1 < 10 ? `0${date.getMonth() + 1}` : date.getMonth() + 1,
date.getDate() < 10 ? `0${date.getDate()}` : date.getDate()
]
export const daySince = (dateStr) => {
const date1 = new Date()
const date2 = new Date(dateStr)
const date = (date1.getTime() - date2.getTime()) / (24 * 60 * 60 * 1000)
return parseInt(date)
}
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment