Skip to content

Commit

Permalink
facebook: fix build of static site, remove path which we don't have yet
Browse files Browse the repository at this point in the history
  • Loading branch information
redshiftzero committed Feb 21, 2025
1 parent 9ba5d6d commit 433ffae
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 8 deletions.
20 changes: 20 additions & 0 deletions archive-static-sites/facebook-archive/public/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<!DOCTYPE html>
<html lang="">

<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<title>Cyd Archive: Facebook</title>

</head>

<body>
<noscript>
<strong>This page doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
</noscript>
<div id="app"></div>
<script src="assets/archive.js"></script>
</body>

</html>
10 changes: 5 additions & 5 deletions archive-static-sites/facebook-archive/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ import { FacebookArchive } from './types'
const archiveDataFound = ref(false);
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const archiveData = ref<FacebookArchive>((window as any).archiveData);
provide('archiveData', archiveData);
onMounted(() => {
// Make sure the archive data is there
archiveDataFound.value = 'archiveData' in window;
// Set the document title
if (archiveDataFound.value) {
document.title = `${archiveData.value.username}'s Facebook Archive`;
Expand All @@ -28,15 +28,15 @@ onMounted(() => {
<img src="./assets/icon.svg" alt="Cyd" class="icon" style="height: 40px;">
</a>
<span class="navbar-text">
<i class="fa-brands fa-facebook"></i> Archive: <b>{{ archiveData.username }}</b>
<i class="fa-brands fa-facebook"></i> Archive: <b>{{ archiveData?.username }}</b>
</span>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav"
aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav ms-auto">
<li v-if="archiveData.posts.length > 0" class="nav-item">
<li v-if="archiveData?.posts?.length && archiveData.posts.length > 0" class="nav-item">
<router-link to="/" class="nav-link">Posts</router-link>
</li>
</ul>
Expand All @@ -49,8 +49,8 @@ onMounted(() => {
<footer class="mt-auto bg-light py-3">
<div class="container">
<p class="text-center mb-0">Archive created with <a href="https://cyd.social/">Cyd</a> v{{
archiveData.appVersion }} | Exported {{
formattedDate(archiveData.createdAt) }}</p>
archiveData?.appVersion }} | Exported {{
formattedDate(archiveData?.createdAt || '') }}</p>
</div>
</footer>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ const formattedText = computed(() => {
<a v-if="post.archivedAt"
:href="`./Archived Posts/${formatDateToYYYYMMDD(post.createdAt)}_${post.postID}.html`"
target="_blank">archived</a>
<a :href="`https://facebook.com/${post.path}`" target="_blank">original</a>
<small v-if="post.createdAt">{{ formattedDatetime(post.createdAt) }}</small>
<small v-else class="text-muted">unknown date</small>
</div>
Expand Down
1 change: 0 additions & 1 deletion archive-static-sites/facebook-archive/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ export type Post = {
postID: string;
createdAt: string;
text: string;
path: string;
archivedAt: string | null;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ const archiveData = inject('archiveData') as Ref<FacebookArchive>;
const filterText = ref('');
const filteredPosts = computed(() => {
if (!archiveData.value?.posts) {
console.log('No posts found in archive data:', archiveData.value);
return [];
}
return archiveData.value.posts.filter(post => {
const lowerCaseFilterText = filterText.value.toLowerCase();
const postText = post.text ? post.text.toLowerCase() : '';
Expand All @@ -20,7 +24,7 @@ const filteredPosts = computed(() => {
<template>
<div class="tweets-container">
<div class="filter-container">
<p><input type="text" v-model="filterText" class="form-control" placeholder="Filter your tweets"></p>
<p><input type="text" v-model="filterText" class="form-control" placeholder="Filter your posts"></p>
<p class="text-center text-muted small">Showing {{ filteredPosts.length.toLocaleString() }} posts</p>
</div>

Expand Down
21 changes: 21 additions & 0 deletions archive-static-sites/facebook-archive/vue.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
const { defineConfig } = require('@vue/cli-service');

module.exports = defineConfig({
publicPath: './',
configureWebpack: {
output: {
filename: 'assets/js/[name].[fullhash:8].js',
chunkFilename: 'assets/js/[name].[fullhash:8].js',
},
},
chainWebpack: config => {
if (config.plugins.has('extract-css')) {
config.plugin('extract-css').tap(args => {
args[0].filename = 'assets/css/[name].[fullhash:8].css';
args[0].chunkFilename = 'assets/css/[name].[fullhash:8].css';
return args;
});
}
},
assetsDir: 'assets',
});

0 comments on commit 433ffae

Please sign in to comment.