65 lines
1.8 KiB
JavaScript
65 lines
1.8 KiB
JavaScript
|
|
import { promises as fs } from 'node:fs'
|
||
|
|
import path from 'node:path'
|
||
|
|
|
||
|
|
const appRoot = process.cwd()
|
||
|
|
const newsDir = path.join(appRoot, 'content', 'news')
|
||
|
|
const casesDir = path.join(appRoot, 'content', 'cases')
|
||
|
|
|
||
|
|
const markdownFiles = async (dir) => {
|
||
|
|
const entries = await fs.readdir(dir, { withFileTypes: true })
|
||
|
|
return entries
|
||
|
|
.filter((entry) => entry.isFile() && entry.name.endsWith('.md'))
|
||
|
|
.map((entry) => entry.name.replace(/\.md$/, ''))
|
||
|
|
.sort()
|
||
|
|
}
|
||
|
|
|
||
|
|
const buildRoutes = async () => {
|
||
|
|
const news = await markdownFiles(newsDir)
|
||
|
|
const cases = await markdownFiles(casesDir)
|
||
|
|
|
||
|
|
return [
|
||
|
|
'/',
|
||
|
|
'/contact',
|
||
|
|
'/company',
|
||
|
|
'/company/culture',
|
||
|
|
'/company/tech',
|
||
|
|
'/company/joinus',
|
||
|
|
'/products/ecommerce',
|
||
|
|
'/products/ecommerce/freight-booking',
|
||
|
|
'/products/ecommerce/net-cargo',
|
||
|
|
'/products/ecommerce/bctp',
|
||
|
|
'/products/ecommerce/obh',
|
||
|
|
'/products/logistics',
|
||
|
|
'/products/logistics/platform',
|
||
|
|
'/products/logistics/cargo-agent',
|
||
|
|
'/products/logistics/ship-agent',
|
||
|
|
'/products/logistics/vehicle-transport',
|
||
|
|
'/products/logistics/warehouse',
|
||
|
|
'/products/port',
|
||
|
|
'/products/port/cdi',
|
||
|
|
'/products/port/cdi-bulk',
|
||
|
|
'/products/port/cdi-container',
|
||
|
|
'/products/port/cloud-yard',
|
||
|
|
'/products/shipping',
|
||
|
|
'/products/shipping/boat',
|
||
|
|
'/products/shipping/company',
|
||
|
|
'/solutions/inland-river-shipping',
|
||
|
|
'/solutions/logistics-chain',
|
||
|
|
'/solutions/port-supply-chain',
|
||
|
|
'/solutions/supply-chain',
|
||
|
|
'/services/chuandai',
|
||
|
|
'/services/yunmatou',
|
||
|
|
'/services/jining',
|
||
|
|
'/services/dianshang',
|
||
|
|
'/services/ilog',
|
||
|
|
'/services/changzhan',
|
||
|
|
'/news',
|
||
|
|
'/cases',
|
||
|
|
...news.map((slug) => `/news/${slug}`),
|
||
|
|
...cases.map((slug) => `/cases/${slug}`)
|
||
|
|
]
|
||
|
|
}
|
||
|
|
|
||
|
|
const routes = await buildRoutes()
|
||
|
|
process.stdout.write(`${JSON.stringify(routes, null, 2)}\n`)
|