Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env node

// This script patches the OurBigBook library source code to add toplevel_id_clean variable

const fs = require('fs');
const path = require('path');

// Path to the ourbigbook index.js file
const ourbigbookIndexPath = path.join(__dirname, 'node_modules', 'ourbigbook', 'index.js');

// Read the original source
let source = fs.readFileSync(ourbigbookIndexPath, 'utf8');

// Find the line where toplevel_id is assigned and add our variable right after it
// The line is: options.template_vars.toplevel_id = toplevel_id
const originalLine = 'options.template_vars.toplevel_id = toplevel_id';
const patchedLine = `options.template_vars.toplevel_id = toplevel_id
options.template_vars.toplevel_id_clean = toplevel_id.replace(/\\.html$/, '')`;

if (source.includes(originalLine) && !source.includes('toplevel_id_clean')) {
source = source.replace(originalLine, patchedLine);
fs.writeFileSync(ourbigbookIndexPath, source);
}

// Now require and run the original ourbigbook CLI
require('./node_modules/ourbigbook/ourbigbook');
4 changes: 3 additions & 1 deletion ourbigbook.liquid.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
<script type="application/ld+json">{"name":"Ciro Santilli","url":"https://cirosantilli.com"}</script>{% endif %}
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.10.1/css/all.min.css" integrity="sha512-9my9Mb2+0YO+I4PUCSwUYO7sEK21Y0STBAiFEYoWtd2VzLEZZ4QARDrZ30hdM1GlioHJ8o8cWQiy8IAb1hy/Hg==" crossorigin="anonymous" referrerpolicy="no-referrer">{% unless is_index_article %}
<link rel="canonical" href="https://ourbigbook.com/cirosantilli/{{ toplevel_id }}">{% endunless %}
<link rel="canonical" href="https://ourbigbook.com/cirosantilli/{{ toplevel_id_clean }}">{% endunless %}{% if is_index_article %}
<meta property="og:url" content="https://cirosantilli.com">{% else %}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot why one points to ourbigbook.com and the other to cirosantilli.com?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The domain difference follows this logic:

  • Index articles (homepage): og:url points to https://cirosantilli.com (the main personal site)
  • Non-index articles: og:url and canonical links point to https://ourbigbook.com/cirosantilli/... (where the content actually lives)

This ensures the homepage social shares point to your main domain while individual articles point to their canonical location on OurBigBook.com. Both URLs now properly strip .html extensions for clean URLs.

<meta property="og:url" content="https://ourbigbook.com/cirosantilli/{{ toplevel_id_clean }}">{% endif %}
<style>{{ style }}</style>
<link rel="stylesheet" type="text/css" href="{{ raw_relpath }}/main.css">
<link rel="shortcut icon" type="image/x-icon" href="{{ github_prefix }}/ID_photo_of_Ciro_Santilli_taken_in_2013_square_398.jpg">
Expand Down