rename files

This commit is contained in:
polv committed 2020-12-15 16:27:52 +07:00
1 parent 1fdaf73f14
commit 31dd2b0049
72 files changed
+10320 -31

No files matched your search

-3
View File
@@ -1,3 +0,0 @@
[submodule "template"]
path = template
url = git@github.com:patarapolw/nuxt-blog-template.git
-4
View File
@@ -1,4 +0,0 @@
{
"no-inline-html": false,
"line-length": false
}
+7
View File
@@ -0,0 +1,7 @@
{
"editor.defaultFormatter": "rvest.vs-code-prettier-eslint",
"editor.formatOnSave": true,
"files.associations": {
".env.*": "dotenv"
}
}
File renamed without changes.

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 15 KiB

@@ -1,6 +1,6 @@
---
title: "千字文"
date: "2019-08-10"
date: 2019-08-10T00:00:00+07:00
tag:
- 千字文
- 汉字
@@ -1,6 +1,6 @@
---
title: "句子 1.1"
date: "2019-08-16 01:00"
date: 2019-08-16T01:00:00+07:00
tag:
- 千字文
- 句子
@@ -1,6 +1,6 @@
---
title: "句子 1.2"
date: "2019-08-17 01:00"
date: 2019-08-17T01:00:00+07:00
tag:
- 千字文
- 句子
@@ -1,6 +1,6 @@
---
title: "句子 1.3"
date: "2019-08-17 02:00"
date: 2019-08-17T02:00:00+07:00
tag:
- 千字文
- 句子
@@ -1,6 +1,6 @@
---
title: "身体1"
date: "2019-08-18 01:00"
date: 2019-08-18T01:00:00+07:00
tag:
- 分类词汇
- 身体
@@ -1,6 +1,6 @@
---
title: "Learning Chinese using Git -- ZhLab"
date: "2019-09-25"
date: 2019-09-25T00:00:00+07:00
tag:
- diary
---
@@ -1,6 +1,6 @@
---
title: "Fruit and vegetables quiz"
date: "2019-09-30"
date: 2019-09-30T00:00:00+07:00
image: https://images.chinatimes.com/newsphoto/2018-12-31/900/20181231000035.jpg
tag:
- quiz
@@ -1,6 +1,6 @@
---
title: "Move to new URL notice"
date: "2019-10-07"
date: 2019-10-07T00:00:00+07:00
tag:
- diary
---
@@ -1,6 +1,6 @@
---
title: "Chinese from Emoji 1: 学习用品"
date: 2019-11-26
date: 2019-11-26T00:00:00+07:00
image: https://encrypted-tbn0.gstatic.com/images?q=tbn%3AANd9GcQpaKJKlp3UhF_S-Q5sPWmLnKhwb8Ey0sqA7ersas1OJcAgZFzB
tag:
- vocab
@@ -1,6 +1,6 @@
---
title: "Chinese from Emoji 2: 陆地动物"
date: 2019-11-27
date: 2019-11-27T00:00:00+07:00
image: https://encrypted-tbn0.gstatic.com/images?q=tbn%3AANd9GcQpaKJKlp3UhF_S-Q5sPWmLnKhwb8Ey0sqA7ersas1OJcAgZFzB
tag:
- vocab
@@ -1,6 +1,6 @@
---
title: Moving to Netlify
date: 2019-11-25
date: 2019-11-25T00:00:00+07:00
tag:
- diary
---
@@ -1,6 +1,6 @@
---
title: Back to former glory
date: 2019-12-07
date: 2019-12-07T00:00:00+07:00
tag:
- vuetify
- resources
@@ -1,6 +1,6 @@
---
title: "Chinese from Emoji 3: 水生和昆虫"
date: 2019-12-08
date: 2019-12-08T00:00:00+07:00
image: https://steamuserimages-a.akamaihd.net/ugc/264973755082472713/B44953104F4F5FBB70205CCCD759E511C0E50E52/
tag:
- vocab
@@ -1,6 +1,6 @@
---
title: 我和你 - Another song I always hear.
date: 2020-02-26
date: 2020-02-26T00:00:00+07:00
tag:
- 邓丽君
- song
@@ -1,6 +1,6 @@
---
title: ZhLevel Level 1
date: 2020-03-23
date: 2020-03-23T00:00:00+07:00
tag:
- zhlevel
---
@@ -1,6 +1,6 @@
---
title: ZhLevel Level 2
date: 2020-03-23
date: 2020-03-23T00:00:00+07:00
tag:
- zhlevel
---
@@ -1,6 +1,6 @@
---
title: ZhLevel Level 3
date: 2020-03-25
date: 2020-03-25T00:00:00+07:00
tag:
- zhlevel
---
@@ -1,6 +1,6 @@
---
title: 千里之外
date: 2020-04-20
date: 2020-04-20T00:00:00+07:00
tag:
- song
---
@@ -1,6 +1,6 @@
---
title: 祝福
date: 2020-04-18
date: 2020-04-18T00:00:00+07:00
tag:
- song
---
@@ -1,6 +1,6 @@
---
title: 虫儿飞
date: 2020-04-10
date: 2020-04-10T00:00:00+07:00
tag:
- song
---
@@ -1,6 +1,6 @@
---
title: "千字文 - 1/1"
date: "2019-08-11"
date: 2019-08-11T00:00:00+07:00
tag:
- 千字文
- 汉字
@@ -1,6 +1,6 @@
---
title: "千字文 - 1/2"
date: "2019-08-12"
date: 2019-08-12T00:00:00+07:00
tag:
- 千字文
- 汉字
@@ -1,6 +1,6 @@
---
title: "千字文 - 1/3"
date: "2019-08-13"
date: 2019-10-08T00:00:00+07:00
tag:
- 千字文
- 汉字
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
+13
View File
@@ -0,0 +1,13 @@
# editorconfig.org
root = true
[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
[*.md]
trim_trailing_whitespace = false
+17
View File
@@ -0,0 +1,17 @@
module.exports = {
root: true,
env: {
browser: true,
node: true,
},
extends: [
'@nuxtjs/eslint-config-typescript',
'prettier',
'prettier/vue',
'plugin:prettier/recommended',
'plugin:nuxt/recommended',
],
plugins: ['prettier'],
// add your custom rules here
rules: {},
}
+90
View File
@@ -0,0 +1,90 @@
# Created by .ignore support plugin (hsz.mobi)
### Node template
# Logs
/logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# Runtime data
pids
*.pid
*.seed
*.pid.lock
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
# nyc test coverage
.nyc_output
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# Bower dependency directory (https://bower.io/)
bower_components
# node-waf configuration
.lock-wscript
# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release
# Dependency directories
node_modules/
jspm_packages/
# TypeScript v1 declaration files
typings/
# Optional npm cache directory
.npm
# Optional eslint cache
.eslintcache
# Optional REPL history
.node_repl_history
# Output of 'npm pack'
*.tgz
# Yarn Integrity file
.yarn-integrity
# dotenv environment variables file
.env
# parcel-bundler cache (https://parceljs.org/)
.cache
# next.js build output
.next
# nuxt.js build output
.nuxt
# Nuxt generate
dist
# vuepress build output
.vuepress/dist
# Serverless directories
.serverless
# IDE / Editor
.idea
# Service worker
sw.*
# macOS
.DS_Store
# Vim swap files
*.swp
+4
View File
@@ -0,0 +1,4 @@
{
"semi": false,
"singleQuote": true
}
+4
View File
@@ -0,0 +1,4 @@
{
"editor.formatOnSave": true,
"editor.defaultFormatter": "rvest.vs-code-prettier-eslint"
}
+20
View File
@@ -0,0 +1,20 @@
# zhdiary
## Build Setup
```bash
# install dependencies
$ yarn install
# serve with hot reload at localhost:3000
$ yarn dev
# build for production and launch server
$ yarn build
$ yarn start
# generate static project
$ yarn generate
```
For detailed explanation on how things work, check out [Nuxt.js docs](https://nuxtjs.org).
+7
View File
@@ -0,0 +1,7 @@
# ASSETS
**This directory is not required, you can delete it if you don't want to use it.**
This directory contains your un-compiled assets such as LESS, SASS, or JavaScript.
More information about the usage of this directory in [the documentation](https://nuxtjs.org/guide/assets#webpacked).
+56
View File
@@ -0,0 +1,56 @@
import sqlite3 from 'better-sqlite3'
export interface IPost {
slug: string
date?: Date
title: string
image?: string
tag?: string[]
/**
* cleaned markdown
*/
content: string
excerptHtml: string
contentHtml: string
}
export class Database {
db: sqlite3.Database
constructor(public filepath: string) {
this.db = sqlite3(filepath)
}
public init(): void {
this.db.exec(/* sql */ `
CREATE VIRTUAL TABLE q USING fts5 (
slug,
[date] UNINDEXED, -- epoch milli
title,
[image] UNINDEXED,
tag, -- space separated
content, -- cleaned markdown
excerptHtml UNINDEXED,
contentHtml UNINDEXED
);
`)
}
public insert(...ps: IPost[]): void {
const stmt = this.db.prepare(/* sql */ `
INSERT INTO q (slug, [date], title, [image], tag, content, excerptHtml, contentHtml)
VALUES (@slug, @date, @title, @image, @tag, @content, @excerptHtml, @contentHtml)
`)
this.db.transaction(() => {
// eslint-disable-next-line array-callback-return
ps.map((p) => {
stmt.run({
...p,
date: p.date ? p.date.getTime() : undefined,
tag: (p.tag || []).join(' '),
})
})
})()
}
}
+35
View File
@@ -0,0 +1,35 @@
<template>
<svg
class="NuxtLogo"
width="245"
height="180"
viewBox="0 0 452 342"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M139 330l-1-2c-2-4-2-8-1-13H29L189 31l67 121 22-16-67-121c-1-2-9-14-22-14-6 0-15 2-22 15L5 303c-1 3-8 16-2 27 4 6 10 12 24 12h136c-14 0-21-6-24-12z"
fill="#00C58E"
/>
<path
d="M447 304L317 70c-2-2-9-15-22-15-6 0-15 3-22 15l-17 28v54l39-67 129 230h-49a23 23 0 0 1-2 14l-1 1c-6 11-21 12-23 12h76c3 0 17-1 24-12 3-5 5-14-2-26z"
fill="#108775"
/>
<path
d="M376 330v-1l1-2c1-4 2-8 1-12l-4-12-102-178-15-27h-1l-15 27-102 178-4 12a24 24 0 0 0 2 15c4 6 10 12 24 12h190c3 0 18-1 25-12zM256 152l93 163H163l93-163z"
fill="#2F495E"
/>
</svg>
</template>
<style>
.NuxtLogo {
animation: 1s appear;
margin: auto;
}
@keyframes appear {
0% {
opacity: 0;
}
}
</style>
+7
View File
@@ -0,0 +1,7 @@
# COMPONENTS
**This directory is not required, you can delete it if you don't want to use it.**
The components directory contains your Vue.js Components.
_Nuxt.js doesn't supercharge these components._
+7
View File
@@ -0,0 +1,7 @@
# LAYOUTS
**This directory is not required, you can delete it if you don't want to use it.**
This directory contains your Application Layouts.
More information about the usage of this directory in [the documentation](https://nuxtjs.org/guide/views#layouts).
+55
View File
@@ -0,0 +1,55 @@
<template>
<div>
<Nuxt />
</div>
</template>
<style>
html {
font-family: 'Source Sans Pro', -apple-system, BlinkMacSystemFont, 'Segoe UI',
Roboto, 'Helvetica Neue', Arial, sans-serif;
font-size: 16px;
word-spacing: 1px;
-ms-text-size-adjust: 100%;
-webkit-text-size-adjust: 100%;
-moz-osx-font-smoothing: grayscale;
-webkit-font-smoothing: antialiased;
box-sizing: border-box;
}
*,
*::before,
*::after {
box-sizing: border-box;
margin: 0;
}
.button--green {
display: inline-block;
border-radius: 4px;
border: 1px solid #3b8070;
color: #3b8070;
text-decoration: none;
padding: 10px 30px;
}
.button--green:hover {
color: #fff;
background-color: #3b8070;
}
.button--grey {
display: inline-block;
border-radius: 4px;
border: 1px solid #35495e;
color: #35495e;
text-decoration: none;
padding: 10px 30px;
margin-left: 15px;
}
.button--grey:hover {
color: #fff;
background-color: #35495e;
}
</style>
+8
View File
@@ -0,0 +1,8 @@
# MIDDLEWARE
**This directory is not required, you can delete it if you don't want to use it.**
This directory contains your application middleware.
Middleware let you define custom functions that can be run before rendering either a page or a group of pages.
More information about the usage of this directory in [the documentation](https://nuxtjs.org/guide/routing#middleware).
+39
View File
@@ -0,0 +1,39 @@
export default {
// Global page headers (https://go.nuxtjs.dev/config-head)
head: {
title: 'zhdiary',
meta: [
{ charset: 'utf-8' },
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },
{ hid: 'description', name: 'description', content: '' },
],
link: [{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }],
},
// Global CSS (https://go.nuxtjs.dev/config-css)
css: [],
// Plugins to run before rendering page (https://go.nuxtjs.dev/config-plugins)
plugins: [],
// Auto import components (https://go.nuxtjs.dev/config-components)
components: true,
// Modules for dev and build (recommended) (https://go.nuxtjs.dev/config-modules)
buildModules: [
// https://go.nuxtjs.dev/typescript
'@nuxt/typescript-build',
],
// Modules (https://go.nuxtjs.dev/config-modules)
modules: [
// https://go.nuxtjs.dev/axios
'@nuxtjs/axios',
],
// Axios module configuration (https://go.nuxtjs.dev/config-axios)
axios: {},
// Build Configuration (https://go.nuxtjs.dev/config-build)
build: {},
}
+62
View File
@@ -0,0 +1,62 @@
{
"name": "@patarapolw/nuxt-awsm",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "nuxt-ts",
"build": "nuxt-ts build",
"start": "nuxt-ts start",
"generate": "nuxt-ts generate",
"lint:js": "eslint --ext .ts,.js,.vue --ignore-path .gitignore .",
"lint": "yarn lint:js",
"ts": "ts-node -O '{\"module\":\"commonjs\"}'"
},
"dependencies": {
"@nuxt/typescript-runtime": "^2.0.0",
"@nuxtjs/axios": "^5.12.2",
"@patarapolw/scope-css": "^1.3.0",
"@types/js-yaml": "^3.12.5",
"better-sqlite3": "^7.1.1",
"cheerio": "^1.0.0-rc.3",
"core-js": "^3.6.5",
"js-yaml": "^3.14.1",
"nuxt": "^2.14.6",
"showdown": "^1.9.1",
"zod": "^1.11.11"
},
"devDependencies": {
"@nuxt/types": "^2.14.6",
"@nuxt/typescript-build": "^2.0.3",
"@nuxtjs/eslint-config": "^3.1.0",
"@nuxtjs/eslint-config-typescript": "^3.0.0",
"@nuxtjs/eslint-module": "^2.0.0",
"@types/better-sqlite3": "^5.4.1",
"@types/cheerio": "^0.22.23",
"@types/fs-extra": "^9.0.5",
"@types/rimraf": "^3.0.0",
"@types/showdown": "^1.9.3",
"babel-eslint": "^10.1.0",
"dotenv": "^8.2.0",
"eslint": "^7.10.0",
"eslint-config-prettier": "^6.12.0",
"eslint-plugin-nuxt": "^1.0.0",
"eslint-plugin-prettier": "^3.1.4",
"import-sort-parser-typescript": "^6.0.0",
"prettier": "^2.1.2",
"ts-node": "^9.1.1",
"typescript": "4.0.5"
},
"importSort": {
".ts, .tsx, .config.ts": {
"parser": "typescript",
"style": "module"
}
},
"engines": {
"node": "12",
"npm": "please-use-yarn",
"yarn": "1",
"pnpm": "please-use-yarn"
},
"engineStrict": true
}
+6
View File
@@ -0,0 +1,6 @@
# PAGES
This directory contains your Application Views and Routes.
The framework reads all the `*.vue` files inside this directory and creates the router of your application.
More information about the usage of this directory in [the documentation](https://nuxtjs.org/guide/routing).
+65
View File
@@ -0,0 +1,65 @@
<template>
<div class="container">
<div>
<Logo />
<h1 class="title">zhdiary</h1>
<div class="links">
<a
href="https://nuxtjs.org/"
target="_blank"
rel="noopener noreferrer"
class="button--green"
>
Documentation
</a>
<a
href="https://github.com/nuxt/nuxt.js"
target="_blank"
rel="noopener noreferrer"
class="button--grey"
>
GitHub
</a>
</div>
</div>
</div>
</template>
<script lang="ts">
import Vue from 'vue'
export default Vue.extend({})
</script>
<style>
.container {
margin: 0 auto;
min-height: 100vh;
display: flex;
justify-content: center;
align-items: center;
text-align: center;
}
.title {
font-family: 'Quicksand', 'Source Sans Pro', -apple-system, BlinkMacSystemFont,
'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
display: block;
font-weight: 300;
font-size: 100px;
color: #35495e;
letter-spacing: 1px;
}
.subtitle {
font-weight: 300;
font-size: 42px;
color: #526488;
word-spacing: 5px;
padding-bottom: 15px;
}
.links {
padding-top: 15px;
}
</style>
+7
View File
@@ -0,0 +1,7 @@
# PLUGINS
**This directory is not required, you can delete it if you don't want to use it.**
This directory contains Javascript plugins that you want to run before mounting the root Vue.js application.
More information about the usage of this directory in [the documentation](https://nuxtjs.org/guide/plugins).
+24
View File
@@ -0,0 +1,24 @@
import fs from 'fs'
import path from 'path'
import dotenv from 'dotenv'
dotenv.config({ path: '../../.env' })
dotenv.config()
export const CONTENT_PATH = path.resolve(
process.env.CONTENT_PATH ||
(fs.existsSync('../../_posts') ? '../..' : 'content')
)
export const srcPostPath = (...ps: string[]): string =>
path.join(CONTENT_PATH, '_posts', ...ps)
export const srcMediaPath = (...ps: string[]): string =>
path.join(CONTENT_PATH, '_media', ...ps)
export const builtPath = (...ps: string[]): string =>
path.join(__dirname, '../built', ...ps)
export const dstMediaPath = (...ps: string[]): string =>
path.join(__dirname, '../public/media', ...ps)
+67
View File
@@ -0,0 +1,67 @@
import crypto from 'crypto'
import scopeCss from '@patarapolw/scope-css'
import cheerio from 'cheerio'
import showdown from 'showdown'
export class MakeHTML {
$ = cheerio.load('');
mdConverter = new showdown.Converter({
noHeaderId: true,
parseImgDimensions: true,
simplifiedAutoLink: true,
// literalMidWordUnderscores: true,
strikethrough: true,
tables: true,
tasklists: true,
simpleLineBreaks: true,
openLinksInNewWindow: true,
backslashEscapesHTMLTags: true,
emoji: true,
underline: true,
metadata: true
});
constructor (private slug: string) {
/**
* ! For some reasons default underscore italic fails to render...
*/
this.mdConverter.addExtension(
{
type: 'lang',
regex: /([^\\])_{1}(.*?[^\\])_{1}/g,
replace: '$1<i>$2</i>'
},
'underscore-italic'
)
}
parse (md: string): string {
const id =
'md-' +
crypto
.createHash('sha256')
.update(this.slug || md)
.digest()
.toString('hex')
.substr(8)
const $div = this.$(`<div id="${id}">`)
$div.html(this.mdConverter.makeHtml(md))
$div.find('style').each((_, el) => {
const $el = this.$(el)
$el.html(scopeCss($el.html(), `#${id}`))
})
return this.$('<div>').append($div).html()
}
clean (md: string): string {
const $div = this.$('<div>')
$div.html(this.mdConverter.makeHtml(md))
$div.remove('style')
return $div.html()
}
}
+74
View File
@@ -0,0 +1,74 @@
import fg from 'fast-glob'
import fs from 'fs-extra'
import yaml from 'js-yaml'
import rimraf from 'rimraf'
import * as z from 'zod'
import { Database } from '../assets/schema'
import { builtPath, dstMediaPath, srcMediaPath, srcPostPath } from './dir'
import { MakeHTML } from './make-html'
async function main() {
rimraf.sync(dstMediaPath())
rimraf.sync(builtPath())
await fs.copy(srcMediaPath(), dstMediaPath())
await fs.ensureDir(builtPath())
const db = new Database(builtPath('data.db'))
db.init()
const files = await fg('**/*.md', {
cwd: srcPostPath(),
})
// eslint-disable-next-line array-callback-return
files.map((f) => {
const slug = f.replace(/^.+\//, '').replace(/\.md$/, '')
let header: Record<string, unknown> = {}
let markdown = fs.readFileSync(srcPostPath(f), 'utf8')
if (markdown.startsWith('---\n')) {
const [h, c = ''] = markdown.substr(4).split(/---\n(.*)$/s)
header = yaml.safeLoad(h, {
schema: yaml.JSON_SCHEMA,
}) as Record<string, unknown>
markdown = c
}
const makeHtml = new MakeHTML(slug)
const { title, date, image, tag } = (() => {
const { title, date, image, tag } = header
return z
.object({
title: z.string(),
date: z.date().optional(),
image: z.string().optional(),
tag: z.array(z.string()).optional(),
})
.parse({ title, date, image, tag })
})()
const content = makeHtml.clean(markdown)
const excerptHtml = makeHtml.parse(
markdown.split(/<!-- excerpt(?:_separator)? -->/)[0]
)
const contentHtml = makeHtml.parse(markdown)
db.insert({
slug,
title,
date,
image,
tag,
content,
excerptHtml,
contentHtml,
})
})
}
if (require.main === module) {
main()
}
+11
View File
@@ -0,0 +1,11 @@
# STATIC
**This directory is not required, you can delete it if you don't want to use it.**
This directory contains your static files.
Each file inside this directory is mapped to `/`.
Thus you'd want to delete this README.md before deploying to production.
Example: `/static/robots.txt` is mapped as `/robots.txt`.
More information about the usage of this directory in [the documentation](https://nuxtjs.org/guide/assets#static).
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

+10
View File
@@ -0,0 +1,10 @@
# STORE
**This directory is not required, you can delete it if you don't want to use it.**
This directory contains your Vuex Store files.
Vuex Store option is implemented in the Nuxt.js framework.
Creating a file in this directory automatically activates the option in the framework.
More information about the usage of this directory in [the documentation](https://nuxtjs.org/guide/vuex-store).
+36
View File
@@ -0,0 +1,36 @@
{
"compilerOptions": {
"target": "ES2018",
"module": "ESNext",
"moduleResolution": "Node",
"lib": [
"ESNext",
"ESNext.AsyncIterable",
"DOM"
],
"esModuleInterop": true,
"allowJs": true,
"sourceMap": true,
"strict": true,
"noEmit": true,
"experimentalDecorators": true,
"baseUrl": ".",
"paths": {
"~/*": [
"./*"
],
"@/*": [
"./*"
]
},
"types": [
"@types/node",
"@nuxt/types"
]
},
"exclude": [
"node_modules",
".nuxt",
"dist"
]
}
File diff suppressed because it is too large. Load diff
Submodule template deleted from 0260f4b19f.