File size: 1,497 Bytes
3993320
 
 
 
1ebf5db
3993320
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import { mkdirSync, readFileSync, writeFileSync } from 'fs';
import { join } from 'path';

const BUILD_DIR = 'build';
const BASE_URL = 'https://omaib-musprot.hf.space';
const template = readFileSync(join(BUILD_DIR, 'index.html'), 'utf-8');

const routes = [
  {
    path: '',
    title: 'MuSProt: Multistate Protein Structure Database',
    description:
      'Explore multistate protein structures, pairwise comparisons, energy scores, and functional annotations.',
  },
  {
    path: 'docs',
    title: 'MuSProt Documentation',
    description: 'MuSProt dataset format, SQLite schema, and usage examples.',
  },
];

for (const route of routes) {
  const canonical = `${BASE_URL}/${route.path}`;
  const head = [
    `<title>${route.title}</title>`,
    `<meta name="description" content="${route.description}" />`,
    `<link rel="canonical" href="${canonical}" />`,
    `<meta property="og:title" content="${route.title}" />`,
    `<meta property="og:description" content="${route.description}" />`,
    `<meta property="og:url" content="${canonical}" />`,
    `<meta property="og:site_name" content="MuSProt" />`,
  ].join('\n    ');

  const html = template
    .replace(/<title>[^<]*<\/title>/, '')
    .replace(/<meta\s+name="description"[^>]*\/?>/, '')
    .replace('</head>', `    ${head}\n  </head>`);

  const outputDir = route.path ? join(BUILD_DIR, route.path) : BUILD_DIR;
  mkdirSync(outputDir, { recursive: true });
  writeFileSync(join(outputDir, 'index.html'), html, 'utf-8');
}