fix for new clones with no dist folder
This commit is contained in:
parent
2763762ae6
commit
a8bbb95cc0
2 changed files with 13 additions and 13 deletions
|
@ -15,8 +15,6 @@ const { parseURI } = require('lbry-redux');
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
|
|
||||||
let html = fs.readFileSync(path.join(__dirname, '/../dist/index.html'), 'utf8');
|
|
||||||
|
|
||||||
function insertToHead(fullHtml, htmlToInsert) {
|
function insertToHead(fullHtml, htmlToInsert) {
|
||||||
return fullHtml.replace(
|
return fullHtml.replace(
|
||||||
/<!-- VARIABLE_HEAD_BEGIN -->.*<!-- VARIABLE_HEAD_END -->/s,
|
/<!-- VARIABLE_HEAD_BEGIN -->.*<!-- VARIABLE_HEAD_END -->/s,
|
||||||
|
@ -155,8 +153,10 @@ async function getClaimFromChainquery(url) {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getHtml(ctx) {
|
async function getHtml(ctx) {
|
||||||
const path = decodeURIComponent(ctx.path);
|
const html = fs.readFileSync(path.join(__dirname, '/../dist/index.html'), 'utf8');
|
||||||
if (path.length === 0) {
|
const requestPath = decodeURIComponent(ctx.path);
|
||||||
|
|
||||||
|
if (requestPath.length === 0) {
|
||||||
const ogMetadata = buildBasicOgMetadata();
|
const ogMetadata = buildBasicOgMetadata();
|
||||||
return insertToHead(html, ogMetadata);
|
return insertToHead(html, ogMetadata);
|
||||||
}
|
}
|
||||||
|
@ -164,7 +164,7 @@ async function getHtml(ctx) {
|
||||||
const invitePath = `/$/${PAGES.INVITE}/`;
|
const invitePath = `/$/${PAGES.INVITE}/`;
|
||||||
const embedPath = `/$/${PAGES.EMBED}/`;
|
const embedPath = `/$/${PAGES.EMBED}/`;
|
||||||
|
|
||||||
if (path.includes(invitePath)) {
|
if (requestPath.includes(invitePath)) {
|
||||||
const inviteChannel = path.slice(invitePath.length).replace(/:/g, '#');
|
const inviteChannel = path.slice(invitePath.length).replace(/:/g, '#');
|
||||||
const inviteChannelUrl = `lbry://${inviteChannel}`;
|
const inviteChannelUrl = `lbry://${inviteChannel}`;
|
||||||
|
|
||||||
|
@ -188,8 +188,8 @@ async function getHtml(ctx) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (path.includes(embedPath)) {
|
if (requestPath.includes(embedPath)) {
|
||||||
const claimUri = path.replace(embedPath, '').replace(/:/g, '#');
|
const claimUri = requestPath.replace(embedPath, '').replace(/:/g, '#');
|
||||||
const claim = await getClaimFromChainquery(claimUri);
|
const claim = await getClaimFromChainquery(claimUri);
|
||||||
|
|
||||||
if (claim) {
|
if (claim) {
|
||||||
|
@ -200,8 +200,8 @@ async function getHtml(ctx) {
|
||||||
return insertToHead(html);
|
return insertToHead(html);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!path.includes('$')) {
|
if (!requestPath.includes('$')) {
|
||||||
const claimUri = path.slice(1).replace(/:/g, '#');
|
const claimUri = requestPath.slice(1).replace(/:/g, '#');
|
||||||
const claim = await getClaimFromChainquery(claimUri);
|
const claim = await getClaimFromChainquery(claimUri);
|
||||||
|
|
||||||
if (claim) {
|
if (claim) {
|
||||||
|
|
|
@ -6,7 +6,7 @@ const baseConfig = require('../webpack.base.config.js');
|
||||||
const CopyWebpackPlugin = require('copy-webpack-plugin');
|
const CopyWebpackPlugin = require('copy-webpack-plugin');
|
||||||
const { DefinePlugin, ProvidePlugin } = require('webpack');
|
const { DefinePlugin, ProvidePlugin } = require('webpack');
|
||||||
const SentryWebpackPlugin = require('@sentry/webpack-plugin');
|
const SentryWebpackPlugin = require('@sentry/webpack-plugin');
|
||||||
// const { insertToHead, buildBasicOgMetadata } = require('./src/html');
|
const { insertToHead, buildBasicOgMetadata } = require('./src/html');
|
||||||
|
|
||||||
const CUSTOM_ROOT = path.resolve(__dirname, '../custom/');
|
const CUSTOM_ROOT = path.resolve(__dirname, '../custom/');
|
||||||
const STATIC_ROOT = path.resolve(__dirname, '../static/');
|
const STATIC_ROOT = path.resolve(__dirname, '../static/');
|
||||||
|
@ -20,9 +20,9 @@ const copyWebpackCommands = [
|
||||||
{
|
{
|
||||||
from: `${STATIC_ROOT}/index-web.html`,
|
from: `${STATIC_ROOT}/index-web.html`,
|
||||||
to: `${DIST_ROOT}/index.html`,
|
to: `${DIST_ROOT}/index.html`,
|
||||||
// transform(content, path) {
|
transform(content, path) {
|
||||||
// return insertToHead(content.toString(), buildBasicOgMetadata());
|
return insertToHead(content.toString(), buildBasicOgMetadata());
|
||||||
// },
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
from: `${STATIC_ROOT}/img/favicon.png`,
|
from: `${STATIC_ROOT}/img/favicon.png`,
|
||||||
|
|
Loading…
Reference in a new issue