-
Notifications
You must be signed in to change notification settings - Fork 0
/
post.html
40 lines (35 loc) · 976 Bytes
/
post.html
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
<html><head><meta name="robots" content="noindex,nofollow,noarchive"><script>
/* https://qiita.com/h-kuwayama/items/6d429b3bd7f730e5b13b */
/*
* Config
*/
var file_name = 'post.html';
var parameter_key = 'post_id';
/*
* Env
*/
var path_name = window.location.pathname;
var query_string = window.location.search;
var base_dir = path_name.split(file_name)[0];
/*
* Process
* (Rewrite URL using historyAPI)
*/
var match_condition = new RegExp(parameter_key + '=[a-z0-9-_]+$');
if (parameter = query_string.match(match_condition))
{
parameter_value = parameter[0].split('=')[1];
history.replaceState(null, null, base_dir + file_name.replace('.html', '/') + parameter_value);
document.title = parameter_value + ' | Github Pages Rewrite';
}
</script>
<style>
@media (prefers-color-scheme: dark) {
body {
background-color: #323232;
color: #fff;
}
}
</style>
</head>
</html>