// routes/admin.js

import { Router } from "../deps.ts"

const router = Router()

import post from './admin/post.js'
router.use('/post', post)

export default router

 

// routes/admin/post.js

import { Router } from "../../deps.ts"
const router = Router()

import post from '../../controllers/admin/post.js'

router.get('/', async (req, res) => {
  post.getItem(req, res)
})
  
export default router

 

// controllers/admin/post.js

import config from '../../config.js'
import post from '../../views/admin/post.jsx'

class Post{
    async getItem(req, res){
        this.config = await config()
        this.config.pageTitle = 'ទំព័​រ​ការផ្សាយ'
        this.config.route = '/admin/post'
        this.config.type = 'post'

        const html = await post(this.config)
        res.send(html)
    }
}

export default new Post()

 

// views/admin/post.jsx

/** @jsx h */
import { h, renderSSR } from "../../deps.ts"

function PostJsx(props){
  return(
    <html>
      <head>
        <meta charset="UTF-8"/>
        <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
        <title>{props.config.siteTitle} | {props.config.pageTitle}</title>
        <link href="/images/siteLogo.png" rel="icon" />
        <link href="/styles/base.css" rel="stylesheet" />
        <link href="/fonts/setup.css" rel="stylesheet" />
        <script src="/scripts/jquery.js"></script>
      </head>
      <body>
        <section class="Post">
            {props.config.pageTitle}
        </section>
      </body>
    </html>
  )
}

function Post(config){
  const str = renderSSR(<PostJsx config={config} />)
  const html = `<!DOCTYPE html>${str}`
  return html
}

export default Post

 

GitHub: https://github.com/Sokhavuth/khmerweb-deno

Deno Deploy: https://khmerweb-blog.deno.dev/login