mirror of
https://github.com/dzeiocom/markblog.git
synced 2025-04-22 02:42:14 +00:00
Updated
Signed-off-by: Avior <florian.bouillon@delta-wings.net>
This commit is contained in:
parent
fee40613f1
commit
59a0862d58
@ -150,7 +150,6 @@ module.exports = {
|
|||||||
"no-bitwise": "error",
|
"no-bitwise": "error",
|
||||||
"no-caller": "error",
|
"no-caller": "error",
|
||||||
"no-cond-assign": "error",
|
"no-cond-assign": "error",
|
||||||
"no-console": "error",
|
|
||||||
"no-debugger": "error",
|
"no-debugger": "error",
|
||||||
"no-empty": "error",
|
"no-empty": "error",
|
||||||
"no-eval": "error",
|
"no-eval": "error",
|
||||||
|
@ -35,6 +35,7 @@ export default class Post implements PostInterface {
|
|||||||
public static async fetchAll(): Promise<Array<Post>> {
|
public static async fetchAll(): Promise<Array<Post>> {
|
||||||
const files: Array<string> = ((require as any).context('../posts', true, /\.md$/)).keys()
|
const files: Array<string> = ((require as any).context('../posts', true, /\.md$/)).keys()
|
||||||
const posts: Array<Post> = []
|
const posts: Array<Post> = []
|
||||||
|
console.log(files)
|
||||||
for (const file of files) {
|
for (const file of files) {
|
||||||
posts.push(new Post(file.replace('./', '')))
|
posts.push(new Post(file.replace('./', '')))
|
||||||
}
|
}
|
||||||
@ -43,10 +44,6 @@ export default class Post implements PostInterface {
|
|||||||
|
|
||||||
|
|
||||||
public async fetch() {
|
public async fetch() {
|
||||||
if (!this.slug.endsWith('.md')) {
|
|
||||||
this.slug = `portfolio/${this.slug}.md`
|
|
||||||
}
|
|
||||||
|
|
||||||
const content = await import(`../posts/${this.slug}`)
|
const content = await import(`../posts/${this.slug}`)
|
||||||
const md = matter(content.default)
|
const md = matter(content.default)
|
||||||
this.title = md.data.title
|
this.title = md.data.title
|
||||||
@ -55,10 +52,6 @@ export default class Post implements PostInterface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public fetchSync() {
|
public fetchSync() {
|
||||||
if (!this.slug.endsWith('.md')) {
|
|
||||||
this.slug = `portfolio/${this.slug}.md`
|
|
||||||
}
|
|
||||||
|
|
||||||
const content = require(`../posts/${this.slug}`)
|
const content = require(`../posts/${this.slug}`)
|
||||||
const md = matter(content.default)
|
const md = matter(content.default)
|
||||||
this.title = md.data.title
|
this.title = md.data.title
|
||||||
|
@ -24,11 +24,16 @@ interface States {
|
|||||||
export default class PostPage extends Component<Props, States> {
|
export default class PostPage extends Component<Props, States> {
|
||||||
|
|
||||||
public static async getInitialProps(context: NextPageContext) {
|
public static async getInitialProps(context: NextPageContext) {
|
||||||
const { slug } = context.query
|
const { slug, category } = context.query
|
||||||
if (typeof slug === 'object' || slug === '[slug]') {
|
if (
|
||||||
|
typeof slug === 'object' ||
|
||||||
|
slug === '[slug]' ||
|
||||||
|
typeof category === 'object' ||
|
||||||
|
category === '[category]'
|
||||||
|
) {
|
||||||
return {post: undefined}
|
return {post: undefined}
|
||||||
}
|
}
|
||||||
const post = new Post(slug)
|
const post = new Post(`${category}/${slug}`)
|
||||||
await post.fetch()
|
await post.fetch()
|
||||||
return {post}
|
return {post}
|
||||||
}
|
}
|
||||||
|
@ -26,14 +26,15 @@ export default class Page extends Component<Props, States> {
|
|||||||
const posts = await Post.fetchAll()
|
const posts = await Post.fetchAll()
|
||||||
const header: Array<PostHeader> = []
|
const header: Array<PostHeader> = []
|
||||||
const cats: Array<string> = []
|
const cats: Array<string> = []
|
||||||
posts.forEach(el => {
|
for (const el of posts) {
|
||||||
el.fetchSync()
|
await el.fetch()
|
||||||
if (!el.header) {
|
if (!el.header) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
header.push(el.header)
|
header.push(el.header)
|
||||||
cats.push(...el.header.tags || [])
|
cats.push(...el.header.tags || [])
|
||||||
})
|
}
|
||||||
|
|
||||||
header.sort((a, b) => (a.date < b.date) ? 1 : -1)
|
header.sort((a, b) => (a.date < b.date) ? 1 : -1)
|
||||||
|
|
||||||
cats.sort((a, b) => (a < b) ? -1 : 1)
|
cats.sort((a, b) => (a < b) ? -1 : 1)
|
||||||
|
@ -80,10 +80,11 @@ PortfolioIndex.getInitialProps = async (context: NextPageContext) => {
|
|||||||
if (!post.isStarted) {
|
if (!post.isStarted) {
|
||||||
await post.fetch()
|
await post.fetch()
|
||||||
}
|
}
|
||||||
const tags = []
|
|
||||||
if (!post.header) {
|
if (!post.header) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const tags = []
|
||||||
for (const tg of post.header.tags || []) {
|
for (const tg of post.header.tags || []) {
|
||||||
tags.push(tg.toLowerCase())
|
tags.push(tg.toLowerCase())
|
||||||
}
|
}
|
||||||
|
@ -1,20 +0,0 @@
|
|||||||
const glob = require('glob')
|
|
||||||
const fs = require('fs')
|
|
||||||
|
|
||||||
// DOMAIN NAME WITHOUT THE LAST /
|
|
||||||
const domain = "https://www.avior.me"
|
|
||||||
|
|
||||||
const files = glob.sync('./out/**/*.html')
|
|
||||||
let res = `<?xml version="1.0" encoding="UTF-8"?><urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">`
|
|
||||||
|
|
||||||
for (let file of files) {
|
|
||||||
file = file.replace("./out", "").replace("index.html", "")
|
|
||||||
res += `<url><loc>${domain}${file}</loc></url>`
|
|
||||||
}
|
|
||||||
|
|
||||||
res += `</urlset>`
|
|
||||||
fs.writeFileSync('./out/sitemap.xml', res)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
console.log(res)
|
|
@ -110,7 +110,6 @@ $color = #6200EE
|
|||||||
&.icon-right select, &.icon-left select
|
&.icon-right select, &.icon-left select
|
||||||
max-width 100%
|
max-width 100%
|
||||||
|
|
||||||
|
|
||||||
input:focus:not([readonly]) + i,
|
input:focus:not([readonly]) + i,
|
||||||
select:focus:not([readonly]) + i
|
select:focus:not([readonly]) + i
|
||||||
color $color
|
color $color
|
||||||
|
Loading…
x
Reference in New Issue
Block a user